lwjgl.org
January 06, 2009, 02:59:36 *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: LWJGL 2.0.1 released!
 
   Home   Help Search Login Register  



Pages: [1]
  Print  
Author Topic: Use Keyboard  (Read 1024 times)
bbjam
Newbie
*
Posts: 11


View Profile
« on: September 16, 2008, 19:50:53 »

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
Code:
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)
Logged
Fool Running
Nerdus Imperius
*****
Posts: 447


View Profile
« Reply #1 on: September 16, 2008, 21:25:00 »

Yes, you can't use the keyboard without some kind of display.

See Display.create()
Logged

Programmers will, one day, rule the world... and the world won't notice until its too late.Just testing the marquee option Grin
bbjam
Newbie
*
Posts: 11


View Profile
« Reply #2 on: September 17, 2008, 02:05:48 »

By that I think you mean org.lwjgl.opengl.Display.

Big thanks Smiley

b.t.w. Is there any way to draw on the surface you get from Display.create() with Java2D?
Logged
Buggy
Newbie
*
Posts: 7


View Profile
« Reply #3 on: November 12, 2008, 04:37:36 »

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.
Logged
Matzon
Administrator
Nerdus Imperius
*****
Posts: 1630



View Profile
« Reply #4 on: November 12, 2008, 08:45:54 »

input creation is now done automatically when you create the display.
Logged

http://certusgames.com (Free Online Multiplayer Java Games)
http://lwjgl.org (OpenGL/OpenAL for Java)
Buggy
Newbie
*
Posts: 7


View Profile
« Reply #5 on: November 12, 2008, 23:15:50 »

So does calling Keyboard.create() create a second keyboard object? Or is calling it just good coding style, and no new object is created?
Logged
Matzon
Administrator
Nerdus Imperius
*****
Posts: 1630



View Profile
« Reply #6 on: November 13, 2008, 09:32:31 »

If the keyboard hasn't been created, it wil create it - otherwise it will just do nothing.
Logged

http://certusgames.com (Free Online Multiplayer Java Games)
http://lwjgl.org (OpenGL/OpenAL for Java)
Buggy
Newbie
*
Posts: 7


View Profile
« Reply #7 on: November 15, 2008, 00:38:31 »

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?
Logged
Matzon
Administrator
Nerdus Imperius
*****
Posts: 1630



View Profile
« Reply #8 on: November 15, 2008, 01:15:27 »

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
Logged

http://certusgames.com (Free Online Multiplayer Java Games)
http://lwjgl.org (OpenGL/OpenAL for Java)
Buggy
Newbie
*
Posts: 7


View Profile
« Reply #9 on: November 15, 2008, 05:03:38 »

Ah... thanks for clearing that up.
Logged
lwjgl.org
   



 Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.7 | SMF © 2006-2008, Simple Machines LLC Valid XHTML 1.0! Valid CSS!