GLFW: size, position & monitorsGLFW 3.0
glfwGetVideoMode
Reads a monitor's current resolution, color depth and refresh rate.
Signature
const GLFWvidmode* glfwGetVideoMode(GLFWmonitor* monitor);
How it works
The returned GLFWvidmode has width and height (in screen coordinates), redBits, greenBits, blueBits and refreshRate (in Hz).
The usual use is full screen without changing the monitor's mode ("borderless full screen"): pass exactly these width, height and refresh rate to glfwSetWindowMonitor or glfwCreateWindow, and the monitor does not flicker into a new mode.
Parameters
monitorGLFWmonitor*
The monitor to ask about.
Return value
A pointer owned by GLFW, valid until the monitor is disconnected or GLFW terminates. Do not free it.
Errors
When the call is invalid it does nothing and sets an error, which glGetError returns:
- GLFW_NOT_INITIALIZED
- Called before glfwInit or after glfwTerminate.
- GLFW_PLATFORM_ERROR
- The operating system or window system reported a failure; the description says which.
Example
example.cpp
1const GLFWvidmode* mode = glfwGetVideoMode(glfwGetPrimaryMonitor());
2double frameBudgetMs = 1000.0 / mode->refreshRate; // 16.7 ms at 60 Hz