mirror of
https://github.com/glfw/glfw.git
synced 2024-11-26 03:52:01 +00:00
Cleanup
This commit is contained in:
parent
ec9fe02a30
commit
10c0eb648a
@ -166,7 +166,7 @@ static GLFWbool pollJoystickEvents(_GLFWjoystickLinux* js)
|
|||||||
return js->present;
|
return js->present;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Lexically compare the specified joysticks by device paths
|
// Lexically compare joysticks, used by quicksort
|
||||||
//
|
//
|
||||||
static int compareJoysticks(const void* fp, const void* sp)
|
static int compareJoysticks(const void* fp, const void* sp)
|
||||||
{
|
{
|
||||||
|
@ -34,28 +34,27 @@
|
|||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
|
||||||
|
|
||||||
// Lexical comparison function for GLFW video modes, used by qsort
|
// Lexically compare video modes, used by qsort
|
||||||
//
|
//
|
||||||
static int compareVideoModes(const void* firstPtr, const void* secondPtr)
|
static int compareVideoModes(const void* fp, const void* sp)
|
||||||
{
|
{
|
||||||
int firstBPP, secondBPP, firstSize, secondSize;
|
const GLFWvidmode* fm = fp;
|
||||||
const GLFWvidmode* first = firstPtr;
|
const GLFWvidmode* sm = fp;
|
||||||
const GLFWvidmode* second = secondPtr;
|
const int fbpp = fm->redBits + fm->greenBits + fm->blueBits;
|
||||||
|
const int sbpp = sm->redBits + sm->greenBits + sm->blueBits;
|
||||||
|
const int farea = fm->width * fm->height;
|
||||||
|
const int sarea = sm->width * sm->height;
|
||||||
|
|
||||||
// First sort on color bits per pixel
|
// First sort on color bits per pixel
|
||||||
firstBPP = first->redBits + first->greenBits + first->blueBits;
|
if (fbpp != sbpp)
|
||||||
secondBPP = second->redBits + second->greenBits + second->blueBits;
|
return fbpp - sbpp;
|
||||||
if (firstBPP != secondBPP)
|
|
||||||
return firstBPP - secondBPP;
|
|
||||||
|
|
||||||
// Then sort on screen area, in pixels
|
// Then sort on screen area
|
||||||
firstSize = first->width * first->height;
|
if (farea != sarea)
|
||||||
secondSize = second->width * second->height;
|
return farea - sarea;
|
||||||
if (firstSize != secondSize)
|
|
||||||
return firstSize - secondSize;
|
|
||||||
|
|
||||||
// Lastly sort on refresh rate
|
// Lastly sort on refresh rate
|
||||||
return first->refreshRate - second->refreshRate;
|
return fm->refreshRate - sm->refreshRate;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Retrieves the available modes for the specified monitor
|
// Retrieves the available modes for the specified monitor
|
||||||
@ -263,9 +262,9 @@ const GLFWvidmode* _glfwChooseVideoMode(_GLFWmonitor* monitor,
|
|||||||
return closest;
|
return closest;
|
||||||
}
|
}
|
||||||
|
|
||||||
int _glfwCompareVideoModes(const GLFWvidmode* first, const GLFWvidmode* second)
|
int _glfwCompareVideoModes(const GLFWvidmode* fm, const GLFWvidmode* sm)
|
||||||
{
|
{
|
||||||
return compareVideoModes(first, second);
|
return compareVideoModes(fm, sm);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwSplitBPP(int bpp, int* red, int* green, int* blue)
|
void _glfwSplitBPP(int bpp, int* red, int* green, int* blue)
|
||||||
|
Loading…
Reference in New Issue
Block a user