Hello,
I wanted to create a simple window with the LWJGL and a key input request which closes the window.
I also wanted to create the classes in seperated packages, so it's more organized.
The window displays but if I press that certain key nothing happens.
It would be great if you could help me.
Thanks!
Here is the Main class:
package bb.main; import bb.input.Input; import bb.main.render.SimpleRenderer; public class Main { public static void main(String[] args){ SimpleRenderer createWindow = new SimpleRenderer(); Input input = new Input(); createWindow.Render(); input.checkKey(); } }
Here is the SimpleRenderer class:
package bb.main.render; import org.lwjgl.LWJGLException; import org.lwjgl.opengl.Display; import org.lwjgl.opengl.DisplayMode; public class SimpleRenderer { public void Render(){ try{ Display.setDisplayMode(new DisplayMode(1280, 720)); Display.setTitle("MISSING TITLE!"); Display.create(); } catch (LWJGLException LWex){ LWex.printStackTrace(); System.exit(0); } while(!Display.isCloseRequested()){ Display.update(); } Display.destroy(); } }
And here is the Input class:
package bb.input; import org.lwjgl.input.Keyboard; import org.lwjgl.opengl.Display; public class Input { public void checkKey(){ while(Keyboard.next()){ if(Keyboard.getEventKeyState()){ if(Keyboard.getEventKey() == Keyboard.KEY_ESCAPE){ Display.destroy(); System.exit(0); } } } Display.destroy(); } }