Search code examples
javalwjgl

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?


Solution

  • 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.