Bartvbl
Bartvbl

Reputation: 2928

How do I make an LWJGL window resizable?

I am trying to make the window of my java game resizable, which uses the LWJGL library. According to some forum questions that date back from 2007 this is only possible with a workaround. Is this still the case today? And what is the way to go?

Upvotes: 7

Views: 8784

Answers (3)

Anthony Sasse
Anthony Sasse

Reputation: 64

If you are using LWJGL 2.9 you can call

Display.setResizable();

This will allow the window to be resized.

Then before you update the display do this.

if (Display.wasResized()) GL11.glViewport(0, 0, Display.getWidth(), Display.getHeight());

this will change the viewport to be the size of the screen if it was resized.

Upvotes: 4

randfur
randfur

Reputation: 251

The Display class has the option for enabling resizing. http://lwjgl.org/javadoc/org/lwjgl/opengl/Display.html#setResizable(boolean)

You can get the width and height at anytime with getWidth() and getHeight().

Upvotes: 25

Gavin
Gavin

Reputation: 842

LWJGL's native display is not resizable. However its easy to achieve you simply use an AWT Frame and using Display.setParent(Canvas) stick your LWJGL content on it to get a resizeable window.

Upvotes: 6

Related Questions