diff --git a/src/cocoa_monitor.m b/src/cocoa_monitor.m index a8fa832b..d828dc58 100644 --- a/src/cocoa_monitor.m +++ b/src/cocoa_monitor.m @@ -152,12 +152,13 @@ static void endFadeReservation(CGDisplayFadeReservationToken token) // Change the current video mode // -GLboolean _glfwSetVideoMode(_GLFWmonitor* monitor, int* width, int* height, int* bpp) +GLboolean _glfwSetVideoMode(_GLFWmonitor* monitor, const GLFWvidmode* desired) { CGDisplayModeRef bestMode = NULL; CFArrayRef modes; CFIndex count, i; unsigned int leastSizeDiff = UINT_MAX; + const int bpp = desired->redBits - desired->greenBits - desired->blueBits; modes = CGDisplayCopyAllDisplayModes(monitor->ns.displayID, NULL); count = CFArrayGetCount(modes); @@ -185,14 +186,13 @@ GLboolean _glfwSetVideoMode(_GLFWmonitor* monitor, int* width, int* height, int* int modeWidth = (int) CGDisplayModeGetWidth(mode); int modeHeight = (int) CGDisplayModeGetHeight(mode); - unsigned int sizeDiff = (abs(modeBPP - *bpp) << 25) | - ((modeWidth - *width) * (modeWidth - *width) + - (modeHeight - *height) * (modeHeight - *height)); + unsigned int sizeDiff = (abs(modeBPP - bpp) << 25) | + ((modeWidth - desired->width) * (modeWidth - desired->width) + + (modeHeight - desired->height) * (modeHeight - desired->height)); if (sizeDiff < leastSizeDiff) { bestMode = mode; - leastSizeDiff = sizeDiff; } } diff --git a/src/cocoa_platform.h b/src/cocoa_platform.h index c1dde4d3..da28c7f5 100644 --- a/src/cocoa_platform.h +++ b/src/cocoa_platform.h @@ -138,7 +138,7 @@ void _glfwInitJoysticks(void); void _glfwTerminateJoysticks(void); // Fullscreen -GLboolean _glfwSetVideoMode(_GLFWmonitor* monitor, int* width, int* height, int* bpp); +GLboolean _glfwSetVideoMode(_GLFWmonitor* monitor, const GLFWvidmode* desired); void _glfwRestoreVideoMode(_GLFWmonitor* monitor); // OpenGL support diff --git a/src/cocoa_window.m b/src/cocoa_window.m index 407c77ab..23aff3d8 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -767,13 +767,6 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window, return GL_FALSE; } - // Mac OS X needs non-zero color size, so set resonable values - int colorBits = fbconfig->redBits + fbconfig->greenBits + fbconfig->blueBits; - if (colorBits == 0) - colorBits = 24; - else if (colorBits < 15) - colorBits = 15; - // Don't use accumulation buffer support; it's not accelerated // Aux buffers probably aren't accelerated either @@ -787,9 +780,7 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window, if (wndconfig->monitor) { - int bpp = colorBits + fbconfig->alphaBits; - - if (!_glfwSetVideoMode(window->monitor, &window->videoMode.width, &window->videoMode.height, &bpp)) + if (!_glfwSetVideoMode(window->monitor, &window->videoMode)) return GL_FALSE; _glfwPlatformShowWindow(window); diff --git a/src/win32_monitor.c b/src/win32_monitor.c index dbdd09d1..ecc4cddb 100644 --- a/src/win32_monitor.c +++ b/src/win32_monitor.c @@ -50,13 +50,13 @@ // Change the current video mode // -int _glfwSetVideoMode(_GLFWmonitor* monitor, const GLFWvidmode* mode) +GLboolean _glfwSetVideoMode(_GLFWmonitor* monitor, const GLFWvidmode* desired) { GLFWvidmode current; const GLFWvidmode* best; DEVMODE dm; - best = _glfwChooseVideoMode(monitor, mode); + best = _glfwChooseVideoMode(monitor, desired); _glfwPlatformGetVideoMode(monitor, ¤t); if (_glfwCompareVideoModes(¤t, best) == 0) diff --git a/src/win32_platform.h b/src/win32_platform.h index e1e5ef8c..e951c4aa 100644 --- a/src/win32_platform.h +++ b/src/win32_platform.h @@ -247,7 +247,7 @@ int _glfwAnalyzeContext(const _GLFWwindow* window, const _GLFWfbconfig* fbconfig); // Fullscreen support -int _glfwSetVideoMode(_GLFWmonitor* monitor, const GLFWvidmode* mode); +GLboolean _glfwSetVideoMode(_GLFWmonitor* monitor, const GLFWvidmode* desired); void _glfwRestoreVideoMode(_GLFWmonitor* monitor); diff --git a/src/x11_monitor.c b/src/x11_monitor.c index 2578d2dc..da0e7ad3 100644 --- a/src/x11_monitor.c +++ b/src/x11_monitor.c @@ -41,7 +41,7 @@ // Set the current video mode for the specified monitor // -void _glfwSetVideoMode(_GLFWmonitor* monitor, const GLFWvidmode* mode) +void _glfwSetVideoMode(_GLFWmonitor* monitor, const GLFWvidmode* desired) { if (_glfw.x11.randr.available) { @@ -82,10 +82,10 @@ void _glfwSetVideoMode(_GLFWmonitor* monitor, const GLFWvidmode* mode) if (mi->modeFlags & RR_Interlace) continue; - unsigned int sizeDiff = (mi->width - mode->width) * - (mi->width - mode->width) + - (mi->height - mode->height) * - (mi->height - mode->height); + unsigned int sizeDiff = (mi->width - desired->width) * + (mi->width - desired->width) + + (mi->height - desired->height) * + (mi->height - desired->height); if (sizeDiff < leastSizeDiff) { diff --git a/src/x11_platform.h b/src/x11_platform.h index 36d887b4..0eb8c28c 100644 --- a/src/x11_platform.h +++ b/src/x11_platform.h @@ -229,7 +229,7 @@ int _glfwCreateContext(_GLFWwindow* window, void _glfwDestroyContext(_GLFWwindow* window); // Fullscreen support -void _glfwSetVideoMode(_GLFWmonitor* monitor, const GLFWvidmode* mode); +void _glfwSetVideoMode(_GLFWmonitor* monitor, const GLFWvidmode* desired); void _glfwRestoreVideoMode(_GLFWmonitor* monitor); // Joystick input