I was trying to create a window in LWJGL 2 but when I tried to get the display width, it just returned a negative number.
import org.lwjgl.LWJGLException;
import org.lwjgl.opengl.Display;
import org.lwjgl.opengl.DisplayMode;
public class Test {
public static void main(String[] args) {
try {
Display.setDisplayMode(new DisplayMode(854, 480));
Display.setResizable(true);
Display.create();
} catch (LWJGLException e) {
e.printStackTrace();
System.exit(1);
}
while (!Display.isCloseRequested()) {
if (Display.wasResized()) {
int newWidth = Display.getWidth();
int newHeight = Display.getHeight();
System.out.println("Width: " + newWidth + ", Height: " + newHeight);
}
Display.update();
}
}
}
I tried downloading multiple times the libraries and deleting the 32 bit ones. But it didn’t solve the problem.
I founded another problem also, when I resize the display vertically the width modifies.
I’m so confused, here some logs in the console:
Width: -282, Height: 0
Width: -88, Height: 0
Width: -324, Height: 0