diff --git a/libraries/gl/src/gl/GLHelpers.cpp b/libraries/gl/src/gl/GLHelpers.cpp index c9de3ccd90..ffeaed4e4f 100644 --- a/libraries/gl/src/gl/GLHelpers.cpp +++ b/libraries/gl/src/gl/GLHelpers.cpp @@ -12,11 +12,12 @@ const QSurfaceFormat& getDefaultOpenGLSurfaceFormat() { // Qt Quick may need a depth and stencil buffer. Always make sure these are available. format.setDepthBufferSize(DEFAULT_GL_DEPTH_BUFFER_BITS); format.setStencilBufferSize(DEFAULT_GL_STENCIL_BUFFER_BITS); - format.setVersion(4, 5); + setGLFormatVersion(format); #ifdef DEBUG format.setOption(QSurfaceFormat::DebugContext); #endif format.setProfile(QSurfaceFormat::OpenGLContextProfile::CoreProfile); + QSurfaceFormat::setDefaultFormat(format); }); return format; } @@ -27,11 +28,12 @@ const QGLFormat& getDefaultGLFormat() { static QGLFormat glFormat; static std::once_flag once; std::call_once(once, [] { - glFormat.setVersion(4, 5); + setGLFormatVersion(glFormat); glFormat.setProfile(QGLFormat::CoreProfile); // Requires >=Qt-4.8.0 glFormat.setSampleBuffers(false); glFormat.setDepth(false); glFormat.setStencil(false); + QGLFormat::setDefaultFormat(glFormat); }); return glFormat; } diff --git a/libraries/gl/src/gl/GLHelpers.h b/libraries/gl/src/gl/GLHelpers.h index 335272d991..6e3d678d0c 100644 --- a/libraries/gl/src/gl/GLHelpers.h +++ b/libraries/gl/src/gl/GLHelpers.h @@ -19,6 +19,9 @@ class QSurfaceFormat; class QGLFormat; +template +void setGLFormatVersion(F& format, int major = 4, int minor = 5) { format.setVersion(major, minor); } + const QSurfaceFormat& getDefaultOpenGLSurfaceFormat(); const QGLFormat& getDefaultGLFormat(); #endif diff --git a/tests/gpu-test/src/main.cpp b/tests/gpu-test/src/main.cpp index 87ce2d7622..d1cd4389a7 100644 --- a/tests/gpu-test/src/main.cpp +++ b/tests/gpu-test/src/main.cpp @@ -34,6 +34,7 @@ #include #include +#include #include #include @@ -141,7 +142,7 @@ public: // Qt Quick may need a depth and stencil buffer. Always make sure these are available. format.setDepthBufferSize(16); format.setStencilBufferSize(8); - format.setVersion(4, 3); + setGLFormatVersion(format); format.setProfile(QSurfaceFormat::OpenGLContextProfile::CoreProfile); format.setOption(QSurfaceFormat::DebugContext); format.setSwapInterval(0); diff --git a/tests/render-utils/src/main.cpp b/tests/render-utils/src/main.cpp index 6a4154c8c3..6973ca075e 100644 --- a/tests/render-utils/src/main.cpp +++ b/tests/render-utils/src/main.cpp @@ -16,6 +16,7 @@ #include #include +#include #include #include @@ -98,7 +99,7 @@ public: // Qt Quick may need a depth and stencil buffer. Always make sure these are available. format.setDepthBufferSize(16); format.setStencilBufferSize(8); - format.setVersion(4, 1); + setGLFormatVersion(format); format.setProfile(QSurfaceFormat::OpenGLContextProfile::CoreProfile); format.setOption(QSurfaceFormat::DebugContext);