From d1617bdd789a0bb882652e9a0f7d748cdf85371f Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Wed, 1 Aug 2012 01:46:06 +0200 Subject: [PATCH 1/3] Made flag parsing output even more consistent. --- tests/glfwinfo.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/glfwinfo.c b/tests/glfwinfo.c index 13c9eec2..bbbedce0 100644 --- a/tests/glfwinfo.c +++ b/tests/glfwinfo.c @@ -257,7 +257,7 @@ int main(int argc, char** argv) printf(" debug"); putchar('\n'); - printf("OpenGL flags parsed by GLFW:"); + printf("OpenGL context flags parsed by GLFW:"); if (glfwGetWindowParam(window, GLFW_OPENGL_FORWARD_COMPAT)) printf(" forward-compatible"); @@ -271,7 +271,7 @@ int main(int argc, char** argv) glGetIntegerv(GL_CONTEXT_PROFILE_MASK, &mask); printf("OpenGL profile mask (0x%08x): %s\n", mask, get_profile_name(mask)); - printf("OpenGL profile parsed by GLFW: %s\n", + printf("OpenGL profile mask parsed by GLFW: %s\n", get_glfw_profile_name(glfwGetWindowParam(window, GLFW_OPENGL_PROFILE))); } From 3a72f33541466c0d0b00a4c33e70c981e87fa9fe Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Thu, 2 Aug 2012 01:13:05 +0200 Subject: [PATCH 2/3] Removed GLFW_ACCELERATED window parameter. --- include/GL/glfw3.h | 1 - readme.html | 1 + src/cocoa_window.m | 5 ----- src/internal.h | 1 - src/win32_opengl.c | 12 ------------ src/window.c | 2 -- src/x11_opengl.c | 4 ---- tests/defaults.c | 1 - 8 files changed, 1 insertion(+), 26 deletions(-) diff --git a/include/GL/glfw3.h b/include/GL/glfw3.h index 28e38bd1..693e55f3 100644 --- a/include/GL/glfw3.h +++ b/include/GL/glfw3.h @@ -390,7 +390,6 @@ extern "C" { /* glfwGetWindowParam tokens */ #define GLFW_ACTIVE 0x00020001 #define GLFW_ICONIFIED 0x00020002 -#define GLFW_ACCELERATED 0x00020003 #define GLFW_OPENGL_REVISION 0x00020004 /* The following constants are used for both glfwGetWindowParam diff --git a/readme.html b/readme.html index 10fa433b..e5fa8c9d 100644 --- a/readme.html +++ b/readme.html @@ -318,6 +318,7 @@ version of GLFW.

  • Removed GLFW_OPENED window parameter
  • Removed nonsensical key actions for Unicode character input
  • Removed GLFWCALL and GLFWAPIENTRY macros for stdcall calling convention
  • +
  • Removed GLFW_ACCELERATED window parameter
  • Bugfix: The default OpenGL version in the glfwinfo test was set to 1.1
  • Bugfix: The OpenGL profile and forward-compatibility window parameters were not saved after context creation
  • Bugfix: The FSAA test did not check for the availability of GL_ARB_multisample
  • diff --git a/src/cocoa_window.m b/src/cocoa_window.m index 9f20398a..e0b146b9 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -1047,11 +1047,6 @@ void _glfwPlatformRefreshWindowParams(void) // Since GLFW doesn't understand screens, we use virtual screen zero - [window->NSGL.pixelFormat getValues:&value - forAttribute:NSOpenGLPFAAccelerated - forVirtualScreen:0]; - window->accelerated = value; - [window->NSGL.pixelFormat getValues:&value forAttribute:NSOpenGLPFAAlphaSize forVirtualScreen:0]; diff --git a/src/internal.h b/src/internal.h index 700b6c06..f0bc6cb0 100644 --- a/src/internal.h +++ b/src/internal.h @@ -211,7 +211,6 @@ struct _GLFWwindow int samples; // OpenGL extensions and context attributes - GLboolean accelerated; // GL_TRUE if OpenGL context is "accelerated" int glMajor, glMinor, glRevision; GLboolean glForward, glDebug; int glProfile; diff --git a/src/win32_opengl.c b/src/win32_opengl.c index cc795e53..1bb26bfc 100644 --- a/src/win32_opengl.c +++ b/src/win32_opengl.c @@ -300,14 +300,6 @@ static void refreshContextParams(_GLFWwindow* window, int pixelFormat) if (window->WGL.ARB_pixel_format) { - if (getPixelFormatAttrib(window, pixelFormat, WGL_ACCELERATION_ARB) != - WGL_NO_ACCELERATION_ARB) - { - window->accelerated = GL_TRUE; - } - else - window->accelerated = GL_FALSE; - window->redBits = getPixelFormatAttrib(window, pixelFormat, WGL_RED_BITS_ARB); window->greenBits = @@ -353,10 +345,6 @@ static void refreshContextParams(_GLFWwindow* window, int pixelFormat) DescribePixelFormat(window->WGL.DC, pixelFormat, sizeof(PIXELFORMATDESCRIPTOR), &pfd); - // Is current OpenGL context accelerated? - window->accelerated = (pfd.dwFlags & PFD_GENERIC_ACCELERATED) || - !(pfd.dwFlags & PFD_GENERIC_FORMAT) ? 1 : 0; - // "Standard" window parameters window->redBits = pfd.cRedBits; window->greenBits = pfd.cGreenBits; diff --git a/src/window.c b/src/window.c index f8939e37..119ce7de 100644 --- a/src/window.c +++ b/src/window.c @@ -682,8 +682,6 @@ GLFWAPI int glfwGetWindowParam(GLFWwindow handle, int param) return window == _glfwLibrary.activeWindow; case GLFW_ICONIFIED: return window->iconified; - case GLFW_ACCELERATED: - return window->accelerated; case GLFW_RED_BITS: return window->redBits; case GLFW_GREEN_BITS: diff --git a/src/x11_opengl.c b/src/x11_opengl.c index edcd69b6..048b794f 100644 --- a/src/x11_opengl.c +++ b/src/x11_opengl.c @@ -233,10 +233,6 @@ static void refreshContextParams(_GLFWwindow* window, GLXFBConfigID fbconfigID) abort(); } - // There is no clear definition of an "accelerated" context on X11/GLX, and - // true sounds better than false, so we hardcode true here - window->accelerated = GL_TRUE; - window->redBits = getFBConfigAttrib(window, *fbconfig, GLX_RED_SIZE); window->greenBits = getFBConfigAttrib(window, *fbconfig, GLX_GREEN_SIZE); window->blueBits = getFBConfigAttrib(window, *fbconfig, GLX_BLUE_SIZE); diff --git a/tests/defaults.c b/tests/defaults.c index d7c5a02c..16c62723 100644 --- a/tests/defaults.c +++ b/tests/defaults.c @@ -42,7 +42,6 @@ typedef struct static Param parameters[] = { - { GLFW_ACCELERATED, "accelerated" }, { GLFW_RED_BITS, "red bits" }, { GLFW_GREEN_BITS, "green bits" }, { GLFW_BLUE_BITS, "blue bits" }, From 053737e6607bb529731aae4720011247c84a2f6c Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Thu, 2 Aug 2012 01:18:35 +0200 Subject: [PATCH 3/3] Use OpenGL to get default framebuffer properties. --- src/cocoa_window.m | 57 ---------------------------------- src/internal.h | 25 +++++++-------- src/opengl.c | 37 +++++++++++++++++++--- src/win32_opengl.c | 77 ---------------------------------------------- src/window.c | 1 + src/x11_opengl.c | 64 -------------------------------------- 6 files changed, 47 insertions(+), 214 deletions(-) diff --git a/src/cocoa_window.m b/src/cocoa_window.m index e0b146b9..6e4d4270 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -1042,63 +1042,6 @@ void _glfwPlatformRestoreWindow(_GLFWwindow* window) void _glfwPlatformRefreshWindowParams(void) { - GLint value; - _GLFWwindow* window = _glfwLibrary.currentWindow; - - // Since GLFW doesn't understand screens, we use virtual screen zero - - [window->NSGL.pixelFormat getValues:&value - forAttribute:NSOpenGLPFAAlphaSize - forVirtualScreen:0]; - window->alphaBits = value; - - [window->NSGL.pixelFormat getValues:&value - forAttribute:NSOpenGLPFAColorSize - forVirtualScreen:0]; - - // It seems that the color size includes the size of the alpha channel so - // we subtract it before splitting - _glfwSplitBPP(value - window->alphaBits, - &window->redBits, - &window->greenBits, - &window->blueBits); - - [window->NSGL.pixelFormat getValues:&value - forAttribute:NSOpenGLPFADepthSize - forVirtualScreen:0]; - window->depthBits = value; - - [window->NSGL.pixelFormat getValues:&value - forAttribute:NSOpenGLPFAStencilSize - forVirtualScreen:0]; - window->stencilBits = value; - - [window->NSGL.pixelFormat getValues:&value - forAttribute:NSOpenGLPFAAccumSize - forVirtualScreen:0]; - - _glfwSplitBPP(value, - &window->accumRedBits, - &window->accumGreenBits, - &window->accumBlueBits); - - // TODO: Figure out what to set this value to - window->accumAlphaBits = 0; - - [window->NSGL.pixelFormat getValues:&value - forAttribute:NSOpenGLPFAAuxBuffers - forVirtualScreen:0]; - window->auxBuffers = value; - - [window->NSGL.pixelFormat getValues:&value - forAttribute:NSOpenGLPFAStereo - forVirtualScreen:0]; - window->stereo = value; - - [window->NSGL.pixelFormat getValues:&value - forAttribute:NSOpenGLPFASamples - forVirtualScreen:0]; - window->samples = value; } diff --git a/src/internal.h b/src/internal.h index f0bc6cb0..620459e9 100644 --- a/src/internal.h +++ b/src/internal.h @@ -196,19 +196,19 @@ struct _GLFWwindow char key[GLFW_KEY_LAST + 1]; // Framebuffer attributes - int redBits; - int greenBits; - int blueBits; - int alphaBits; - int depthBits; - int stencilBits; - int accumRedBits; - int accumGreenBits; - int accumBlueBits; - int accumAlphaBits; - int auxBuffers; + GLint redBits; + GLint greenBits; + GLint blueBits; + GLint alphaBits; + GLint depthBits; + GLint stencilBits; + GLint accumRedBits; + GLint accumGreenBits; + GLint accumBlueBits; + GLint accumAlphaBits; + GLint auxBuffers; GLboolean stereo; - int samples; + GLint samples; // OpenGL extensions and context attributes int glMajor, glMinor, glRevision; @@ -363,6 +363,7 @@ int _glfwStringInExtensionString(const char* string, const GLubyte* extensions); const _GLFWfbconfig* _glfwChooseFBConfig(const _GLFWfbconfig* desired, const _GLFWfbconfig* alternatives, unsigned int count); +void _glfwRefreshContextParams(void); GLboolean _glfwIsValidContextConfig(_GLFWwndconfig* wndconfig); GLboolean _glfwIsValidContext(_GLFWwindow* window, _GLFWwndconfig* wndconfig); diff --git a/src/opengl.c b/src/opengl.c index 64e12e97..ed68c499 100644 --- a/src/opengl.c +++ b/src/opengl.c @@ -347,12 +347,13 @@ GLboolean _glfwIsValidContextConfig(_GLFWwndconfig* wndconfig) //======================================================================== -// Checks whether the specified context fulfils the requirements -// It blames glfwOpenWindow because that's the only caller +// Reads back context properties //======================================================================== -GLboolean _glfwIsValidContext(_GLFWwindow* window, _GLFWwndconfig* wndconfig) +void _glfwRefreshContextParams(void) { + _GLFWwindow* window = _glfwLibrary.currentWindow; + parseGLVersion(&window->glMajor, &window->glMinor, &window->glRevision); // Read back forward-compatibility flag @@ -387,8 +388,36 @@ GLboolean _glfwIsValidContext(_GLFWwindow* window, _GLFWwndconfig* wndconfig) } } - window->glRobustness = wndconfig->glRobustness; + glGetIntegerv(GL_RED_BITS, &window->redBits); + glGetIntegerv(GL_GREEN_BITS, &window->greenBits); + glGetIntegerv(GL_BLUE_BITS, &window->blueBits); + glGetIntegerv(GL_ALPHA_BITS, &window->alphaBits); + glGetIntegerv(GL_DEPTH_BITS, &window->depthBits); + glGetIntegerv(GL_STENCIL_BITS, &window->stencilBits); + + glGetIntegerv(GL_ACCUM_RED_BITS, &window->accumRedBits); + glGetIntegerv(GL_ACCUM_GREEN_BITS, &window->accumGreenBits); + glGetIntegerv(GL_ACCUM_BLUE_BITS, &window->accumBlueBits); + glGetIntegerv(GL_ACCUM_ALPHA_BITS, &window->accumAlphaBits); + + glGetIntegerv(GL_AUX_BUFFERS, &window->auxBuffers); + glGetBooleanv(GL_STEREO, &window->stereo); + + if (_glfwPlatformExtensionSupported("GL_ARB_multisample")) + glGetIntegerv(GL_SAMPLES_ARB, &window->samples); + else + window->samples = 0; +} + + +//======================================================================== +// Checks whether the specified context fulfils the requirements +// It blames glfwOpenWindow because that's the only caller +//======================================================================== + +GLboolean _glfwIsValidContext(_GLFWwindow* window, _GLFWwndconfig* wndconfig) +{ if (window->glMajor < wndconfig->glMajor || (window->glMajor == wndconfig->glMajor && window->glMinor < wndconfig->glMinor)) diff --git a/src/win32_opengl.c b/src/win32_opengl.c index 1bb26bfc..11a45346 100644 --- a/src/win32_opengl.c +++ b/src/win32_opengl.c @@ -290,82 +290,6 @@ static _GLFWfbconfig* getFBConfigs(_GLFWwindow* window, unsigned int* found) } -//======================================================================== -// Read back framebuffer parameters from the context -//======================================================================== - -static void refreshContextParams(_GLFWwindow* window, int pixelFormat) -{ - PIXELFORMATDESCRIPTOR pfd; - - if (window->WGL.ARB_pixel_format) - { - window->redBits = - getPixelFormatAttrib(window, pixelFormat, WGL_RED_BITS_ARB); - window->greenBits = - getPixelFormatAttrib(window, pixelFormat, WGL_GREEN_BITS_ARB); - window->blueBits = - getPixelFormatAttrib(window, pixelFormat, WGL_BLUE_BITS_ARB); - - window->alphaBits = - getPixelFormatAttrib(window, pixelFormat, WGL_ALPHA_BITS_ARB); - window->depthBits = - getPixelFormatAttrib(window, pixelFormat, WGL_DEPTH_BITS_ARB); - window->stencilBits = - getPixelFormatAttrib(window, pixelFormat, WGL_STENCIL_BITS_ARB); - - window->accumRedBits = - getPixelFormatAttrib(window, pixelFormat, WGL_ACCUM_RED_BITS_ARB); - window->accumGreenBits = - getPixelFormatAttrib(window, pixelFormat, WGL_ACCUM_GREEN_BITS_ARB); - window->accumBlueBits = - getPixelFormatAttrib(window, pixelFormat, WGL_ACCUM_BLUE_BITS_ARB); - window->accumAlphaBits = - getPixelFormatAttrib(window, pixelFormat, WGL_ACCUM_ALPHA_BITS_ARB); - - window->auxBuffers = - getPixelFormatAttrib(window, pixelFormat, WGL_AUX_BUFFERS_ARB); - window->stereo = - getPixelFormatAttrib(window, pixelFormat, WGL_STEREO_ARB) ? GL_TRUE : GL_FALSE; - - if (window->WGL.ARB_multisample) - { - window->samples = getPixelFormatAttrib(window, pixelFormat, WGL_SAMPLES_ARB); - - // We force 1 to zero here because all the other APIs say zero when - // they really mean 1 - if (window->samples == 1) - window->samples = 0; - } - else - window->samples = 0; - } - else - { - DescribePixelFormat(window->WGL.DC, pixelFormat, - sizeof(PIXELFORMATDESCRIPTOR), &pfd); - - // "Standard" window parameters - window->redBits = pfd.cRedBits; - window->greenBits = pfd.cGreenBits; - window->blueBits = pfd.cBlueBits; - window->alphaBits = pfd.cAlphaBits; - window->depthBits = pfd.cDepthBits; - window->stencilBits = pfd.cStencilBits; - window->accumRedBits = pfd.cAccumRedBits; - window->accumGreenBits = pfd.cAccumGreenBits; - window->accumBlueBits = pfd.cAccumBlueBits; - window->accumAlphaBits = pfd.cAccumAlphaBits; - window->auxBuffers = pfd.cAuxBuffers; - window->stereo = (pfd.dwFlags & PFD_STEREO) ? GL_TRUE : GL_FALSE; - - // If we don't have WGL_ARB_pixel_format then we can't have created a - // multisampling context, so it's safe to hardcode zero here - window->samples = 0; - } -} - - //======================================================================== // Creates an OpenGL context on the specified device context //======================================================================== @@ -516,7 +440,6 @@ static GLboolean createContext(_GLFWwindow* window, glfwMakeContextCurrent(window); initWGLExtensions(window); - refreshContextParams(window, pixelFormat); return GL_TRUE; } diff --git a/src/window.c b/src/window.c index 119ce7de..919434ec 100644 --- a/src/window.c +++ b/src/window.c @@ -320,6 +320,7 @@ GLFWAPI GLFWwindow glfwOpenWindow(int width, int height, // Cache the actual (as opposed to desired) window parameters glfwMakeContextCurrent(window); + _glfwRefreshContextParams(); _glfwPlatformRefreshWindowParams(); if (!_glfwIsValidContext(window, &wndconfig)) diff --git a/src/x11_opengl.c b/src/x11_opengl.c index 048b794f..017d660d 100644 --- a/src/x11_opengl.c +++ b/src/x11_opengl.c @@ -197,68 +197,6 @@ static int errorHandler(Display *display, XErrorEvent* event) } -//======================================================================== -// Read back framebuffer parameters from the context -//======================================================================== - -static void refreshContextParams(_GLFWwindow* window, GLXFBConfigID fbconfigID) -{ - int dummy; - GLXFBConfig* fbconfig; - - int attribs[] = { GLX_FBCONFIG_ID, fbconfigID, None }; - - if (_glfwLibrary.GLX.SGIX_fbconfig) - { - fbconfig = _glfwLibrary.GLX.ChooseFBConfigSGIX(_glfwLibrary.X11.display, - _glfwLibrary.X11.screen, - attribs, - &dummy); - } - else - { - fbconfig = glXChooseFBConfig(_glfwLibrary.X11.display, - _glfwLibrary.X11.screen, - attribs, - &dummy); - } - - if (fbconfig == NULL) - { - // This should never ever happen - // TODO: Flag this as an error and propagate up - _glfwSetError(GLFW_PLATFORM_ERROR, "X11/GLX: Cannot find known " - "GLXFBConfig by ID. This cannot " - "happen. Have a nice day.\n"); - abort(); - } - - window->redBits = getFBConfigAttrib(window, *fbconfig, GLX_RED_SIZE); - window->greenBits = getFBConfigAttrib(window, *fbconfig, GLX_GREEN_SIZE); - window->blueBits = getFBConfigAttrib(window, *fbconfig, GLX_BLUE_SIZE); - - window->alphaBits = getFBConfigAttrib(window, *fbconfig, GLX_ALPHA_SIZE); - window->depthBits = getFBConfigAttrib(window, *fbconfig, GLX_DEPTH_SIZE); - window->stencilBits = getFBConfigAttrib(window, *fbconfig, GLX_STENCIL_SIZE); - - window->accumRedBits = getFBConfigAttrib(window, *fbconfig, GLX_ACCUM_RED_SIZE); - window->accumGreenBits = getFBConfigAttrib(window, *fbconfig, GLX_ACCUM_GREEN_SIZE); - window->accumBlueBits = getFBConfigAttrib(window, *fbconfig, GLX_ACCUM_BLUE_SIZE); - window->accumAlphaBits = getFBConfigAttrib(window, *fbconfig, GLX_ACCUM_ALPHA_SIZE); - - window->auxBuffers = getFBConfigAttrib(window, *fbconfig, GLX_AUX_BUFFERS); - window->stereo = getFBConfigAttrib(window, *fbconfig, GLX_STEREO) ? GL_TRUE : GL_FALSE; - - // Get FSAA buffer sample count - if (_glfwLibrary.GLX.ARB_multisample) - window->samples = getFBConfigAttrib(window, *fbconfig, GLX_SAMPLES); - else - window->samples = 0; - - XFree(fbconfig); -} - - //======================================================================== // Create the actual OpenGL context //======================================================================== @@ -463,8 +401,6 @@ static int createContext(_GLFWwindow* window, return GL_FALSE; } - refreshContextParams(window, fbconfigID); - return GL_TRUE; }