This is the reference documentation for monitor related functions and types. For more task-oriented information, see the Monitor guide.
Typedefs | |
typedef struct GLFWmonitor | GLFWmonitor |
Opaque monitor object. | |
typedef void(* | GLFWmonitorfun) (GLFWmonitor *monitor, int event) |
The function pointer type for monitor configuration callbacks. | |
typedef struct GLFWvidmode | GLFWvidmode |
Video mode type. | |
typedef struct GLFWgammaramp | GLFWgammaramp |
Gamma ramp. | |
Functions | |
GLFWmonitor ** | glfwGetMonitors (int *count) |
Returns the currently connected monitors. | |
GLFWmonitor * | glfwGetPrimaryMonitor (void) |
Returns the primary monitor. | |
void | glfwGetMonitorPos (GLFWmonitor *monitor, int *xpos, int *ypos) |
Returns the position of the monitor's viewport on the virtual screen. | |
void | glfwGetMonitorWorkarea (GLFWmonitor *monitor, int *xpos, int *ypos, int *width, int *height) |
Retrieves the work area of the monitor. | |
void | glfwGetMonitorPhysicalSize (GLFWmonitor *monitor, int *widthMM, int *heightMM) |
Returns the physical size of the monitor. | |
void | glfwGetMonitorContentScale (GLFWmonitor *monitor, float *xscale, float *yscale) |
Retrieves the content scale for the specified monitor. | |
const char * | glfwGetMonitorName (GLFWmonitor *monitor) |
Returns the name of the specified monitor. | |
void | glfwSetMonitorUserPointer (GLFWmonitor *monitor, void *pointer) |
Sets the user pointer of the specified monitor. | |
void * | glfwGetMonitorUserPointer (GLFWmonitor *monitor) |
Returns the user pointer of the specified monitor. | |
GLFWmonitorfun | glfwSetMonitorCallback (GLFWmonitorfun callback) |
Sets the monitor configuration callback. | |
const GLFWvidmode * | glfwGetVideoModes (GLFWmonitor *monitor, int *count) |
Returns the available video modes for the specified monitor. | |
const GLFWvidmode * | glfwGetVideoMode (GLFWmonitor *monitor) |
Returns the current mode of the specified monitor. | |
void | glfwSetGamma (GLFWmonitor *monitor, float gamma) |
Generates a gamma ramp and sets it for the specified monitor. | |
const GLFWgammaramp * | glfwGetGammaRamp (GLFWmonitor *monitor) |
Returns the current gamma ramp for the specified monitor. | |
void | glfwSetGammaRamp (GLFWmonitor *monitor, const GLFWgammaramp *ramp) |
Sets the current gamma ramp for the specified monitor. | |
typedef struct GLFWmonitor GLFWmonitor |
typedef void(* GLFWmonitorfun) (GLFWmonitor *monitor, int event) |
This is the function pointer type for monitor configuration callbacks. A monitor callback function has the following signature:
[in] | monitor | The monitor that was connected or disconnected. |
[in] | event | One of GLFW_CONNECTED or GLFW_DISCONNECTED . Future releases may add more events. |
typedef struct GLFWvidmode GLFWvidmode |
This describes a single video mode.
typedef struct GLFWgammaramp GLFWgammaramp |
This describes the gamma ramp for a monitor.
GLFWmonitor ** glfwGetMonitors | ( | int * | count | ) |
This function returns an array of handles for all currently connected monitors. The primary monitor is always first in the returned array. If no monitors were found, this function returns NULL
.
[out] | count | Where to store the number of monitors in the returned array. This is set to zero if an error occurred. |
NULL
if no monitors were found or if an error occurred.GLFWmonitor * glfwGetPrimaryMonitor | ( | void | ) |
This function returns the primary monitor. This is usually the monitor where elements like the task bar or global menu bar are located.
NULL
if no monitors were found or if an error occurred.void glfwGetMonitorPos | ( | GLFWmonitor * | monitor, |
int * | xpos, | ||
int * | ypos | ||
) |
This function returns the position, in screen coordinates, of the upper-left corner of the specified monitor.
Any or all of the position arguments may be NULL
. If an error occurs, all non-NULL
position arguments will be set to zero.
[in] | monitor | The monitor to query. |
[out] | xpos | Where to store the monitor x-coordinate, or NULL . |
[out] | ypos | Where to store the monitor y-coordinate, or NULL . |
void glfwGetMonitorWorkarea | ( | GLFWmonitor * | monitor, |
int * | xpos, | ||
int * | ypos, | ||
int * | width, | ||
int * | height | ||
) |
This function returns the position, in screen coordinates, of the upper-left corner of the work area of the specified monitor along with the work area size in screen coordinates. The work area is defined as the area of the monitor not occluded by the operating system task bar where present. If no task bar exists then the work area is the monitor resolution in screen coordinates.
Any or all of the position and size arguments may be NULL
. If an error occurs, all non-NULL
position and size arguments will be set to zero.
[in] | monitor | The monitor to query. |
[out] | xpos | Where to store the monitor x-coordinate, or NULL . |
[out] | ypos | Where to store the monitor y-coordinate, or NULL . |
[out] | width | Where to store the monitor width, or NULL . |
[out] | height | Where to store the monitor height, or NULL . |
void glfwGetMonitorPhysicalSize | ( | GLFWmonitor * | monitor, |
int * | widthMM, | ||
int * | heightMM | ||
) |
This function returns the size, in millimetres, of the display area of the specified monitor.
Some systems do not provide accurate monitor size information, either because the monitor EDID data is incorrect or because the driver does not report it accurately.
Any or all of the size arguments may be NULL
. If an error occurs, all non-NULL
size arguments will be set to zero.
[in] | monitor | The monitor to query. |
[out] | widthMM | Where to store the width, in millimetres, of the monitor's display area, or NULL . |
[out] | heightMM | Where to store the height, in millimetres, of the monitor's display area, or NULL . |
void glfwGetMonitorContentScale | ( | GLFWmonitor * | monitor, |
float * | xscale, | ||
float * | yscale | ||
) |
This function retrieves the content scale for the specified monitor. The content scale is the ratio between the current DPI and the platform's default DPI. This is especially important for text and any UI elements. If the pixel dimensions of your UI scaled by this look appropriate on your machine then it should appear at a reasonable size on other machines regardless of their DPI and scaling settings. This relies on the system DPI and scaling settings being somewhat correct.
The content scale may depend on both the monitor resolution and pixel density and on user settings. It may be very different from the raw DPI calculated from the physical size and current resolution.
[in] | monitor | The monitor to query. |
[out] | xscale | Where to store the x-axis content scale, or NULL . |
[out] | yscale | Where to store the y-axis content scale, or NULL . |
const char * glfwGetMonitorName | ( | GLFWmonitor * | monitor | ) |
This function returns a human-readable name, encoded as UTF-8, of the specified monitor. The name typically reflects the make and model of the monitor and is not guaranteed to be unique among the connected monitors.
[in] | monitor | The monitor to query. |
NULL
if an error occurred.void glfwSetMonitorUserPointer | ( | GLFWmonitor * | monitor, |
void * | pointer | ||
) |
This function sets the user-defined pointer of the specified monitor. The current value is retained until the monitor is disconnected. The initial value is NULL
.
This function may be called from the monitor callback, even for a monitor that is being disconnected.
[in] | monitor | The monitor whose pointer to set. |
[in] | pointer | The new value. |
void * glfwGetMonitorUserPointer | ( | GLFWmonitor * | monitor | ) |
This function returns the current value of the user-defined pointer of the specified monitor. The initial value is NULL
.
This function may be called from the monitor callback, even for a monitor that is being disconnected.
[in] | monitor | The monitor whose pointer to return. |
GLFWmonitorfun glfwSetMonitorCallback | ( | GLFWmonitorfun | callback | ) |
This function sets the monitor configuration callback, or removes the currently set callback. This is called when a monitor is connected to or disconnected from the system.
[in] | callback | The new callback, or NULL to remove the currently set callback. |
NULL
if no callback was set or the library had not been initialized.const GLFWvidmode * glfwGetVideoModes | ( | GLFWmonitor * | monitor, |
int * | count | ||
) |
This function returns an array of all video modes supported by the specified monitor. The returned array is sorted in ascending order, first by color bit depth (the sum of all channel depths), then by resolution area (the product of width and height), then resolution width and finally by refresh rate.
[in] | monitor | The monitor to query. |
[out] | count | Where to store the number of video modes in the returned array. This is set to zero if an error occurred. |
NULL
if an error occurred.const GLFWvidmode * glfwGetVideoMode | ( | GLFWmonitor * | monitor | ) |
This function returns the current video mode of the specified monitor. If you have created a full screen window for that monitor, the return value will depend on whether that window is iconified.
[in] | monitor | The monitor to query. |
NULL
if an error occurred.glfwGetDesktopMode
. void glfwSetGamma | ( | GLFWmonitor * | monitor, |
float | gamma | ||
) |
This function generates an appropriately sized gamma ramp from the specified exponent and then calls glfwSetGammaRamp with it. The value must be a finite number greater than zero.
The software controlled gamma ramp is applied in addition to the hardware gamma correction, which today is usually an approximation of sRGB gamma. This means that setting a perfectly linear ramp, or gamma 1.0, will produce the default (usually sRGB-like) behavior.
For gamma correct rendering with OpenGL or OpenGL ES, see the GLFW_SRGB_CAPABLE hint.
[in] | monitor | The monitor whose gamma ramp to set. |
[in] | gamma | The desired exponent. |
const GLFWgammaramp * glfwGetGammaRamp | ( | GLFWmonitor * | monitor | ) |
This function returns the current gamma ramp of the specified monitor.
[in] | monitor | The monitor to query. |
NULL
if an error occurred.NULL
.void glfwSetGammaRamp | ( | GLFWmonitor * | monitor, |
const GLFWgammaramp * | ramp | ||
) |
This function sets the current gamma ramp for the specified monitor. The original gamma ramp for that monitor is saved by GLFW the first time this function is called and is restored by glfwTerminate.
The software controlled gamma ramp is applied in addition to the hardware gamma correction, which today is usually an approximation of sRGB gamma. This means that setting a perfectly linear ramp, or gamma 1.0, will produce the default (usually sRGB-like) behavior.
For gamma correct rendering with OpenGL or OpenGL ES, see the GLFW_SRGB_CAPABLE hint.
[in] | monitor | The monitor whose gamma ramp to set. |
[in] | ramp | The gamma ramp to use. |
Last update on Wed Feb 21 2024 for GLFW 3.3.10