I'm trying to use the Keyboard class insted of Java's key events for my game engine, but when I try to .create() the keyboard I get
Exception in thread "main" java.lang.IllegalStateException: Display must be created.
at org.lwjgl.input.Keyboard.create(Keyboard.java:319)
at com.glassFlame.event.EventSystem.<init>(EventSystem.java:43)
at com.glassFlame.scene.SceneBuilder.createScene(SceneBuilder.java:19)
at com.glassFlame.util.setup.GameEngineFactory.createGameEngine(GameEngineFactory.java:16)
at test.TestFrame.<init>(TestFrame.java:88)
at test.TestFrame.main(TestFrame.java:38)
Yes, you can't use the keyboard without some kind of display.
See Display.create()
By that I think you mean org.lwjgl.opengl.Display.
Big thanks :)
b.t.w. Is there any way to draw on the surface you get from Display.create() with Java2D?
I just made my very first OpenGL window, and keypresses seem to work without me having to call "Keyboard.create()" ... is this just a matter of style, or is it actually important?
I'm just using Keyboard.isKeyPressed() calls, by the way.
input creation is now done automatically when you create the display.
So does calling Keyboard.create() create a second keyboard object? Or is calling it just good coding style, and no new object is created?
If the keyboard hasn't been created, it wil create it - otherwise it will just do nothing.
Except, if I understand correctly, the keyboard can't be created without first creating a display. And creating a display automatically creates a keyboard, rendering Keyboard.create() completely useless.
Is there something I'm missing here?
a) its old code, hence no need to break stuff
b) you can disable automatic input creation using:
org.lwjgl.opengl.Display.nokeyboard
org.lwjgl.opengl.Display.nomouse
org.lwjgl.opengl.Display.noinput
Ah... thanks for clearing that up.