1
0
Fork 0
mirror of https://github.com/gwm17/glfw.git synced 2024-11-27 04:28:52 -05:00
glfw/docs/monitor.dox

157 lines
4.4 KiB
Plaintext
Raw Normal View History

2013-05-27 11:10:34 -04:00
/*!
@page monitor Multi-monitor guide
2013-05-27 15:58:33 -04:00
@tableofcontents
2013-05-27 11:10:34 -04:00
@section monitor_objects Monitor objects
2014-04-23 07:30:11 -04:00
A monitor object represents a currently connected monitor and is represented as
a pointer to the [opaque](https://en.wikipedia.org/wiki/Opaque_data_type) type
@ref GLFWmonitor. Monitor objects cannot be created or destroyed by the
application and retain their addresses until the monitors they represent are
disconnected or until the library is [terminated](@ref intro_init_terminate).
2013-05-27 15:58:33 -04:00
2014-04-23 07:30:11 -04:00
Each monitor has a human-readable name, a current video mode, a list of
supported video modes, a virtual position, an estimated physical size and
a gamma ramp.
2013-07-07 06:06:59 -04:00
2014-04-23 07:30:11 -04:00
The virtual position of a monitor is in screen coordinates and, together with
the current video mode, describes the viewports that the connected monitors
provide into the virtual desktop that spans them.
2013-07-07 06:06:59 -04:00
2014-04-23 07:30:11 -04:00
@subsection monitor_monitors Retrieving monitors
The primary monitor is returned by @ref glfwGetPrimaryMonitor. It is the user's
preferred monitor and is usually the one with global UI elements like task bar
2013-05-27 15:58:33 -04:00
or menu bar.
@code
GLFWmonitor* primary = glfwGetPrimaryMonitor();
@endcode
You can retrieve all currently connected monitors with @ref glfwGetMonitors.
2014-04-23 07:30:11 -04:00
The primary monitor is always the first monitor in the returned array.
2013-05-27 15:58:33 -04:00
@code
int count;
GLFWmonitor** monitors = glfwGetMonitors(&count);
@endcode
2014-04-23 07:30:11 -04:00
@note Monitors other than the primary monitor may be moved to a different index
in the array if another monitor is disconnected.
@section monitor_properties Monitor properties
2013-05-27 11:10:34 -04:00
2014-04-23 07:30:11 -04:00
@subsection monitor_modes Video modes
2013-05-27 11:10:34 -04:00
Although GLFW generally does a good job at selecting a suitable video
2013-05-27 15:58:33 -04:00
mode for you when you open a full screen window, it is sometimes useful to
2013-05-27 11:10:34 -04:00
know exactly which modes are available on a certain system. For example,
you may want to present the user with a list of video modes to select
from. To get a list of available video modes, you can use the function
@ref glfwGetVideoModes.
@code
int count;
GLFWvidmode* modes = glfwGetVideoModes(monitor, &count);
@endcode
To get the current video mode of a monitor call @ref glfwGetVideoMode.
@code
const GLFWvidmode* mode = glfwGetVideoMode(monitor);
@endcode
2014-04-23 07:30:11 -04:00
@subsection monitor_size Physical size
2013-05-27 15:58:33 -04:00
2014-04-23 07:30:11 -04:00
The physical size in millimetres of a monitor, or an estimation of it, can be
retrieved with @ref glfwGetMonitorPhysicalSize.
2013-05-27 15:58:33 -04:00
@code
int widthMM, heightMM;
glfwGetMonitorPhysicalSize(monitor, &widthMM, &heightMM);
@endcode
2013-06-17 06:56:36 -04:00
This can, for example, be used together with the current video mode to calculate
the DPI of a monitor.
@code
const double dpi = mode->width / (widthMM / 25.4);
@endcode
2013-05-27 15:58:33 -04:00
2014-04-23 07:30:11 -04:00
@subsection monitor_pos Virtual position
2013-05-27 15:58:33 -04:00
2014-04-23 07:30:11 -04:00
The position of the monitor on the virtual desktop, in screen coordinates, can
be retrieved with @ref glfwGetMonitorPos.
@code
int xpos, ypos;
glfwGetMonitorPos(monitor, &xpos, &ypos);
@endcode
@subsection monitor_name Human-readable name
The human-readable name of a monitor is returned by @ref glfwGetMonitorName.
It is a regular C string using the UTF-8 encoding.
2013-05-27 15:58:33 -04:00
@code
const char* name = glfwGetMonitorName(monitor);
@endcode
2014-04-23 07:30:11 -04:00
@note Monitor names are not guaranteed to be unique. Two monitors of the same
model and make may have the same name. Only the address of a monitor object is
guaranteed to be unique.
2013-05-27 15:58:33 -04:00
2014-04-23 07:30:11 -04:00
@subsection monitor_gamma Gamma ramp
2013-05-27 15:58:33 -04:00
The gamma ramp of a monitor can be set with @ref glfwSetGammaRamp, which accepts
a monitor handle and a pointer to a @ref GLFWgammaramp structure.
@code
2014-04-23 07:30:11 -04:00
GLFWgammaramp ramp;
unsigned short red[256], green[256], blue[256];
ramp.size = 256;
ramp.red = red;
ramp.green = green;
ramp.blue = blue;
for (i = 0; i < ramp.size; i++)
{
// Fill out gamma ramp arrays as desired
}
2013-05-27 15:58:33 -04:00
glfwSetGammaRamp(monitor, &ramp);
@endcode
2014-04-23 07:30:11 -04:00
The gamma ramp data is copied before the function returns, so there is no need
to keep it around once the ramp has been set.
@note It is recommended to use gamma ramps of size 256, as that is the size
supported by virtually all graphics cards on all platforms.
The current gamma ramp for a monitor is returned by @ref glfwGetGammaRamp. The
returned structure and its arrays are allocated and freed by GLFW.
2013-05-27 15:58:33 -04:00
@code
const GLFWgammaramp* ramp = glfwGetGammaRamp(monitor);
@endcode
If you wish to set a regular gamma ramp, you can have GLFW calculate it for you
from the desired exponent with @ref glfwSetGamma, which in turn calls @ref
glfwSetGammaRamp with the resulting ramp.
@code
glfwSetGamma(monitor, 1.0);
@endcode
2013-05-27 11:10:34 -04:00
*/