From ee79d942714d28d517bd0f1f48d66b65d2026626 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Tue, 2 Jul 2013 19:45:11 +0200 Subject: [PATCH] Add a way to test if an OpenGL context has the fixed function pipeline available Due to the mess done in 3.0/3.1 this is trickier than it should be, so add a convenience method to test that. Change-Id: I26d77cc8f109820cca3f578c3fa3520e802dc15f Reviewed-by: Sean Harmer --- src/gui/opengl/qopenglfunctions.cpp | 8 ++++++++ src/gui/opengl/qopenglfunctions.h | 3 ++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/gui/opengl/qopenglfunctions.cpp b/src/gui/opengl/qopenglfunctions.cpp index 5c7af6e474..60591a34d2 100644 --- a/src/gui/opengl/qopenglfunctions.cpp +++ b/src/gui/opengl/qopenglfunctions.cpp @@ -158,6 +158,7 @@ QT_BEGIN_NAMESPACE \value StencilSeparate Separate stencil functions are available. \value NPOTTextures Non power of two textures are available. \value NPOTTextureRepeat Non power of two textures can use GL_REPEAT as wrap parameter. + \value FixedFunctionPipeline The fixed function pipeline is available. */ // Hidden private fields for additional extension data. @@ -331,6 +332,13 @@ static int qt_gl_resolve_features() if (format.majorVersion() >= 3) features |= QOpenGLFunctions::Framebuffers; + const QPair version = format.version(); + if (version < qMakePair(3, 0) + || (version == qMakePair(3, 0) && format.testOption(QSurfaceFormat::DeprecatedFunctions)) + || (version == qMakePair(3, 1) && extensions.match("GL_ARB_compatibility")) + || (version >= qMakePair(3, 2) && format.profile() == QSurfaceFormat::CompatibilityProfile)) { + features |= QOpenGLFunctions::FixedFunctionPipeline; + } return features; #endif } diff --git a/src/gui/opengl/qopenglfunctions.h b/src/gui/opengl/qopenglfunctions.h index 1548ad4a24..9d8da209ad 100644 --- a/src/gui/opengl/qopenglfunctions.h +++ b/src/gui/opengl/qopenglfunctions.h @@ -199,7 +199,8 @@ public: Multisample = 0x0400, StencilSeparate = 0x0800, NPOTTextures = 0x1000, - NPOTTextureRepeat = 0x2000 + NPOTTextureRepeat = 0x2000, + FixedFunctionPipeline = 0x4000 }; Q_DECLARE_FLAGS(OpenGLFeatures, OpenGLFeature)