Merge branch 'master' of ssh://glfw.git.sourceforge.net/gitroot/glfw/glfw

This commit is contained in:
Camilla Berglund 2011-01-02 00:10:49 +01:00
commit 15c4a2bd02
8 changed files with 53 additions and 6 deletions

View File

@ -329,11 +329,12 @@ extern "C" {
#define GLFW_STEREO 0x00020010 #define GLFW_STEREO 0x00020010
#define GLFW_WINDOW_NO_RESIZE 0x00020011 #define GLFW_WINDOW_NO_RESIZE 0x00020011
#define GLFW_FSAA_SAMPLES 0x00020012 #define GLFW_FSAA_SAMPLES 0x00020012
#define GLFW_OPENGL_VERSION_MAJOR 0x00020013 #define GLFW_SRGB_CAPABLE 0x00020013
#define GLFW_OPENGL_VERSION_MINOR 0x00020014 #define GLFW_OPENGL_VERSION_MAJOR 0x00020014
#define GLFW_OPENGL_FORWARD_COMPAT 0x00020015 #define GLFW_OPENGL_VERSION_MINOR 0x00020015
#define GLFW_OPENGL_DEBUG_CONTEXT 0x00020016 #define GLFW_OPENGL_FORWARD_COMPAT 0x00020016
#define GLFW_OPENGL_PROFILE 0x00020017 #define GLFW_OPENGL_DEBUG_CONTEXT 0x00020017
#define GLFW_OPENGL_PROFILE 0x00020018
/* GLFW_OPENGL_PROFILE bit tokens */ /* GLFW_OPENGL_PROFILE bit tokens */
#define GLFW_OPENGL_CORE_PROFILE 0x00000001 #define GLFW_OPENGL_CORE_PROFILE 0x00000001

View File

@ -273,6 +273,7 @@ version of GLFW.</p>
<li>Added <code>glfwSetWindowIconifyCallback</code> function and <code>GLFWwindowiconifyfun</code> type for receiving window iconification events</li> <li>Added <code>glfwSetWindowIconifyCallback</code> function and <code>GLFWwindowiconifyfun</code> type for receiving window iconification events</li>
<li>Added <code>glfwGetCurrentWindow</code> function for retrieving the window whose OpenGL context is current</li> <li>Added <code>glfwGetCurrentWindow</code> function for retrieving the window whose OpenGL context is current</li>
<li>Added <code>GLFW_OPENGL_ES2_PROFILE</code> profile for creating OpenGL ES 2.0 contexts using the <code>GLX_EXT_create_context_es2_profile</code> and <code>WGL_EXT_create_context_es2_profile</code> extensions</li> <li>Added <code>GLFW_OPENGL_ES2_PROFILE</code> profile for creating OpenGL ES 2.0 contexts using the <code>GLX_EXT_create_context_es2_profile</code> and <code>WGL_EXT_create_context_es2_profile</code> extensions</li>
<li>Added <code>GLFW_SRGB_CAPABLE</code> hint for creating sRGB-capable contexts using the <code>GL_ARB_framebuffer_sRGB</code> and <code>GL_EXT_framebuffer_sRGB</code> extensions</li>
<li>Added <code>windows</code> simple multi-window test program</li> <li>Added <code>windows</code> simple multi-window test program</li>
<li>Added <code>sharing</code> simple OpenGL object sharing test program</li> <li>Added <code>sharing</code> simple OpenGL object sharing test program</li>
<li>Added a parameter to <code>glfwOpenWindow</code> for specifying a context the new window's context will share objects with</li> <li>Added a parameter to <code>glfwOpenWindow</code> for specifying a context the new window's context will share objects with</li>

View File

@ -94,6 +94,7 @@ struct _GLFWhints
GLboolean stereo; GLboolean stereo;
GLboolean windowNoResize; GLboolean windowNoResize;
int samples; int samples;
GLboolean sRGB;
int glMajor; int glMajor;
int glMinor; int glMinor;
GLboolean glForward; GLboolean glForward;
@ -145,6 +146,7 @@ struct _GLFWfbconfig
int auxBuffers; int auxBuffers;
GLboolean stereo; GLboolean stereo;
int samples; int samples;
GLboolean sRGB;
GLFWintptr platformID; GLFWintptr platformID;
}; };
@ -190,6 +192,7 @@ struct _GLFWwindow
int auxBuffers; int auxBuffers;
GLboolean stereo; GLboolean stereo;
int samples; int samples;
GLboolean sRGB;
// OpenGL extensions and context attributes // OpenGL extensions and context attributes
GLboolean accelerated; // GL_TRUE if OpenGL context is "accelerated" GLboolean accelerated; // GL_TRUE if OpenGL context is "accelerated"

View File

