Hello Guest

[LWJGL3] Question about resizing windows

  • 4 Replies
  • 3206 Views
[LWJGL3] Question about resizing windows
« on: December 18, 2015, 20:05:39 »
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

Re: [LWJGL3] Question about resizing windows
« Reply #1 on: December 18, 2015, 21:28:08 »
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.
« Last Edit: December 18, 2015, 21:32:08 by Kai »

Re: [LWJGL3] Question about resizing windows
« Reply #2 on: December 19, 2015, 04:03:02 »
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.

Re: [LWJGL3] Question about resizing windows
« Reply #3 on: December 20, 2015, 10:23:05 »
You're probably thinking of LWJGL2
No, I'm not, but thanks for playing.

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!

*

Offline Cornix

  • *****
  • 488
Re: [LWJGL3] Question about resizing windows
« Reply #4 on: December 20, 2015, 10:54:38 »
Does 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.