From 04c057238b422785b487d32b5d4865511b20f2f7 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Tue, 14 Jul 2015 15:44:13 +0200 Subject: [PATCH] Added support for EXT_framebuffer_sRGB. Added sRGB extensions to standards conformance page. --- docs/compat.dox | 10 ++++++++++ docs/window.dox | 2 ++ src/glx_context.c | 5 ++++- src/glx_context.h | 1 + src/wgl_context.c | 11 +++++++++-- src/wgl_context.h | 1 + 6 files changed, 27 insertions(+), 3 deletions(-) diff --git a/docs/compat.dox b/docs/compat.dox index 7ff4ab04..0837323d 100644 --- a/docs/compat.dox +++ b/docs/compat.dox @@ -117,6 +117,11 @@ whether a context is flushed when it is released (made non-current). Where this extension is unavailable, the `GLFW_CONTEXT_RELEASE_BEHAVIOR` hint will have no effect and the context will always be flushed when released. +GLFW uses the `GLX_ARB_framebuffer_sRGB` and `GLX_EXT_framebuffer_sRGB` +extensions to provide support for sRGB framebuffers. Where both of these +extensions are unavailable, the `GLFW_SRGB_CAPABLE` hint will have no effect. + + @section compat_wgl WGL extensions The WGL API is used to create OpenGL contexts on Microsoft Windows and other @@ -154,6 +159,11 @@ whether a context is flushed when it is released (made non-current). Where this extension is unavailable, the `GLFW_CONTEXT_RELEASE_BEHAVIOR` hint will have no effect and the context will always be flushed when released. +GLFW uses the `WGL_ARB_framebuffer_sRGB` and `WGL_EXT_framebuffer_sRGB` +extensions to provide support for sRGB framebuffers. Where both of these +extension are unavailable, the `GLFW_SRGB_CAPABLE` hint will have no effect. + + @section compat_osx OpenGL 3.2 and later on OS X Support for OpenGL 3.2 and above was introduced with OS X 10.7 and even then diff --git a/docs/window.dox b/docs/window.dox index f395c6fa..1f67e010 100644 --- a/docs/window.dox +++ b/docs/window.dox @@ -206,6 +206,8 @@ Zero disables multisampling. `GLFW_DONT_CARE` means the application has no preference. `GLFW_SRGB_CAPABLE` specifies whether the framebuffer should be sRGB capable. +If supported, the created context will provide `GL_ARB_framebuffer_sRGB` or +`GL_EXT_framebuffer_sRGB`. `GLFW_DOUBLEBUFFER` specifies whether the framebuffer should be double buffered. You nearly always want to use double buffering. This is a hard constraint. diff --git a/src/glx_context.c b/src/glx_context.c index 1101912f..b2c8e7e3 100644 --- a/src/glx_context.c +++ b/src/glx_context.c @@ -117,7 +117,7 @@ static GLboolean chooseFBConfig(const _GLFWfbconfig* desired, GLXFBConfig* resul if (_glfw.glx.ARB_multisample) u->samples = getFBConfigAttrib(n, GLX_SAMPLES); - if (_glfw.glx.ARB_framebuffer_sRGB) + if (_glfw.glx.ARB_framebuffer_sRGB || _glfw.glx.EXT_framebuffer_sRGB) u->sRGB = getFBConfigAttrib(n, GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB); u->glx = n; @@ -226,6 +226,9 @@ int _glfwInitContextAPI(void) if (_glfwPlatformExtensionSupported("GLX_ARB_framebuffer_sRGB")) _glfw.glx.ARB_framebuffer_sRGB = GL_TRUE; + if (_glfwPlatformExtensionSupported("GLX_EXT_framebuffer_sRGB")) + _glfw.glx.EXT_framebuffer_sRGB = GL_TRUE; + if (_glfwPlatformExtensionSupported("GLX_ARB_create_context")) { _glfw.glx.CreateContextAttribsARB = (PFNGLXCREATECONTEXTATTRIBSARBPROC) diff --git a/src/glx_context.h b/src/glx_context.h index 13d6144f..c5a4e61e 100644 --- a/src/glx_context.h +++ b/src/glx_context.h @@ -81,6 +81,7 @@ typedef struct _GLFWlibraryGLX GLboolean MESA_swap_control; GLboolean ARB_multisample; GLboolean ARB_framebuffer_sRGB; + GLboolean EXT_framebuffer_sRGB; GLboolean ARB_create_context; GLboolean ARB_create_context_profile; GLboolean ARB_create_context_robustness; diff --git a/src/wgl_context.c b/src/wgl_context.c index 96ebcfb1..7514ac6d 100644 --- a/src/wgl_context.c +++ b/src/wgl_context.c @@ -61,6 +61,8 @@ static void initWGLExtensions(_GLFWwindow* window) _glfwPlatformExtensionSupported("WGL_ARB_multisample"); window->wgl.ARB_framebuffer_sRGB = _glfwPlatformExtensionSupported("WGL_ARB_framebuffer_sRGB"); + window->wgl.EXT_framebuffer_sRGB = + _glfwPlatformExtensionSupported("WGL_EXT_framebuffer_sRGB"); window->wgl.ARB_create_context = _glfwPlatformExtensionSupported("WGL_ARB_create_context"); window->wgl.ARB_create_context_profile = @@ -175,7 +177,8 @@ static GLboolean choosePixelFormat(_GLFWwindow* window, if (window->wgl.ARB_multisample) u->samples = getPixelFormatAttrib(window, n, WGL_SAMPLES_ARB); - if (window->wgl.ARB_framebuffer_sRGB) + if (window->wgl.ARB_framebuffer_sRGB || + window->wgl.EXT_framebuffer_sRGB) { if (getPixelFormatAttrib(window, n, WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB)) u->sRGB = GL_TRUE; @@ -543,8 +546,12 @@ int _glfwAnalyzeContext(const _GLFWwindow* window, if (fbconfig->sRGB) { // sRGB is not a hard constraint, so do nothing if it's not supported - if (window->wgl.ARB_framebuffer_sRGB && window->wgl.ARB_pixel_format) + if ((window->wgl.ARB_framebuffer_sRGB || + window->wgl.EXT_framebuffer_sRGB) && + window->wgl.ARB_pixel_format) + { required = GL_TRUE; + } } if (required) diff --git a/src/wgl_context.h b/src/wgl_context.h index 93536fdf..f7d41874 100644 --- a/src/wgl_context.h +++ b/src/wgl_context.h @@ -55,6 +55,7 @@ typedef struct _GLFWcontextWGL GLboolean EXT_swap_control; GLboolean ARB_multisample; GLboolean ARB_framebuffer_sRGB; + GLboolean EXT_framebuffer_sRGB; GLboolean ARB_pixel_format; GLboolean ARB_create_context; GLboolean ARB_create_context_profile;