From 05f7f9bc58596000406bcbbd94123bb31b3cba33 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Wed, 5 Feb 2014 19:15:33 +0100 Subject: QOpenGLTextureHelper: fix 3D texture support on ES2 The code first tried to check for the GL_OES_texture_3D extension, and if present it resolved the pointers to the gl*Tex*3DOES functions. But then it overwrote those pointers by attempting to resolve the Desktop GL gl*Tex*3D functions, thus making them unusable. So, if the extension is found, don't overwrite the pointers. If the extension is NOT found, keep the general behavior of still trying to resolve those functions. (That is going to fail, but refactoring the general behavior belongs to a separate commit.) Change-Id: Idaba122cf9500f136e3f79284d3c82284257036d Reviewed-by: James Turner Reviewed-by: Sean Harmer --- src/gui/opengl/qopengltexturehelper.cpp | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) (limited to 'src/gui/opengl') diff --git a/src/gui/opengl/qopengltexturehelper.cpp b/src/gui/opengl/qopengltexturehelper.cpp index 4da9b3f164..97ae4df804 100644 --- a/src/gui/opengl/qopengltexturehelper.cpp +++ b/src/gui/opengl/qopengltexturehelper.cpp @@ -119,15 +119,6 @@ QOpenGLTextureHelper::QOpenGLTextureHelper(QOpenGLContext *context) CompressedTextureImage1D = &QOpenGLTextureHelper::qt_CompressedTextureImage1D; CompressedTextureImage2D = &QOpenGLTextureHelper::qt_CompressedTextureImage2D; CompressedTextureImage3D = &QOpenGLTextureHelper::qt_CompressedTextureImage3D; -#if defined(QT_OPENGL_ES_2) - if (context->hasExtension(QByteArrayLiteral("GL_OES_texture_3D"))) { - TexImage3D = reinterpret_cast(context->getProcAddress(QByteArrayLiteral("glTexImage3DOES"))); - TexSubImage3D = reinterpret_cast(context->getProcAddress(QByteArrayLiteral("glTexSubImage3DOES"))); - CompressedTexImage3D = reinterpret_cast(context->getProcAddress(QByteArrayLiteral("glCompressedTexImage3DOES"))); - CompressedTexSubImage3D = reinterpret_cast(context->getProcAddress(QByteArrayLiteral("glCompressedTexSubImage3DOES"))); - } -#endif - #if !defined(QT_OPENGL_ES_2) } #endif @@ -200,18 +191,30 @@ QOpenGLTextureHelper::QOpenGLTextureHelper(QOpenGLContext *context) TexSubImage1D = reinterpret_cast(context->getProcAddress(QByteArrayLiteral("glTexSubImage1D"))); #endif - // OpenGL 1.2 - TexImage3D = reinterpret_cast(context->getProcAddress(QByteArrayLiteral("glTexImage3D"))); - TexSubImage3D = reinterpret_cast(context->getProcAddress(QByteArrayLiteral("glTexSubImage3D"))); +#if defined(QT_OPENGL_ES_2) + if (context->hasExtension(QByteArrayLiteral("GL_OES_texture_3D"))) { + TexImage3D = reinterpret_cast(context->getProcAddress(QByteArrayLiteral("glTexImage3DOES"))); + TexSubImage3D = reinterpret_cast(context->getProcAddress(QByteArrayLiteral("glTexSubImage3DOES"))); + CompressedTexImage3D = reinterpret_cast(context->getProcAddress(QByteArrayLiteral("glCompressedTexImage3DOES"))); + CompressedTexSubImage3D = reinterpret_cast(context->getProcAddress(QByteArrayLiteral("glCompressedTexSubImage3DOES"))); + } else +#endif + { + // OpenGL 1.2 + TexImage3D = reinterpret_cast(context->getProcAddress(QByteArrayLiteral("glTexImage3D"))); + TexSubImage3D = reinterpret_cast(context->getProcAddress(QByteArrayLiteral("glTexSubImage3D"))); + + // OpenGL 1.3 + CompressedTexImage3D = reinterpret_cast(context->getProcAddress(QByteArrayLiteral("glCompressedTexImage3D"))); + CompressedTexSubImage3D = reinterpret_cast(context->getProcAddress(QByteArrayLiteral("glCompressedTexSubImage3D"))); + } // OpenGL 1.3 GetCompressedTexImage = reinterpret_cast(context->getProcAddress(QByteArrayLiteral("glGetCompressedTexImage"))); CompressedTexSubImage1D = reinterpret_cast(context->getProcAddress(QByteArrayLiteral("glCompressedTexSubImage1D"))); CompressedTexSubImage2D = reinterpret_cast(context->getProcAddress(QByteArrayLiteral("glCompressedTexSubImage2D"))); - CompressedTexSubImage3D = reinterpret_cast(context->getProcAddress(QByteArrayLiteral("glCompressedTexSubImage3D"))); CompressedTexImage1D = reinterpret_cast(context->getProcAddress(QByteArrayLiteral("glCompressedTexImage1D"))); CompressedTexImage2D = reinterpret_cast(context->getProcAddress(QByteArrayLiteral("glCompressedTexImage2D"))); - CompressedTexImage3D = reinterpret_cast(context->getProcAddress(QByteArrayLiteral("glCompressedTexImage3D"))); ActiveTexture = reinterpret_cast(context->getProcAddress(QByteArrayLiteral("glActiveTexture"))); // OpenGL 3.0 -- cgit v1.2.3