Properly check which OpenGL features are supported
QOpenGLShaderProgram::hasOpenGLShaderPrograms tests whether QOpenGLFunctions::Shaders is provided for the given context. As the initialization code assumed OpenGL 2 this always was true. But unfortunately we still cannot assume that OpenGL 2 is universally supported. E.g. indirect rendering (no matter how bad that idea is) does not support OpenGL 2 on all hardware and the Shader related extensions are not available. This change makes sure that only when OpenGL 2 is available the features provided by OpenGL 2 are enabled. If OpenGL 2 is not available the extensions are tested. The checks are slightly reordered to not do the extension tests at all if OpenGL 2 is available. Task-number: QTBUG-39730 Change-Id: Ic775163e0dcc519925b1287f3c4ca5e8ebf101d5 Reviewed-by: Laszlo Agocs <laszlo.agocs@digia.com>
This commit is contained in:
parent
075c36e39b
commit
473ed1c1aa
@ -283,33 +283,16 @@ static int qt_gl_resolve_features()
|
|||||||
QSurfaceFormat format = QOpenGLContext::currentContext()->format();
|
QSurfaceFormat format = QOpenGLContext::currentContext()->format();
|
||||||
QOpenGLExtensionMatcher extensions;
|
QOpenGLExtensionMatcher extensions;
|
||||||
|
|
||||||
// Recognize features by extension name.
|
if (format.majorVersion() >= 3)
|
||||||
if (extensions.match("GL_ARB_multitexture"))
|
features |= QOpenGLFunctions::Framebuffers;
|
||||||
features |= QOpenGLFunctions::Multitexture;
|
else if (extensions.match("GL_EXT_framebuffer_object") ||
|
||||||
if (extensions.match("GL_ARB_shader_objects"))
|
|
||||||
features |= QOpenGLFunctions::Shaders;
|
|
||||||
if (extensions.match("GL_EXT_framebuffer_object") ||
|
|
||||||
extensions.match("GL_ARB_framebuffer_object"))
|
extensions.match("GL_ARB_framebuffer_object"))
|
||||||
features |= QOpenGLFunctions::Framebuffers;
|
features |= QOpenGLFunctions::Framebuffers;
|
||||||
if (extensions.match("GL_EXT_blend_color"))
|
|
||||||
features |= QOpenGLFunctions::BlendColor;
|
|
||||||
if (extensions.match("GL_EXT_blend_equation_separate"))
|
|
||||||
features |= QOpenGLFunctions::BlendEquationSeparate;
|
|
||||||
if (extensions.match("GL_EXT_blend_func_separate"))
|
|
||||||
features |= QOpenGLFunctions::BlendFuncSeparate;
|
|
||||||
if (extensions.match("GL_EXT_blend_subtract"))
|
|
||||||
features |= QOpenGLFunctions::BlendSubtract;
|
|
||||||
if (extensions.match("GL_ARB_texture_compression"))
|
|
||||||
features |= QOpenGLFunctions::CompressedTextures;
|
|
||||||
if (extensions.match("GL_ARB_multisample"))
|
|
||||||
features |= QOpenGLFunctions::Multisample;
|
|
||||||
if (extensions.match("GL_ARB_texture_non_power_of_two"))
|
|
||||||
features |= QOpenGLFunctions::NPOTTextures |
|
|
||||||
QOpenGLFunctions::NPOTTextureRepeat;
|
|
||||||
|
|
||||||
// assume version 2.0 or higher
|
if (format.majorVersion() >= 2) {
|
||||||
features |= QOpenGLFunctions::BlendColor |
|
features |= QOpenGLFunctions::BlendColor |
|
||||||
QOpenGLFunctions::BlendEquation |
|
QOpenGLFunctions::BlendEquation |
|
||||||
|
QOpenGLFunctions::BlendSubtract |
|
||||||
QOpenGLFunctions::Multitexture |
|
QOpenGLFunctions::Multitexture |
|
||||||
QOpenGLFunctions::CompressedTextures |
|
QOpenGLFunctions::CompressedTextures |
|
||||||
QOpenGLFunctions::Multisample |
|
QOpenGLFunctions::Multisample |
|
||||||
@ -320,9 +303,28 @@ static int qt_gl_resolve_features()
|
|||||||
QOpenGLFunctions::BlendEquationSeparate |
|
QOpenGLFunctions::BlendEquationSeparate |
|
||||||
QOpenGLFunctions::NPOTTextures |
|
QOpenGLFunctions::NPOTTextures |
|
||||||
QOpenGLFunctions::NPOTTextureRepeat;
|
QOpenGLFunctions::NPOTTextureRepeat;
|
||||||
|
} else {
|
||||||
if (format.majorVersion() >= 3)
|
// Recognize features by extension name.
|
||||||
features |= QOpenGLFunctions::Framebuffers;
|
if (extensions.match("GL_ARB_multitexture"))
|
||||||
|
features |= QOpenGLFunctions::Multitexture;
|
||||||
|
if (extensions.match("GL_ARB_shader_objects"))
|
||||||
|
features |= QOpenGLFunctions::Shaders;
|
||||||
|
if (extensions.match("GL_EXT_blend_color"))
|
||||||
|
features |= QOpenGLFunctions::BlendColor;
|
||||||
|
if (extensions.match("GL_EXT_blend_equation_separate"))
|
||||||
|
features |= QOpenGLFunctions::BlendEquationSeparate;
|
||||||
|
if (extensions.match("GL_EXT_blend_subtract"))
|
||||||
|
features |= QOpenGLFunctions::BlendSubtract;
|
||||||
|
if (extensions.match("GL_EXT_blend_func_separate"))
|
||||||
|
features |= QOpenGLFunctions::BlendFuncSeparate;
|
||||||
|
if (extensions.match("GL_ARB_texture_compression"))
|
||||||
|
features |= QOpenGLFunctions::CompressedTextures;
|
||||||
|
if (extensions.match("GL_ARB_multisample"))
|
||||||
|
features |= QOpenGLFunctions::Multisample;
|
||||||
|
if (extensions.match("GL_ARB_texture_non_power_of_two"))
|
||||||
|
features |= QOpenGLFunctions::NPOTTextures |
|
||||||
|
QOpenGLFunctions::NPOTTextureRepeat;
|
||||||
|
}
|
||||||
|
|
||||||
const QPair<int, int> version = format.version();
|
const QPair<int, int> version = format.version();
|
||||||
if (version < qMakePair(3, 0)
|
if (version < qMakePair(3, 0)
|
||||||
|
Loading…
Reference in New Issue
Block a user