GLFW: size, position & monitorsGLFW 1.0
glfwGetWindowSize
Reads the size of the window's content area in SCREEN COORDINATES (not pixels).
Signature
void glfwGetWindowSize(GLFWwindow* window, int* width, int* height);
How it works
This is the size in the same units as glfwCreateWindow and the cursor position. It does not include the title bar or borders (see glfwGetWindowFrameSize for those).
Use it for things measured in screen coordinates, such as turning a cursor position into a 0–1 fraction of the window. For glViewport use glfwGetFramebufferSize.
Parameters
windowGLFWwindow*
The window to measure.
widthint*
Where to write the width, or NULL.
heightint*
Where to write the height, or NULL.
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
1double mx, my;
2int ww, wh;
3glfwGetCursorPos(window, &mx, &my);
4glfwGetWindowSize(window, &ww, &wh); // same units as the cursor
5float u = (float)(mx / ww), v = 1.0f - (float)(my / wh);