diff --git a/src/gui/opengl/qopenglextensions_p.h b/src/gui/opengl/qopenglextensions_p.h index aa712f51a3..aa2f784d86 100644 --- a/src/gui/opengl/qopenglextensions_p.h +++ b/src/gui/opengl/qopenglextensions_p.h @@ -72,6 +72,9 @@ public: void (QOPENGLF_APIENTRYP CompressedTexImage3D)(GLenum target, GLint level, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); void (QOPENGLF_APIENTRYP CompressedTexSubImage3D)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); + void (QOPENGLF_APIENTRYP TexStorage3D)(GLenum target, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth); + void (QOPENGLF_APIENTRYP TexStorage2D)(GLenum target, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height); + private: QLibrary m_gl; }; diff --git a/src/gui/opengl/qopenglfunctions.cpp b/src/gui/opengl/qopenglfunctions.cpp index aefea9a0e9..587995515d 100644 --- a/src/gui/opengl/qopenglfunctions.cpp +++ b/src/gui/opengl/qopenglfunctions.cpp @@ -3229,7 +3229,10 @@ QOpenGLES3Helper::QOpenGLES3Helper() CompressedTexImage3D = (void (QOPENGLF_APIENTRYP)(GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *)) m_gl.resolve("glCompressedTexImage3D"); CompressedTexSubImage3D = (void (QOPENGLF_APIENTRYP)(GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *)) m_gl.resolve("glCompressedTexSubImage3D"); - if (!MapBufferRange || !GenVertexArrays || !TexImage3D) + TexStorage3D = (void (QOPENGLF_APIENTRYP)(GLenum, GLsizei, GLenum, GLsizei, GLsizei, GLsizei)) m_gl.resolve("glTexStorage3D"); + TexStorage2D = (void (QOPENGLF_APIENTRYP)(GLenum, GLsizei, GLenum, GLsizei, GLsizei)) m_gl.resolve("glTexStorage2D"); + + if (!MapBufferRange || !GenVertexArrays || !TexImage3D || !TexStorage3D) qFatal("OpenGL ES 3.0 entry points not found"); } else { qFatal("Failed to load libGLESv2"); 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