GLFW_RESIZABLE after the creation of the window

1.2k views Asked by At

I'm really starting out with LWJGL (I just started) and I focused on one thing: When I create a window and I want to set it as not resizable, I use:

glfwWindowHint(GLFW_RESIZABLE, GL_FALSE);
window = glfwCreateWindow(WIDTH, HEIGHT, TITLE, NULL, NULL);

However, even if I want to set this after the window was created, I do not know how. I just tried to put the command after the creation of the window, but it won't work:

window = glfwCreateWindow(WIDTH, HEIGHT, TITLE, NULL, NULL);
glfwWindowHint(GLFW_RESIZABLE, GL_FALSE);

So, how I can resolve this?

2

There are 2 answers

0
javac On BEST ANSWER

From the GLFW Window Guide:

Window creation hints

There are a number of hints that can be set before the creation of a window and context. Some affect the window itself, others affect the framebuffer or context. These hints are set to their default values each time the library is initialized with glfwInit, can be set individually with glfwWindowHint and reset all at once to their defaults with glfwDefaultWindowHints.

Note that hints need to be set before the creation of the window and context you wish to have the specified attributes.

Essentially, you set hints like whether the window should be resizable, which context version it has etc. through glfwWindowHint() calls. These hints will then be used the next time you create a window with glfwCreateWindow(). If you set hints after the window has been created, then only new windows created after the call will be affected.

Therefore, it is currently not possible to change certain GLFW window properties, like whether it is resizable, after creation.

0
Robbie On

You can now change glfw Window Attributes with:

void glfwSetWindowAttrib(GLFWwindow * window, int attrib, int value);

From the documentation for glfw3 or lwjgl

This function sets the value of an attribute of the specified window.

The supported attributes are GLFW_DECORATED, GLFW_RESIZABLE, GLFW_FLOATING, GLFW_AUTO_ICONIFY and GLFW_FOCUS_ON_SHOW.

Some of these attributes are ignored for full screen windows. The new value will take effect if the window is later made windowed.

Some of these attributes are ignored for windowed mode windows. The new value will take effect if the window is later made full screen.