Просмотр исходного кода

Merge pull request #22 from blackberry-gaming/next-ablake

Change to Texture, fixes DepthStencilTarget
Sean Paul Taylor 14 лет назад
Родитель
Сommit
08f1ec9384
1 измененных файлов с 10 добавлено и 1 удалено
  1. 10 1
      gameplay/src/Texture.cpp

+ 10 - 1
gameplay/src/Texture.cpp

@@ -197,7 +197,16 @@ Texture* Texture::create(Format format, unsigned int width, unsigned int height,
     GLuint textureId;
     GL_ASSERT( glGenTextures(1, &textureId) );
     GL_ASSERT( glBindTexture(GL_TEXTURE_2D, textureId) );
-    GL_ASSERT( glTexImage2D(GL_TEXTURE_2D, 0, (GLenum)format, width, height, 0, (GLenum)format, GL_UNSIGNED_BYTE, data) );
+
+    if (format == DEPTH)
+    {
+        // <type> must be UNSIGNED_SHORT or UNSIGNED_INT for a format of DEPTH_COMPONENT.
+        GL_ASSERT( glTexImage2D(GL_TEXTURE_2D, 0, (GLenum)format, width, height, 0, (GLenum)format, GL_UNSIGNED_INT, data) );
+    }
+    else
+    {
+        GL_ASSERT( glTexImage2D(GL_TEXTURE_2D, 0, (GLenum)format, width, height, 0, (GLenum)format, GL_UNSIGNED_BYTE, data) );
+    }
 
     // Set initial minification filter based on whether or not mipmaping was enabled
     GL_ASSERT( glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, generateMipmaps ? GL_NEAREST_MIPMAP_LINEAR : GL_LINEAR) );