@ -228,6 +228,8 @@ typedef struct _GLFWcontextWGL
PFNWGLCREATECONTEXTATTRIBSARBPROC CreateContextAttribsARB; PFNWGLCREATECONTEXTATTRIBSARBPROC CreateContextAttribsARB;
GLboolean has_WGL_EXT_swap_control; GLboolean has_WGL_EXT_swap_control;
GLboolean has_WGL_ARB_multisample; GLboolean has_WGL_ARB_multisample;
GLboolean has_WGL_EXT_framebuffer_sRGB;
GLboolean has_WGL_ARB_framebuffer_sRGB;
GLboolean has_WGL_ARB_pixel_format; GLboolean has_WGL_ARB_pixel_format;
GLboolean has_WGL_ARB_create_context; GLboolean has_WGL_ARB_create_context;
GLboolean has_WGL_ARB_create_context_profile; GLboolean has_WGL_ARB_create_context_profile;

View File

@ -251,6 +251,11 @@ static _GLFWfbconfig* getFBConfigs(_GLFWwindow* window, unsigned int* found)
} }
else else
result[*found].samples = 0; result[*found].samples = 0;
if (window->WGL.has_WGL_EXT_framebuffer_sRGB || window->WGL.has_WGL_ARB_framebuffer_sRGB)
result[*found].sRGB = getPixelFormatAttrib(window, i, WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB);
else
result[*found].sRGB = GL_FALSE;
} }
else else
{ {
@ -294,8 +299,9 @@ static _GLFWfbconfig* getFBConfigs(_GLFWwindow* window, unsigned int* found)
result[*found].auxBuffers = pfd.cAuxBuffers; result[*found].auxBuffers = pfd.cAuxBuffers;
result[*found].stereo = (pfd.dwFlags & PFD_STEREO) ? GL_TRUE : GL_FALSE; result[*found].stereo = (pfd.dwFlags & PFD_STEREO) ? GL_TRUE : GL_FALSE;
// PFD pixel formats do not support FSAA // PFD pixel formats do not support FSAA or sRGB
result[*found].samples = 0; result[*found].samples = 0;
result[*found].sRGB = GL_FALSE;
} }
result[*found].platformID = i; result[*found].platformID = i;
@ -1024,6 +1030,8 @@ static void initWGLExtensions(_GLFWwindow* window)
window->WGL.has_WGL_EXT_swap_control = GL_FALSE; window->WGL.has_WGL_EXT_swap_control = GL_FALSE;
window->WGL.has_WGL_ARB_pixel_format = GL_FALSE; window->WGL.has_WGL_ARB_pixel_format = GL_FALSE;
window->WGL.has_WGL_ARB_multisample = GL_FALSE; window->WGL.has_WGL_ARB_multisample = GL_FALSE;
window->WGL.has_WGL_EXT_framebuffer_sRGB = GL_FALSE;
window->WGL.has_WGL_ARB_framebuffer_sRGB = GL_FALSE;
window->WGL.has_WGL_ARB_create_context = GL_FALSE; window->WGL.has_WGL_ARB_create_context = GL_FALSE;
window->WGL.has_WGL_ARB_create_context_profile = GL_FALSE; window->WGL.has_WGL_ARB_create_context_profile = GL_FALSE;
@ -1040,6 +1048,12 @@ static void initWGLExtensions(_GLFWwindow* window)
if (_glfwPlatformExtensionSupported("WGL_ARB_multisample")) if (_glfwPlatformExtensionSupported("WGL_ARB_multisample"))
window->WGL.has_WGL_ARB_multisample = GL_TRUE; window->WGL.has_WGL_ARB_multisample = GL_TRUE;
if (_glfwPlatformExtensionSupported("WGL_EXT_framebuffer_sRGB"))
window->WGL.has_WGL_EXT_framebuffer_sRGB = GL_TRUE;
if (_glfwPlatformExtensionSupported("WGL_ARB_framebuffer_sRGB"))
window->WGL.has_WGL_ARB_framebuffer_sRGB = GL_TRUE;
if (_glfwPlatformExtensionSupported("WGL_ARB_create_context")) if (_glfwPlatformExtensionSupported("WGL_ARB_create_context"))
{ {
window->WGL.CreateContextAttribsARB = (PFNWGLCREATECONTEXTATTRIBSARBPROC) window->WGL.CreateContextAttribsARB = (PFNWGLCREATECONTEXTATTRIBSARBPROC)

View File

@ -288,6 +288,12 @@ const _GLFWfbconfig* _glfwChooseFBConfig(const _GLFWfbconfig* desired,
continue; continue;
} }
if (desired->sRGB && !current->sRGB)
{
// sRGB framebuffer is a hard constraint
continue;
}
// Count number of missing buffers // Count number of missing buffers
{ {
missing = 0; missing = 0;
@ -467,6 +473,7 @@ GLFWAPI GLFWwindow glfwOpenWindow(int width, int height,
fbconfig.auxBuffers = Max(_glfwLibrary.hints.auxBuffers, 0); fbconfig.auxBuffers = Max(_glfwLibrary.hints.auxBuffers, 0);
fbconfig.stereo = _glfwLibrary.hints.stereo ? GL_TRUE : GL_FALSE; fbconfig.stereo = _glfwLibrary.hints.stereo ? GL_TRUE : GL_FALSE;
fbconfig.samples = Max(_glfwLibrary.hints.samples, 0); fbconfig.samples = Max(_glfwLibrary.hints.samples, 0);
fbconfig.sRGB = _glfwLibrary.hints.sRGB ? GL_TRUE : GL_FALSE;
// Set up desired window config // Set up desired window config
wndconfig.mode = mode; wndconfig.mode = mode;
@ -751,6 +758,9 @@ GLFWAPI void glfwOpenWindowHint(int target, int hint)
case GLFW_FSAA_SAMPLES: case GLFW_FSAA_SAMPLES:
_glfwLibrary.hints.samples = hint; _glfwLibrary.hints.samples = hint;
break; break;
case GLFW_SRGB_CAPABLE:
_glfwLibrary.hints.sRGB = hint;
break;
case GLFW_OPENGL_VERSION_MAJOR: case GLFW_OPENGL_VERSION_MAJOR:
_glfwLibrary.hints.glMajor = hint; _glfwLibrary.hints.glMajor = hint;
break; break;
@ -1060,6 +1070,8 @@ GLFWAPI int glfwGetWindowParam(GLFWwindow window, int param)
return window->windowNoResize; return window->windowNoResize;
case GLFW_FSAA_SAMPLES: case GLFW_FSAA_SAMPLES:
return window->samples; return window->samples;
case GLFW_SRGB_CAPABLE:
return window->sRGB;
case GLFW_OPENGL_VERSION_MAJOR: case GLFW_OPENGL_VERSION_MAJOR:
return window->glMajor; return window->glMajor;
case GLFW_OPENGL_VERSION_MINOR: case GLFW_OPENGL_VERSION_MINOR:

View File

@ -100,6 +100,9 @@ typedef struct _GLFWcontextGLX
GLboolean has_GLX_SGI_swap_control; GLboolean has_GLX_SGI_swap_control;
GLboolean has_GLX_EXT_swap_control; GLboolean has_GLX_EXT_swap_control;
GLboolean has_GLX_ARB_multisample; GLboolean has_GLX_ARB_multisample;
GLboolean has_GLX_ARB_fbconfig_float;
GLboolean has_GLX_ARB_framebuffer_sRGB;
GLboolean has_GLX_EXT_framebuffer_sRGB;
GLboolean has_GLX_ARB_create_context; GLboolean has_GLX_ARB_create_context;
GLboolean has_GLX_ARB_create_context_profile; GLboolean has_GLX_ARB_create_context_profile;
GLboolean has_GLX_EXT_create_context_es2_profile; GLboolean has_GLX_EXT_create_context_es2_profile;

View File

@ -458,6 +458,11 @@ static _GLFWfbconfig* getFBConfigs(_GLFWwindow* window, unsigned int* found)
result[*found].auxBuffers = getFBConfigAttrib(window, fbconfigs[i], GLX_AUX_BUFFERS); result[*found].auxBuffers = getFBConfigAttrib(window, fbconfigs[i], GLX_AUX_BUFFERS);
result[*found].stereo = getFBConfigAttrib(window, fbconfigs[i], GLX_STEREO); result[*found].stereo = getFBConfigAttrib(window, fbconfigs[i], GLX_STEREO);
if (window->GLX.has_GLX_EXT_framebuffer_sRGB || window->GLX.has_GLX_ARB_framebuffer_sRGB)
result[*found].sRGB = getFBConfigAttrib(window, fbconfigs[i], GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB);
else
result[*found].sRGB = GL_FALSE;
if (window->GLX.has_GLX_ARB_multisample) if (window->GLX.has_GLX_ARB_multisample)
result[*found].samples = getFBConfigAttrib(window, fbconfigs[i], GLX_SAMPLES); result[*found].samples = getFBConfigAttrib(window, fbconfigs[i], GLX_SAMPLES);
else else
@ -702,6 +707,12 @@ static void initGLXExtensions(_GLFWwindow* window)
if (_glfwPlatformExtensionSupported("GLX_ARB_multisample")) if (_glfwPlatformExtensionSupported("GLX_ARB_multisample"))
window->GLX.has_GLX_ARB_multisample = GL_TRUE; window->GLX.has_GLX_ARB_multisample = GL_TRUE;
if (_glfwPlatformExtensionSupported("GLX_EXT_framebuffer_sRGB"))
window->GLX.has_GLX_EXT_framebuffer_sRGB = GL_TRUE;
if (_glfwPlatformExtensionSupported("GLX_ARB_framebuffer_sRGB"))
window->GLX.has_GLX_ARB_framebuffer_sRGB = GL_TRUE;
if (_glfwPlatformExtensionSupported("GLX_ARB_create_context")) if (_glfwPlatformExtensionSupported("GLX_ARB_create_context"))
{ {
window->GLX.CreateContextAttribsARB = (PFNGLXCREATECONTEXTATTRIBSARBPROC) window->GLX.CreateContextAttribsARB = (PFNGLXCREATECONTEXTATTRIBSARBPROC)