How to move LWJGL's window after it has been created?

Started by dlubarov, December 28, 2013, 01:52:25

Previous topic - Next topic

dlubarov

I tried calling Display.setLocation, but it doesn't seem to work if the display has already been created. I'm not sure if this is a bug or just the expected behavior of setLocation.

Here's an example to demonstrate. I want the window to move up and down in response to the keyboard. When I run it, it prints "moving up/down", but the window doesn't move.

public class Test {
  public static void main(String[] args) throws Exception {
    Display.setDisplayMode(new DisplayMode(640, 480));
    Display.create();
    
    while (!Display.isCloseRequested()) {
      if (Keyboard.isKeyDown(Keyboard.KEY_UP)) {
        System.out.println("moving up");
        Display.setLocation(Display.getX(), Display.getY() - 1);
      }
      if (Keyboard.isKeyDown(Keyboard.KEY_DOWN)) {
        System.out.println("moving down");
        Display.setLocation(Display.getX(), Display.getY() + 1);
      }
      Display.update();
      Display.sync(60);
    }
  }
}


I can get it to work by destroying and recreating the display with each setLocation, but I want to move the window in small increments, so it's not a practical solution.

I'm using LWJGL 2.9.1 on OSX.

(I also made a question on StackOverflow yesterday. I'll be checking both.)

Thanks,
Daniel

Cornix

Display.setLocation works for me like a charm. Even after creating the window. (testing on windows 7)
Are you sure, that its Display.setLocation that doesn work? Maybe its your Conditions.

ra4king

-Roi

dlubarov

Thank you both for testing it. I tried some different versions, and it works on my machine (OSX 10.9) if I use 2.8.5, but not 2.9.0. I'll post a bug report.

ra4king

-Roi