From a98c66c8cb31061d2ec8781eac2bea25cb2fe02d Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Thu, 22 Sep 2011 14:15:07 +0200 Subject: [PATCH 1/4] Added glext header explanation. --- src/internal.h | 4 ++++ src/win32_platform.h | 3 +++ src/x11_platform.h | 3 +++ 3 files changed, 10 insertions(+) diff --git a/src/internal.h b/src/internal.h index 83559ecc..2d38912c 100644 --- a/src/internal.h +++ b/src/internal.h @@ -59,6 +59,10 @@ #include "config.h" #include "../include/GL/glfw3.h" + +// This path may need to be changed if you build GLFW using your own setup +// We ship and use our own copy of glext.h since GLFW uses fairly new +// extensions and not all operating systems come with an up-to-date version #include "../support/GL/glext.h" #if defined(_GLFW_COCOA_NSGL) diff --git a/src/win32_platform.h b/src/win32_platform.h index db5b82ae..a2b94ebc 100644 --- a/src/win32_platform.h +++ b/src/win32_platform.h @@ -43,6 +43,9 @@ #include #include +// This path may need to be changed if you build GLFW using your own setup +// We ship and use our own copy of wglext.h since GLFW uses fairly new +// extensions and not all operating systems come with an up-to-date version #include "../support/GL/wglext.h" diff --git a/src/x11_platform.h b/src/x11_platform.h index 70a57b84..46f09f1a 100644 --- a/src/x11_platform.h +++ b/src/x11_platform.h @@ -41,6 +41,9 @@ #define GLX_GLXEXT_LEGACY #include +// This path may need to be changed if you build GLFW using your own setup +// We ship and use our own copy of glxext.h since GLFW uses fairly new +// extensions and not all operating systems come with an up-to-date version #include "../support/GL/glxext.h" From 5ac752d79d4897946c1d5546189250ec99390bcb Mon Sep 17 00:00:00 2001 From: Tai Chi Minh Ralph Eastwood Date: Sun, 25 Sep 2011 15:00:08 +0100 Subject: [PATCH 2/4] Set the current gamma ramp to original gamma ramp at start. --- src/cocoa_init.m | 1 + src/win32_init.c | 1 + src/x11_init.c | 1 + 3 files changed, 3 insertions(+) diff --git a/src/cocoa_init.m b/src/cocoa_init.m index dd85f3f8..c7c0d6c5 100644 --- a/src/cocoa_init.m +++ b/src/cocoa_init.m @@ -228,6 +228,7 @@ int _glfwPlatformInit(void) // Save the original gamma ramp _glfwLibrary.originalRampSize = CGDisplayGammaTableCapacity(CGMainDisplayID()); _glfwPlatformGetGammaRamp(&_glfwLibrary.originalRamp); + _glfwLibrary.currentRamp = _glfwLibrary.originalRamp; return GL_TRUE; } diff --git a/src/win32_init.c b/src/win32_init.c index 51b3f093..a69cccd7 100644 --- a/src/win32_init.c +++ b/src/win32_init.c @@ -163,6 +163,7 @@ int _glfwPlatformInit(void) // Save the original gamma ramp _glfwLibrary.originalRampSize = 256; _glfwPlatformGetGammaRamp(&_glfwLibrary.originalRamp); + _glfwLibrary.currentRamp = _glfwLibrary.originalRamp; _glfwInitTimer(); diff --git a/src/x11_init.c b/src/x11_init.c index 2b8e3e35..cceaa174 100644 --- a/src/x11_init.c +++ b/src/x11_init.c @@ -502,6 +502,7 @@ static void initGammaRamp(void) // Save the original gamma ramp _glfwPlatformGetGammaRamp(&_glfwLibrary.originalRamp); + _glfwLibrary.currentRamp = _glfwLibrary.originalRamp; } From 5999a40aaa929a5a75ed4a0590980718d2b3bc45 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Mon, 26 Sep 2011 15:38:11 +0200 Subject: [PATCH 3/4] Improved legibility. --- src/x11_fullscreen.c | 66 ++++++++++++++++---------------------------- 1 file changed, 24 insertions(+), 42 deletions(-) diff --git a/src/x11_fullscreen.c b/src/x11_fullscreen.c index c154fe3d..7eead3a3 100644 --- a/src/x11_fullscreen.c +++ b/src/x11_fullscreen.c @@ -45,21 +45,16 @@ int _glfwGetClosestVideoMode(int screen, int* width, int* height, int* rate) { int i, match, bestmatch; -#if defined(_GLFW_HAS_XRANDR) - int sizecount, bestsize; - int ratecount, bestrate; - short* ratelist; - XRRScreenConfiguration* sc; - XRRScreenSize* sizelist; -#endif /*_GLFW_HAS_XRANDR*/ -#if defined(_GLFW_HAS_XF86VIDMODE) - XF86VidModeModeInfo** modelist; - int bestmode, modecount; -#endif /*_GLFW_HAS_XF86VIDMODE*/ if (_glfwLibrary.X11.RandR.available) { #if defined(_GLFW_HAS_XRANDR) + int sizecount, bestsize; + int ratecount, bestrate; + short* ratelist; + XRRScreenConfiguration* sc; + XRRScreenSize* sizelist; + sc = XRRGetScreenInfo(_glfwLibrary.X11.display, RootWindow(_glfwLibrary.X11.display, screen)); @@ -108,7 +103,6 @@ int _glfwGetClosestVideoMode(int screen, int* width, int* height, int* rate) } } - // Free modelist XRRFreeScreenConfigInfo(sc); if (bestsize != -1) @@ -118,6 +112,9 @@ int _glfwGetClosestVideoMode(int screen, int* width, int* height, int* rate) else if (_glfwLibrary.X11.VidMode.available) { #if defined(_GLFW_HAS_XF86VIDMODE) + XF86VidModeModeInfo** modelist; + int bestmode, modecount; + // Get a list of all available display modes XF86VidModeGetAllModeLines(_glfwLibrary.X11.display, screen, &modecount, &modelist); @@ -145,7 +142,6 @@ int _glfwGetClosestVideoMode(int screen, int* width, int* height, int* rate) *height = modelist[bestmode]->vdisplay; } - // Free modelist XFree(modelist); if (bestmode != -1) @@ -167,18 +163,12 @@ int _glfwGetClosestVideoMode(int screen, int* width, int* height, int* rate) void _glfwSetVideoModeMODE(int screen, int mode, int rate) { -#if defined(_GLFW_HAS_XRANDR) - XRRScreenConfiguration* sc; - Window root; -#endif /*_GLFW_HAS_XRANDR*/ -#if defined(_GLFW_HAS_XF86VIDMODE) - XF86VidModeModeInfo **modelist; - int modecount; -#endif /*_GLFW_HAS_XF86VIDMODE*/ - if (_glfwLibrary.X11.RandR.available) { #if defined(_GLFW_HAS_XRANDR) + XRRScreenConfiguration* sc; + Window root; + root = RootWindow(_glfwLibrary.X11.display, screen); sc = XRRGetScreenInfo(_glfwLibrary.X11.display, root); @@ -220,6 +210,9 @@ void _glfwSetVideoModeMODE(int screen, int mode, int rate) else if (_glfwLibrary.X11.VidMode.available) { #if defined(_GLFW_HAS_XF86VIDMODE) + XF86VidModeModeInfo **modelist; + int modecount; + // Get a list of all available display modes XF86VidModeGetAllModeLines(_glfwLibrary.X11.display, screen, &modecount, &modelist); @@ -229,8 +222,7 @@ void _glfwSetVideoModeMODE(int screen, int mode, int rate) XF86VidModeLockModeSwitch(_glfwLibrary.X11.display, screen, 0); // Change the video mode to the desired mode - XF86VidModeSwitchToMode(_glfwLibrary.X11.display, screen, - modelist[mode]); + XF86VidModeSwitchToMode(_glfwLibrary.X11.display, screen, modelist[mode]); // Set viewport to upper left corner (where our window will be) XF86VidModeSetViewPort(_glfwLibrary.X11.display, screen, 0, 0); @@ -245,7 +237,6 @@ void _glfwSetVideoModeMODE(int screen, int mode, int rate) _glfwLibrary.X11.FS.modeChanged = GL_TRUE; } - // Free mode list XFree(modelist); #endif /*_GLFW_HAS_XF86VIDMODE*/ } @@ -338,15 +329,6 @@ int _glfwPlatformGetVideoModes(GLFWvidmode* list, int maxcount) int viscount, rgbcount, rescount; int* rgbarray; struct _glfwResolution* resarray; -#if defined(_GLFW_HAS_XRANDR) - XRRScreenConfiguration* sc; - XRRScreenSize* sizelist; - int sizecount; -#endif /*_GLFW_HAS_XRANDR*/ -#if defined(_GLFW_HAS_XF86VIDMODE) - XF86VidModeModeInfo** modelist; - int modecount, width, height; -#endif /*_GLFW_HAS_XF86VIDMODE*/ // Get list of visuals vislist = XGetVisualInfo(_glfwLibrary.X11.display, 0, &dummy, &viscount); @@ -397,6 +379,10 @@ int _glfwPlatformGetVideoModes(GLFWvidmode* list, int maxcount) if (_glfwLibrary.X11.RandR.available) { #if defined(_GLFW_HAS_XRANDR) + XRRScreenConfiguration* sc; + XRRScreenSize* sizelist; + int sizecount; + sc = XRRGetScreenInfo(_glfwLibrary.X11.display, _glfwLibrary.X11.root); sizelist = XRRConfigSizes(sc, &sizecount); @@ -415,6 +401,9 @@ int _glfwPlatformGetVideoModes(GLFWvidmode* list, int maxcount) else if (_glfwLibrary.X11.VidMode.available) { #if defined(_GLFW_HAS_XF86VIDMODE) + XF86VidModeModeInfo** modelist; + int modecount, width, height; + XF86VidModeGetAllModeLines(_glfwLibrary.X11.display, screen, &modecount, &modelist); resarray = (struct _glfwResolution*) _glfwMalloc(sizeof(struct _glfwResolution) * modecount); @@ -467,7 +456,6 @@ int _glfwPlatformGetVideoModes(GLFWvidmode* list, int maxcount) } } - // Free visuals list XFree(vislist); _glfwFree(resarray); @@ -484,15 +472,9 @@ int _glfwPlatformGetVideoModes(GLFWvidmode* list, int maxcount) void _glfwPlatformGetDesktopMode(GLFWvidmode* mode) { int bpp; -#if defined(_GLFW_HAS_XF86VIDMODE) - XF86VidModeModeInfo** modelist; - int modecount; -#endif /*_GLFW_HAS_XF86VIDMODE*/ - // Get display depth + // Get and split display depth bpp = DefaultDepth(_glfwLibrary.X11.display, _glfwLibrary.X11.screen); - - // Convert BPP to RGB bits _glfwSplitBPP(bpp, &mode->redBits, &mode->greenBits, &mode->blueBits); if (_glfwLibrary.X11.FS.modeChanged) From 0544afeb06fbfcfc87a3c344742b79c7d9d28403 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Mon, 26 Sep 2011 15:40:18 +0200 Subject: [PATCH 4/4] It is a platform error. --- src/x11_fullscreen.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/x11_fullscreen.c b/src/x11_fullscreen.c index 7eead3a3..bb0a3d53 100644 --- a/src/x11_fullscreen.c +++ b/src/x11_fullscreen.c @@ -334,7 +334,8 @@ int _glfwPlatformGetVideoModes(GLFWvidmode* list, int maxcount) vislist = XGetVisualInfo(_glfwLibrary.X11.display, 0, &dummy, &viscount); if (vislist == NULL) { - // TODO: Figure out which error this is + _glfwSetError(GLFW_PLATFORM_ERROR, + "X11/GLX: Failed to retrieve the available visuals"); return 0; }