42static int compareVideoModes(
const void* fp,
const void* sp)
81 qsort(modes, modeCount,
sizeof(
GLFWvidmode), compareVideoModes);
84 monitor->
modes = modes;
122 if (window->
monitor == monitor)
124 int width, height, xoff, yoff;
173 strncpy(monitor->
name, name,
sizeof(monitor->
name) - 1);
190 free(monitor->
modes);
198 ramp->
red = calloc(size,
sizeof(
unsigned short));
199 ramp->
green = calloc(size,
sizeof(
unsigned short));
200 ramp->
blue = calloc(size,
sizeof(
unsigned short));
221 unsigned int sizeDiff, leastSizeDiff = UINT_MAX;
222 unsigned int rateDiff, leastRateDiff = UINT_MAX;
223 unsigned int colorDiff, leastColorDiff = UINT_MAX;
227 if (!refreshVideoModes(monitor))
232 current = monitor->
modes + i;
243 sizeDiff = abs((current->
width - desired->
width) *
253 if ((colorDiff < leastColorDiff) ||
254 (colorDiff == leastColorDiff && sizeDiff < leastSizeDiff) ||
255 (colorDiff == leastColorDiff && sizeDiff == leastSizeDiff && rateDiff < leastRateDiff))
258 leastSizeDiff = sizeDiff;
259 leastRateDiff = rateDiff;
260 leastColorDiff = colorDiff;
271 return compareVideoModes(fm, sm);
286 *red = *green = *blue = bpp / 3;
287 delta = bpp - (*red * 3);
302 assert(count !=
NULL);
325 assert(monitor !=
NULL);
338 int* xpos,
int* ypos,
339 int* width,
int* height)
342 assert(monitor !=
NULL);
361 assert(monitor !=
NULL);
377 float* xscale,
float* yscale)
380 assert(monitor !=
NULL);
394 assert(monitor !=
NULL);
397 return monitor->
name;
403 assert(monitor !=
NULL);
412 assert(monitor !=
NULL);
428 assert(monitor !=
NULL);
429 assert(count !=
NULL);
435 if (!refreshVideoModes(monitor))
439 return monitor->
modes;
445 assert(monitor !=
NULL);
456 unsigned short* values;
459 assert(handle !=
NULL);
461 assert(gamma <= FLT_MAX);
465 if (gamma != gamma || gamma <= 0.f || gamma > FLT_MAX)
475 values = calloc(original->
size,
sizeof(
unsigned short));
477 for (i = 0; i < original->
size; i++)
482 value = i / (float) (original->
size - 1);
484 value = powf(value, 1.f / gamma) * 65535.f + 0.5f;
488 values[i] = (
unsigned short) value;
503 assert(monitor !=
NULL);
517 assert(monitor !=
NULL);
518 assert(ramp !=
NULL);
519 assert(ramp->
size > 0);
527 "Invalid gamma ramp size %i",
void _glfwPlatformFreeMonitor(_GLFWmonitor *monitor)
GLFWvidmode * _glfwPlatformGetVideoModes(_GLFWmonitor *monitor, int *count)
void _glfwPlatformGetVideoMode(_GLFWmonitor *monitor, GLFWvidmode *mode)
void _glfwPlatformSetGammaRamp(_GLFWmonitor *monitor, const GLFWgammaramp *ramp)
void _glfwPlatformGetMonitorPos(_GLFWmonitor *monitor, int *xpos, int *ypos)
GLFWbool _glfwPlatformGetGammaRamp(_GLFWmonitor *monitor, GLFWgammaramp *ramp)
void _glfwPlatformGetMonitorContentScale(_GLFWmonitor *monitor, float *xscale, float *yscale)
void _glfwPlatformGetMonitorWorkarea(_GLFWmonitor *monitor, int *xpos, int *ypos, int *width, int *height)
void _glfwPlatformSetWindowMonitor(_GLFWwindow *window, _GLFWmonitor *monitor, int xpos, int ypos, int width, int height, int refreshRate)
void _glfwPlatformGetWindowSize(_GLFWwindow *window, int *width, int *height)
void _glfwPlatformSetWindowPos(_GLFWwindow *window, int x, int y)
void _glfwPlatformGetWindowFrameSize(_GLFWwindow *window, int *left, int *top, int *right, int *bottom)
#define GLFW_DISCONNECTED
#define GLFW_INVALID_VALUE
One of the arguments to the function was an invalid value.
GLFWAPI void * glfwGetMonitorUserPointer(GLFWmonitor *handle)
Returns the user pointer of the specified monitor.
GLFWAPI const GLFWvidmode * glfwGetVideoMode(GLFWmonitor *handle)
Returns the current mode of the specified monitor.
GLFWAPI void glfwGetMonitorContentScale(GLFWmonitor *handle, float *xscale, float *yscale)
Retrieves the content scale for the specified monitor.
GLFWAPI GLFWmonitor * glfwGetPrimaryMonitor(void)
Returns the primary monitor.
GLFWAPI void glfwSetGamma(GLFWmonitor *handle, float gamma)
Generates a gamma ramp and sets it for the specified monitor.
GLFWAPI void glfwGetMonitorPos(GLFWmonitor *handle, int *xpos, int *ypos)
Returns the position of the monitor's viewport on the virtual screen.
GLFWAPI void glfwGetMonitorWorkarea(GLFWmonitor *handle, int *xpos, int *ypos, int *width, int *height)
Retrieves the work area of the monitor.
GLFWAPI const char * glfwGetMonitorName(GLFWmonitor *handle)
Returns the name of the specified monitor.
GLFWAPI void glfwSetMonitorUserPointer(GLFWmonitor *handle, void *pointer)
Sets the user pointer of the specified monitor.
GLFWAPI const GLFWvidmode * glfwGetVideoModes(GLFWmonitor *handle, int *count)
Returns the available video modes for the specified monitor.
GLFWAPI GLFWmonitor ** glfwGetMonitors(int *count)
Returns the currently connected monitors.
struct GLFWmonitor GLFWmonitor
Opaque monitor object.
GLFWAPI GLFWmonitorfun glfwSetMonitorCallback(GLFWmonitorfun cbfun)
Sets the monitor configuration callback.
GLFWAPI void glfwSetGammaRamp(GLFWmonitor *handle, const GLFWgammaramp *ramp)
Sets the current gamma ramp for the specified monitor.
void(* GLFWmonitorfun)(GLFWmonitor *, int)
The function pointer type for monitor configuration callbacks.
GLFWAPI void glfwGetMonitorPhysicalSize(GLFWmonitor *handle, int *widthMM, int *heightMM)
Returns the physical size of the monitor.
GLFWAPI const GLFWgammaramp * glfwGetGammaRamp(GLFWmonitor *handle)
Returns the current gamma ramp for the specified monitor.
void _glfwInputError(int code, const char *format,...)
float _glfw_fminf(float a, float b)
#define _GLFW_REQUIRE_INIT_OR_RETURN(x)
#define _GLFW_SWAP_POINTERS(x, y)
#define _GLFW_INSERT_FIRST
#define _GLFW_REQUIRE_INIT()
void _glfwInputMonitorWindow(_GLFWmonitor *monitor, _GLFWwindow *window)
void _glfwInputMonitor(_GLFWmonitor *monitor, int action, int placement)
void _glfwSplitBPP(int bpp, int *red, int *green, int *blue)
const GLFWvidmode * _glfwChooseVideoMode(_GLFWmonitor *monitor, const GLFWvidmode *desired)
void _glfwFreeMonitor(_GLFWmonitor *monitor)
void _glfwFreeGammaArrays(GLFWgammaramp *ramp)
int _glfwCompareVideoModes(const GLFWvidmode *fm, const GLFWvidmode *sm)
_GLFWmonitor * _glfwAllocMonitor(const char *name, int widthMM, int heightMM)
void _glfwAllocGammaArrays(GLFWgammaramp *ramp, unsigned int size)
struct _GLFWlibrary::@26 callbacks
_GLFWwindow * windowListHead
GLFWgammaramp originalRamp
GLFWgammaramp currentRamp
struct _GLFWwindow * next