From c233e005a82e78e4e746c47f143847f77e20dd96 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Wed, 27 Jul 2011 18:20:15 +0200 Subject: [PATCH] Copied context property readback from 2.7.1. --- src/opengl.c | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/src/opengl.c b/src/opengl.c index 7b97d6e3..6d6f24fb 100644 --- a/src/opengl.c +++ b/src/opengl.c @@ -354,9 +354,36 @@ GLboolean _glfwIsValidContext(_GLFWwindow* window, _GLFWwndconfig* wndconfig) { parseGLVersion(&window->glMajor, &window->glMinor, &window->glRevision); - // As these are hard constraints when non-zero, we can simply copy them - window->glProfile = wndconfig->glProfile; - window->glForward = wndconfig->glForward; + // Read back forward-compatibility flag + { + window->glForward = GL_FALSE; + + if (window->glMajor >= 3) + { + GLint flags; + glGetIntegerv(GL_CONTEXT_FLAGS, &flags); + + if (flags & GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT) + window->glForward = GL_TRUE; + } + } + + // Read back OpenGL context profile + { + window->glProfile = 0; + + if (window->glMajor > 3 || (window->glMajor == 3 && window->glMinor >= 2)) + { + GLint mask; + glGetIntegerv(GL_CONTEXT_PROFILE_MASK, &mask); + + if (mask & GL_CONTEXT_COMPATIBILITY_PROFILE_BIT) + window->glProfile = GLFW_OPENGL_COMPAT_PROFILE; + else if (mask & GL_CONTEXT_CORE_PROFILE_BIT) + window->glProfile = GLFW_OPENGL_CORE_PROFILE; + } + } + window->glRobustness = wndconfig->glRobustness; if (window->glMajor < wndconfig->glMajor ||