summaryrefslogtreecommitdiffstats
path: root/src/opengl
diff options
context:
space:
mode:
authorSamuel Rødal <samuel.rodal@nokia.com>2011-07-15 15:29:29 (GMT)
committerSamuel Rødal <samuel.rodal@nokia.com>2011-07-26 08:57:11 (GMT)
commitd852e6164a4aaf8e235e97cba8f0e8e9b933987c (patch)
tree7577ad2b4c80bffab4212e49364ea77a949bd187 /src/opengl
parent5c1ec4373f63045c4c56f748e47612b3bfc9ab88 (diff)
downloadQt-d852e6164a4aaf8e235e97cba8f0e8e9b933987c.zip
Qt-d852e6164a4aaf8e235e97cba8f0e8e9b933987c.tar.gz
Qt-d852e6164a4aaf8e235e97cba8f0e8e9b933987c.tar.bz2
Properly resolve and use glMapBuffer / glUnmapBuffer on GLES2.
Even though we're able to resolve the function pointers, the spec says we have to check for the GL_OES_mapbuffer extension before we use them. Fixes a crash on a platform that doesn't advertise the extension but still resolves the function pointers. Reviewed-by: Kim
Diffstat (limited to 'src/opengl')
-rw-r--r--src/opengl/qglbuffer.cpp4
-rw-r--r--src/opengl/qglextensions.cpp33
-rw-r--r--src/opengl/qglextensions_p.h4
3 files changed, 28 insertions, 13 deletions
diff --git a/src/opengl/qglbuffer.cpp b/src/opengl/qglbuffer.cpp
index a1ec3ef..b5c6b83 100644
--- a/src/opengl/qglbuffer.cpp
+++ b/src/opengl/qglbuffer.cpp
@@ -543,6 +543,10 @@ void *QGLBuffer::map(QGLBuffer::Access access)
return 0;
if (!glMapBufferARB)
return 0;
+#ifdef QT_OPENGL_ES_2
+ if (access != QGLBuffer::WriteOnly)
+ return 0;
+#endif
return glMapBufferARB(d->type, access);
}
diff --git a/src/opengl/qglextensions.cpp b/src/opengl/qglextensions.cpp
index 98d2960..64f7526 100644
--- a/src/opengl/qglextensions.cpp
+++ b/src/opengl/qglextensions.cpp
@@ -191,23 +191,30 @@ bool qt_resolve_frag_program_extensions(QGLContext *ctx)
bool qt_resolve_buffer_extensions(QGLContext *ctx)
{
+ if (!QGLContextPrivate::extensionFuncs(ctx).qt_bufferFuncsResolved) {
#if defined(QGL_RESOLVE_BUFFER_FUNCS)
- if (glBindBuffer && glDeleteBuffers && glGenBuffers && glBufferData
- && glBufferSubData && glGetBufferParameteriv)
- return true;
+ glBindBuffer = (_glBindBuffer) qt_gl_getProcAddressARB(ctx, "glBindBuffer");
+ glDeleteBuffers = (_glDeleteBuffers) qt_gl_getProcAddressARB(ctx, "glDeleteBuffers");
+ glGenBuffers = (_glGenBuffers) qt_gl_getProcAddressARB(ctx, "glGenBuffers");
+ glBufferData = (_glBufferData) qt_gl_getProcAddressARB(ctx, "glBufferData");
+ glBufferSubData = (_glBufferSubData) qt_gl_getProcAddressARB(ctx, "glBufferSubData");
+ glGetBufferSubData = (_glGetBufferSubData) qt_gl_getProcAddressARB(ctx, "glGetBufferSubData");
+ glGetBufferParameteriv = (_glGetBufferParameteriv) qt_gl_getProcAddressARB(ctx, "glGetBufferParameteriv");
#endif
-#if defined(QGL_RESOLVE_BUFFER_FUNCS)
- glBindBuffer = (_glBindBuffer) qt_gl_getProcAddressARB(ctx, "glBindBuffer");
- glDeleteBuffers = (_glDeleteBuffers) qt_gl_getProcAddressARB(ctx, "glDeleteBuffers");
- glGenBuffers = (_glGenBuffers) qt_gl_getProcAddressARB(ctx, "glGenBuffers");
- glBufferData = (_glBufferData) qt_gl_getProcAddressARB(ctx, "glBufferData");
- glBufferSubData = (_glBufferSubData) qt_gl_getProcAddressARB(ctx, "glBufferSubData");
- glGetBufferSubData = (_glGetBufferSubData) qt_gl_getProcAddressARB(ctx, "glGetBufferSubData");
- glGetBufferParameteriv = (_glGetBufferParameteriv) qt_gl_getProcAddressARB(ctx, "glGetBufferParameteriv");
+#ifdef QT_OPENGL_ES_2
+ QGLExtensionMatcher extensions;
+ if (extensions.match("GL_OES_mapbuffer")) {
+ glMapBufferARB = (_glMapBufferARB) qt_gl_getProcAddressARB(ctx, "glMapBufferOES");
+ glUnmapBufferARB = (_glUnmapBufferARB) qt_gl_getProcAddressARB(ctx, "glUnmapBufferOES");
+ }
+#else
+ glMapBufferARB = (_glMapBufferARB) qt_gl_getProcAddressARB(ctx, "glMapBuffer");
+ glUnmapBufferARB = (_glUnmapBufferARB) qt_gl_getProcAddressARB(ctx, "glUnmapBuffer");
#endif
- glMapBufferARB = (_glMapBufferARB) qt_gl_getProcAddressARB(ctx, "glMapBuffer");
- glUnmapBufferARB = (_glUnmapBufferARB) qt_gl_getProcAddressARB(ctx, "glUnmapBuffer");
+
+ QGLContextPrivate::extensionFuncs(ctx).qt_bufferFuncsResolved = true;
+ }
#if defined(QGL_RESOLVE_BUFFER_FUNCS)
return glBindBuffer
diff --git a/src/opengl/qglextensions_p.h b/src/opengl/qglextensions_p.h
index 98433c3..f85c89b 100644
--- a/src/opengl/qglextensions_p.h
+++ b/src/opengl/qglextensions_p.h
@@ -332,6 +332,8 @@ struct QGLExtensionFuncs
qt_glMapBufferARB = 0;
qt_glUnmapBufferARB = 0;
+ qt_bufferFuncsResolved = false;
+
qt_glProgramParameteriEXT = 0;
qt_glFramebufferTextureEXT = 0;
qt_glFramebufferTextureLayerEXT = 0;
@@ -457,6 +459,8 @@ struct QGLExtensionFuncs
_glMapBufferARB qt_glMapBufferARB;
_glUnmapBufferARB qt_glUnmapBufferARB;
+ bool qt_bufferFuncsResolved;
+
// Geometry shaders...
_glProgramParameteriEXT qt_glProgramParameteriEXT;
_glFramebufferTextureEXT qt_glFramebufferTextureEXT;