[LWJGL3] Question about resizing windows

Started by orange451, December 18, 2015, 20:05:39

Previous topic - Next topic

orange451

I remember reading somewhere that resizing (or perhaps changing to fullscreen from windowed) a window in lwjgl3 requires destroying the GL context and re-creating it.

Doing this would destroy all data I've put into the GPU, such as textures, right?

Is there a way around this?

Kai

The problem is that the API of GLFW does not support/export this at the moment.
You can either create a new window and GL context in windowed mode, or create a window and GL context in fullscreen mode. Not toggling between both modes.

Technically, though, GLFW already implements everything for it.
At least for the Windows platform, when looking into the sources win32_window.c and win32_monitor.c.
There is a function to toggle fullscreen.
And, at least on Windows, it will work to toggle between fullscreen and windowed mode without losing the GL context *if* the display mode does not change between them. That is to say, if the fullscreen window also uses the desktop display mode (same bit depths, same dimension).
With a non-fullscreen windowed you can however of course resize it arbitrarily.

So, if you want to toggle between windowed and fullscreen, you (current) always have to create two separate windows and GL contexts for that.

What are your options now?
You can use SWT which already implements desktop display mode fullscreen toggling.

aeonios

erm...

public void setSize(int width, int height){
        glfwSetWindowSize(windowID, width, height);
}

If you want to go from an undecorated window to a decorated one you'll have to create a new window though. That should only be a problem if you're trying to draw from multiple threads, which is a dumb thing to do anyway (make a special thread for drawing if you need multithreading). You're probably thinking of LWJGL2, and LWJGL2 lets you resize windows also, but doesn't support hiding windows.

orange451

Quote from: aeonios on December 19, 2015, 04:03:02
You're probably thinking of LWJGL2
No, I'm not, but thanks for playing.

Quote from: Kai on December 18, 2015, 21:28:08
The problem is that the API of GLFW does not support/export this at the moment.
Does anyone know if this will be changed in the future? I'll look into SWT, thanks for the heads up!

Cornix

Quote from: orange451 on December 20, 2015, 10:23:05Does anyone know if this will be changed in the future? I'll look into SWT, thanks for the heads up!
This feature is supposed to be added to GLFW in the future, but nobody can really say when it is going to come.