GLFW 3.0.2 A multi-platform library for OpenGL, window and input

- Main Page
- Related Pages
- Modules
- Data Structures
- Files

All Data Structures Files Functions Variables Typedefs Macros Groups Pages
Data Structures | Typedefs | Functions
Monitor handling

## Data Structures
struct | GLFWvidmode
| Video mode type. More...
struct | GLFWgammaramp
| Gamma ramp. More...

## Typedefs
typedef struct GLFWmonitor | GLFWmonitor
typedef void(* | GLFWmonitorfun )(GLFWmonitor *, int)
| The function signature for monitor configuration callbacks. More...

## Functions
GLFWmonitor ** | glfwGetMonitors (int *count)
| Returns the currently connected monitors. More...
GLFWmonitor * | glfwGetPrimaryMonitor (void)
| Returns the primary monitor. More...
void | glfwGetMonitorPos (GLFWmonitor *monitor, int *xpos, int *ypos)
| Returns the position of the monitor's viewport on the virtual screen. More...
void | glfwGetMonitorPhysicalSize (GLFWmonitor *monitor, int *width, int *height)
| Returns the physical size of the monitor. More...
const char * | glfwGetMonitorName (GLFWmonitor *monitor)
| Returns the name of the specified monitor. More...
GLFWmonitorfun | glfwSetMonitorCallback (GLFWmonitorfun cbfun)
| Sets the monitor configuration callback. More...
const GLFWvidmode * | glfwGetVideoModes (GLFWmonitor *monitor, int *count)
| Returns the available video modes for the specified monitor. More...
const GLFWvidmode * | glfwGetVideoMode (GLFWmonitor *monitor)
| Returns the current mode of the specified monitor. More...
void | glfwSetGamma (GLFWmonitor *monitor, float gamma)
| Generates a gamma ramp and sets it for the specified monitor. More...
const GLFWgammaramp * | glfwGetGammaRamp (GLFWmonitor *monitor)
| Retrieves the current gamma ramp for the specified monitor. More...
void | glfwSetGammaRamp (GLFWmonitor *monitor, const GLFWgammaramp *ramp)
| Sets the current gamma ramp for the specified monitor. More...

## Detailed Description

This is the reference documentation for monitor related functions and types. For more information, see the Multi-monitor guide.

## Typedef Documentation

typedef struct GLFWmonitor GLFWmonitor

Opaque monitor object.

typedef void(* GLFWmonitorfun)(GLFWmonitor *, int)

This is the function signature for monitor configuration callback functions.

Parameters

  [in] | monitor | The monitor that was connected or disconnected.
  [in] | event | One of `GLFW_CONNECTED` or `GLFW_DISCONNECTED`.

See Also
  glfwSetMonitorCallback

## Function Documentation

const GLFWgammaramp* glfwGetGammaRamp | ( | GLFWmonitor * | monitor | ) |

This function retrieves the current gamma ramp of the specified monitor.

Parameters

  [in] | monitor | The monitor to query.

Returns
  The current gamma ramp, or `NULL` if an error occurred.

Note
  The value arrays of the returned ramp are allocated and freed by GLFW. You should not free them yourself.

const char* glfwGetMonitorName | ( | GLFWmonitor * | monitor | ) |

This function returns a human-readable name, encoded as UTF-8, of the specified monitor.

Parameters

  [in] | monitor | The monitor to query.

Returns
  The UTF-8 encoded name of the monitor, or `NULL` if an error occurred.

Note
  The returned string is allocated and freed by GLFW. You should not free it yourself.

void glfwGetMonitorPhysicalSize | ( | GLFWmonitor * | monitor,
|  | int * | width,
|  | int * | height
| ) |  |

This function returns the size, in millimetres, of the display area of the specified monitor.

Parameters

  [in] | monitor | The monitor to query.
  [out] | width | Where to store the width, in mm, of the monitor's display area, or `NULL`.
  [out] | height | Where to store the height, in mm, of the monitor's display area, or `NULL`.

Note
  Some operating systems do not provide accurate information, either because the monitor's EDID data is incorrect, or because the driver does not report it accurately.

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.

Parameters

  [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`.

GLFWmonitor** glfwGetMonitors | ( | int * | count | ) |

This function returns an array of handles for all currently connected monitors.

Parameters

  [out] | count | Where to store the size of the returned array. This is set to zero if an error occurred.

Returns
  An array of monitor handles, or `NULL` if an error occurred.

Note
  The returned array is allocated and freed by GLFW. You should not free it yourself.
  The returned array is valid only until the monitor configuration changes. See glfwSetMonitorCallback to receive notifications of configuration changes.

See Also
  glfwGetPrimaryMonitor

GLFWmonitor* glfwGetPrimaryMonitor | ( | void |  | ) |

This function returns the primary monitor. This is usually the monitor where elements like the Windows task bar or the OS X menu bar is located.

Returns
  The primary monitor, or `NULL` if an error occurred.

See Also
  glfwGetMonitors

const GLFWvidmode* glfwGetVideoMode | ( | GLFWmonitor * | monitor | ) |

This function returns the current video mode of the specified monitor. If you are using a full screen window, the return value will therefore depend on whether it is focused.

Parameters

  [in] | monitor | The monitor to query.

Returns
  The current mode of the monitor, or `NULL` if an error occurred.

Note
  The returned struct is allocated and freed by GLFW. You should not free it yourself.

See Also
  glfwGetVideoModes

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) and then by resolution area (the product of width and height).

Parameters

  [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.

Returns
  An array of video modes, or `NULL` if an error occurred.

Note
  The returned array is allocated and freed by GLFW. You should not free it yourself.
  The returned array is valid only until this function is called again for the specified monitor.

See Also
  glfwGetVideoMode

void glfwSetGamma | ( | GLFWmonitor * | monitor,
|  | float | gamma
| ) |  |

This function generates a 256-element gamma ramp from the specified exponent and then calls glfwSetGammaRamp with it.

Parameters

  [in] | monitor | The monitor whose gamma ramp to set.
  [in] | gamma | The desired exponent.

void glfwSetGammaRamp | ( | GLFWmonitor * | monitor,
|  | const GLFWgammaramp * | ramp
| ) |  |

This function sets the current gamma ramp for the specified monitor.

Parameters

  [in] | monitor | The monitor whose gamma ramp to set.
  [in] | ramp | The gamma ramp to use.

Note
  Gamma ramp sizes other than 256 are not supported by all hardware.

GLFWmonitorfun glfwSetMonitorCallback | ( | GLFWmonitorfun | cbfun | ) |

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.

Parameters

  [in] | cbfun | The new callback, or `NULL` to remove the currently set callback.

Returns
  The previously set callback, or `NULL` if no callback was set or an error occurred.

Bug:
  X11: This callback is not yet called on monitor configuration changes.