mirror of
https://github.com/glfw/glfw.git
synced 2024-11-10 09:01:46 +00:00
Video mode setting cleanup.
This commit is contained in:
parent
b0ae7a6957
commit
f5ba0d9f22
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
@ -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)
|
||||
|
@ -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);
|
||||
|
||||
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user