From 77cb1b8794156d5b036b983d8376855bfa9cbfd7 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Wed, 11 Feb 2015 08:57:56 +0100 Subject: Prevent crashing on ES2 SDK - ES3 device scenarios with Android Making a build with an older NDK having only gl2.h results in crashing QOpenGLTexture on devices that provide ES 3.0 or 3.1. This is because immutable storage is supported (based on runtime checks) but the function pointers are not there (due to ifdef checks). Fix this like we did in other places: get rid of the ifdef and dlsym the ES3-only symbols. Task-number: QTBUG-44397 Change-Id: Ief518ec8c7d532aeea0075ba166baf8d22e66ec5 Reviewed-by: Sean Harmer --- src/gui/opengl/qopengltexturehelper.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'src/gui/opengl/qopengltexturehelper.cpp') diff --git a/src/gui/opengl/qopengltexturehelper.cpp b/src/gui/opengl/qopengltexturehelper.cpp index 3f55dfdba7..386c4af232 100644 --- a/src/gui/opengl/qopengltexturehelper.cpp +++ b/src/gui/opengl/qopengltexturehelper.cpp @@ -201,13 +201,16 @@ QOpenGLTextureHelper::QOpenGLTextureHelper(QOpenGLContext *context) TexImage2DMultisample = 0; // OpenGL 4.2 -#ifdef QT_OPENGL_ES_3 - TexStorage3D = ::glTexStorage3D; - TexStorage2D = ::glTexStorage2D; -#else - TexStorage3D = 0; - TexStorage2D = 0; -#endif + QOpenGLContext *ctx = QOpenGLContext::currentContext(); + if (ctx->format().majorVersion() >= 3) { + // OpenGL ES 3.0+ has immutable storage for 2D and 3D at least. + QOpenGLES3Helper *es3 = static_cast(ctx->functions())->gles3Helper(); + TexStorage3D = es3->TexStorage3D; + TexStorage2D = es3->TexStorage2D; + } else { + TexStorage3D = 0; + TexStorage2D = 0; + } TexStorage1D = 0; // OpenGL 4.3 -- cgit v1.2.3