Video mode setting cleanup.

This commit is contained in:
Camilla Berglund
2013-04-21 21:28:07 +02:00
parent b0ae7a6957
commit f5ba0d9f22
7 changed files with 16 additions and 25 deletions
+5 -5
View File
@@ -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;
}
}