mirror of
https://github.com/glfw/glfw.git
synced 2024-11-25 22:14:34 +00:00
Added explicit support for sRGB framebuffers.
This commit is contained in:
parent
a3ff29af36
commit
69a900592e
@ -518,6 +518,10 @@ extern "C" {
|
||||
/*! @brief The number of samples used for default framebuffer multisampling.
|
||||
*/
|
||||
#define GLFW_FSAA_SAMPLES 0x0002100E
|
||||
/*! @brief @c GL_TRUE if the framebuffer should be sRGB capable, or @c GL_FALSE
|
||||
* otherwise.
|
||||
*/
|
||||
#define GLFW_SRGB_CAPABLE 0x0002100F
|
||||
|
||||
/*! @brief The @link clients client API @endlink to create a context for.
|
||||
*/
|
||||
@ -1020,6 +1024,9 @@ GLFWAPI void glfwDefaultWindowHints(void);
|
||||
* The @ref GLFW_FSAA_SAMPLES hint specifies the desired number of samples to
|
||||
* use for multisampling.
|
||||
*
|
||||
* The @ref GLFW_SRGB_CAPABLE hint specifies whether the framebuffer should be
|
||||
* sRGB capable.
|
||||
*
|
||||
* The @ref GLFW_CLIENT_API hint specifies which client API to create the
|
||||
* context for. Possible values are @ref GLFW_OPENGL_API and @ref
|
||||
* GLFW_OPENGL_ES_API.
|
||||
|
@ -835,6 +835,9 @@ static GLboolean createContext(_GLFWwindow* window,
|
||||
ADD_ATTR2(NSOpenGLPFASamples, fbconfig->samples);
|
||||
}
|
||||
|
||||
// NOTE: All NSOpenGLPixelFormats on the relevant cards support sRGB
|
||||
// frambuffer, so there's no need (and no way) to request it
|
||||
|
||||
ADD_ATTR(0);
|
||||
|
||||
#undef ADD_ATTR
|
||||
|
@ -100,6 +100,7 @@ struct _GLFWhints
|
||||
GLboolean resizable;
|
||||
GLboolean visible;
|
||||
int samples;
|
||||
GLboolean sRGB;
|
||||
int clientAPI;
|
||||
int glMajor;
|
||||
int glMinor;
|
||||
@ -160,6 +161,7 @@ struct _GLFWfbconfig
|
||||
int auxBuffers;
|
||||
GLboolean stereo;
|
||||
int samples;
|
||||
GLboolean sRGB;
|
||||
GLFWintptr platformID;
|
||||
};
|
||||
|
||||
|
@ -217,6 +217,12 @@ const _GLFWfbconfig* _glfwChooseFBConfig(const _GLFWfbconfig* desired,
|
||||
extraDiff += (desired->samples - current->samples) *
|
||||
(desired->samples - current->samples);
|
||||
}
|
||||
|
||||
if (desired->sRGB)
|
||||
{
|
||||
if (!current->sRGB)
|
||||
extraDiff++;
|
||||
}
|
||||
}
|
||||
|
||||
// Figure out if the current one is better than the best one found so far
|
||||
|
@ -72,6 +72,7 @@ static void initWGLExtensions(_GLFWwindow* window)
|
||||
// This needs to include every extension used below except for
|
||||
// WGL_ARB_extensions_string and WGL_EXT_extensions_string
|
||||
window->WGL.ARB_multisample = GL_FALSE;
|
||||
window->WGL.ARB_framebuffer_sRGB = GL_FALSE;
|
||||
window->WGL.ARB_create_context = GL_FALSE;
|
||||
window->WGL.ARB_create_context_profile = GL_FALSE;
|
||||
window->WGL.EXT_create_context_es2_profile = GL_FALSE;
|
||||
@ -92,6 +93,9 @@ static void initWGLExtensions(_GLFWwindow* window)
|
||||
if (_glfwPlatformExtensionSupported("WGL_ARB_multisample"))
|
||||
window->WGL.ARB_multisample = GL_TRUE;
|
||||
|
||||
if (_glfwPlatformExtensionSupported("WGL_ARB_framebuffer_sRGB"))
|
||||
window->WGL.ARB_framebuffer_sRGB = GL_TRUE;
|
||||
|
||||
if (_glfwPlatformExtensionSupported("WGL_ARB_create_context"))
|
||||
{
|
||||
window->WGL.CreateContextAttribsARB = (PFNWGLCREATECONTEXTATTRIBSARBPROC)
|
||||
@ -246,6 +250,11 @@ static _GLFWfbconfig* getFBConfigs(_GLFWwindow* window, unsigned int* found)
|
||||
f->samples = getPixelFormatAttrib(window, i, WGL_SAMPLES_ARB);
|
||||
else
|
||||
f->samples = 0;
|
||||
|
||||
if (window->WGL.ARB_framebuffer_sRGB)
|
||||
f->sRGB = getPixelFormatAttrib(window, i, WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB);
|
||||
else
|
||||
f->sRGB = GL_FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -293,6 +302,9 @@ static _GLFWfbconfig* getFBConfigs(_GLFWwindow* window, unsigned int* found)
|
||||
|
||||
// PFD pixel formats do not support FSAA
|
||||
f->samples = 0;
|
||||
|
||||
// PFD pixel formats do not support sRGB
|
||||
f->sRGB = GL_FALSE;
|
||||
}
|
||||
|
||||
f->platformID = i;
|
||||
|
@ -144,6 +144,7 @@ typedef struct _GLFWcontextWGL
|
||||
GLboolean EXT_swap_control;
|
||||
GLboolean ARB_multisample;
|
||||
GLboolean ARB_pixel_format;
|
||||
GLboolean ARB_framebuffer_sRGB;
|
||||
GLboolean ARB_create_context;
|
||||
GLboolean ARB_create_context_profile;
|
||||
GLboolean EXT_create_context_es2_profile;
|
||||
|
@ -237,6 +237,7 @@ GLFWAPI GLFWwindow glfwCreateWindow(int width, int height,
|
||||
fbconfig.auxBuffers = Max(_glfwLibrary.hints.auxBuffers, 0);
|
||||
fbconfig.stereo = _glfwLibrary.hints.stereo ? GL_TRUE : GL_FALSE;
|
||||
fbconfig.samples = Max(_glfwLibrary.hints.samples, 0);
|
||||
fbconfig.sRGB = _glfwLibrary.hints.sRGB ? GL_TRUE : GL_FALSE;
|
||||
|
||||
// Set up desired window config
|
||||
wndconfig.mode = mode;
|
||||
@ -446,6 +447,9 @@ GLFWAPI void glfwWindowHint(int target, int hint)
|
||||
case GLFW_FSAA_SAMPLES:
|
||||
_glfwLibrary.hints.samples = hint;
|
||||
break;
|
||||
case GLFW_SRGB_CAPABLE:
|
||||
_glfwLibrary.hints.sRGB = hint;
|
||||
break;
|
||||
case GLFW_CLIENT_API:
|
||||
_glfwLibrary.hints.clientAPI = hint;
|
||||
break;
|
||||
|
@ -190,6 +190,11 @@ static _GLFWfbconfig* getFBConfigs(_GLFWwindow* window, unsigned int* found)
|
||||
else
|
||||
f->samples = 0;
|
||||
|
||||
if (_glfwLibrary.GLX.ARB_framebuffer_sRGB)
|
||||
f->sRGB = getFBConfigAttrib(window, fbconfigs[i], GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB);
|
||||
else
|
||||
f->sRGB = GL_FALSE;
|
||||
|
||||
f->platformID = (GLFWintptr) getFBConfigAttrib(window, fbconfigs[i], GLX_FBCONFIG_ID);
|
||||
|
||||
(*found)++;
|
||||
@ -527,6 +532,9 @@ int _glfwInitOpenGL(void)
|
||||
if (_glfwPlatformExtensionSupported("GLX_ARB_multisample"))
|
||||
_glfwLibrary.GLX.ARB_multisample = GL_TRUE;
|
||||
|
||||
if (_glfwPlatformExtensionSupported("GLX_ARB_framebuffer_sRGB"))
|
||||
_glfwLibrary.GLX.ARB_framebuffer_sRGB = GL_TRUE;
|
||||
|
||||
if (_glfwPlatformExtensionSupported("GLX_ARB_create_context"))
|
||||
{
|
||||
_glfwLibrary.GLX.CreateContextAttribsARB = (PFNGLXCREATECONTEXTATTRIBSARBPROC)
|
||||
|
@ -272,6 +272,7 @@ typedef struct _GLFWlibraryGLX
|
||||
GLboolean EXT_swap_control;
|
||||
GLboolean MESA_swap_control;
|
||||
GLboolean ARB_multisample;
|
||||
GLboolean ARB_framebuffer_sRGB;
|
||||
GLboolean ARB_create_context;
|
||||
GLboolean ARB_create_context_profile;
|
||||
GLboolean ARB_create_context_robustness;
|
||||
|
Loading…
Reference in New Issue
Block a user