From 7c52bd0b28eaf0b1d5435fda6140a9d05fddba19 Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Fri, 11 Sep 2009 08:30:20 +1000 Subject: Make an EGL context current when initializing GL extensions Reviewed-by: trustme --- src/opengl/qgl_qws.cpp | 23 +++++++++++++++++++++++ src/opengl/qgl_wince.cpp | 7 +++++++ src/opengl/qgl_x11egl.cpp | 7 +++++++ 3 files changed, 37 insertions(+) diff --git a/src/opengl/qgl_qws.cpp b/src/opengl/qgl_qws.cpp index c71ceeb..759f9de 100644 --- a/src/opengl/qgl_qws.cpp +++ b/src/opengl/qgl_qws.cpp @@ -41,6 +41,7 @@ #include "qgl.h" #include "qgl_egl_p.h" +#include "qglpixelbuffer.h" #include #include @@ -411,7 +412,29 @@ void QGLExtensions::init() if (init_done) return; init_done = true; + + // We need a context current to initialize the extensions, + // but getting a valid EGLNativeWindowType this early can be + // problematic under QWS. So use a pbuffer instead. + // + // Unfortunately OpenGL/ES 2.0 systems don't normally + // support pbuffers, so we have no choice but to try + // our luck with a window on those systems. +#if defined(QT_OPENGL_ES_2) + QGLWidget tmpWidget; + tmpWidget.makeCurrent(); + init_extensions(); + + tmpWidget.doneCurrent(); +#else + QGLPixelBuffer pbuffer(16, 16); + pbuffer.makeCurrent(); + + init_extensions(); + + pbuffer.doneCurrent(); +#endif } QT_END_NAMESPACE diff --git a/src/opengl/qgl_wince.cpp b/src/opengl/qgl_wince.cpp index 881d7f7..83efca8 100644 --- a/src/opengl/qgl_wince.cpp +++ b/src/opengl/qgl_wince.cpp @@ -730,7 +730,14 @@ void QGLExtensions::init() if (init_done) return; init_done = true; + + // We need a context current to initialize the extensions. + QGLWidget tmpWidget; + tmpWidget.makeCurrent(); + init_extensions(); + + tmpWidget.doneCurrent(); } QT_END_NAMESPACE diff --git a/src/opengl/qgl_x11egl.cpp b/src/opengl/qgl_x11egl.cpp index 055138d..c54315f 100644 --- a/src/opengl/qgl_x11egl.cpp +++ b/src/opengl/qgl_x11egl.cpp @@ -470,7 +470,14 @@ void QGLExtensions::init() if (init_done) return; init_done = true; + + // We need a context current to initialize the extensions. + QGLWidget tmpWidget; + tmpWidget.makeCurrent(); + init_extensions(); + + tmpWidget.doneCurrent(); } // Re-creates the EGL surface if the window ID has changed or if force is true -- cgit v0.12