GLFW: size, position & monitorsGLFW 1.0

glfwSetWindowSizeCallback

Registers a function called when the window's content area changes size, in screen coordinates.

Signature

GLFWwindowsizefun glfwSetWindowSizeCallback(GLFWwindow* window, GLFWwindowsizefun callback);

How it works

The twin of glfwSetFramebufferSizeCallback, in the other unit. Use it for layout that is measured in screen coordinates, such as a user interface. For anything OpenGL (the viewport, render targets) use the framebuffer callback.

Parameters

windowGLFWwindow*

The window to watch.

callbackGLFWwindowsizefun

Your function, void f(GLFWwindow* window, int width, int height), or NULL.

Return value

The callback that was set before, 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.

Example

example.cpp
1glfwSetWindowSizeCallback(window, [](GLFWwindow*, int w, int h) {
2    ui.layout(w, h);   // screen coordinates
3});
Official GLFW documentation