LWJGL Forum

Programming => Lightweight Java Gaming Library => Topic started by: CrossKun on May 15, 2013, 20:39:45

Title: while(Keyboard.next()) not responding
Post by: CrossKun on May 15, 2013, 20:39:45
Good evening fellows!

Story:
At first I was learning LWJGL by codinguniverse and now switched to the online book "Learning Modern OpenGL" with rosicks/mckessons port of the tutorial source code.

Problem:
Back then when I was practicing the codingUniverse tutorials the following code would work
while(Keyboard.next()){
if(Keyboard.getEventKey() == Keyboard.KEY_F){
System.out.println("!");

}

but when I try to play around a bit besides the LearningModern..tutorials, this code will be ignored.
simple "if(Keyboard.isKeyDown(Key_F) System.out.Println("!")" works fine, which confuses me  ???

Could someone give me a hint what Im missing?

I tried to search for this problem already but couldnt find a solution that fits :/

Sincerly,
Cross!
Title: Re: while(Keyboard.next()) not responding
Post by: quew8 on May 16, 2013, 18:00:21
Make sure you are calling Display.update() or Keyboard.poll() (update calls this) at the end of your loop. This polls the keyboard for events as you might guess.
Title: Re: while(Keyboard.next()) not responding
Post by: CrossKun on May 16, 2013, 19:21:16
Ah, great thanks more than 2 tons for the advice! :)

I found the solution due to this.
The class of the display tutorial "lwjglwindow.java" had already a while(keyboard.next()) loop, as soon as I removed that one and tried it in my own class it worked!

I really appreciate it, that solutions and ideas are posted here so quickly, thanks a lot!