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 61 62 63
| package com;
import org.lwjgl.opengl.Display; import org.lwjgl.opengl.DisplayMode; import org.lwjgl.opengl.GL11; import java.nio.FloatBuffer; import java.nio.ByteBuffer; import java.nio.ByteOrder; import org.lwjgl.util.glu.GLU; import com.engine.objects.*; import org.lwjgl.util.vector.Vector3f;
public class EngineTest { public static void main(String[] args) {
try { Display.setDisplayMode(new DisplayMode(800,600)); Display.create(); } catch (Exception e) {
} initGL();
Triangle myTriangle = new Triangle(new Vertex(new Vector3f(1.0f,2.0f,1.0f),null,null,null),new Vertex(new Vector3f(1.0f,-1.0f,1.0f),null,null,null),new Vertex(new Vector3f(-1.0f,-1.0f,1.0f),null,null,null)); while(!Display.isCloseRequested()) { GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); GL11.glLoadIdentity(); GL11.glTranslatef(0.0f,0.0f,-10.0f);
GL11.glCallList(myTriangle.getObjectList());
Display.update(); }
Display.destroy();
}
private static void initGL() { GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); GLU.gluPerspective(45.0f,((float)800)/((float)600),0.1f,100.0f); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity();
GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glShadeModel(GL11.GL_SMOOTH); GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); GL11.glClearDepth(1.0f); GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glDepthFunc(GL11.GL_LEQUAL); GL11.glHint(GL11.GL_PERSPECTIVE_CORRECTION_HINT, GL11.GL_NICEST); } } |