1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
| import org.lwjgl.*; import org.lwjgl.opengl.*; import org.lwjgl.input.*;
public class Game { static boolean finished = false; static { try { Window.create("HELLO WORLD",50,50,640,480,32,0,8,0); } catch (Exception e) { e.printStackTrace(); System.exit(0); } } public static void main(String argv[]) { try { { Keyboard.create(); GL.glClearColor(0.0f,0.0f,0.0f,0.0f); GL.glMatrixMode(GL.GL_PROJECTION); GL.glLoadIdentity(); GL.glOrtho(0.0f,1.0f,0.0f,1.0f,0.0f,0.0f); } while (!finished) { render(); Window.update(); Window.paint(); } Window.destroy(); Keyboard.destroy(); } catch (Exception exp) { exp.printStackTrace(); } } public static void render() { if (Window.isCloseRequested()) { finished = true; return; } Keyboard.poll(); if (Keyboard.isKeyDown(Keyboard.KEY_ESCAPE)) { finished = true; return; } GL.glClear(GL.GL_COLOR_BUFFER_BIT); GL.glColor3f(0.0f,1.0f,0.0f); GL.glBegin(GL.GL_POLYGON); { GL.glVertex3f(0.25f,0.25f,0.0f); GL.glVertex3f(0.75f,0.25f,0.0f); GL.glVertex3f(0.75f,0.75f,0.0f); GL.glVertex3f(0.25f,0.75f,0.0f); } GL.glEnd(); } } |