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 64 65 66 67 68
|
private static void render() {
// clear the screen
GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
// center square according to screen size
GL11.glPushMatrix();
GL11.glTranslatef(Display.getDisplayMode().getWidth() / 2, Display.getDisplayMode().getHeight() / 2, 0.0f);
// rotate square according to angle
//GL11.glRotatef(angle, 0, 0, 1.0f);
// render the square
GL11.glMatrixMode(GL11.GL_MODELVIEW);
GLU.gluLookAt(5,0,1,0,5,0,0,1,0);
GL11.glBegin(GL11.GL_QUADS);
GL11.glColor3d(1,0,0);
GL11.glVertex3i(50,50,50);
GL11.glVertex3i(50,-50,50);
GL11.glVertex3i(-50,-50,50);
GL11.glVertex3i(-50,50,50);
//1 face
GL11.glColor3d(0,1,0);
GL11.glVertex3i(50,50,-50);
GL11.glVertex3i(50,-50,-50);
GL11.glVertex3i(-50,-50,-50);
GL11.glVertex3i(-50,50,-50);
//2 faces
GL11.glColor3d(0,0,1);
GL11.glVertex3i(50,50,50);
GL11.glVertex3i(50,-50,50);
GL11.glVertex3i(50,-50,-50);
GL11.glVertex3i(50,50,-50);
//3 faces
GL11.glColor3d(0,1,1);
GL11.glVertex3i(-50,50,50);
GL11.glVertex3i(-50,-50,50);
GL11.glVertex3i(-50,-50,-50);
GL11.glVertex3i(-50,50,-50);
//4 faces
GL11.glColor3d(1,0,0);
GL11.glVertex3i(-50,50,-50);
GL11.glVertex3i(-50,50,50);
GL11.glVertex3i(50,50,50);
GL11.glVertex3i(50,50,-50);
//5 faces
GL11.glColor3d(1,1,0);
GL11.glVertex3i(-50,-50,-50);
GL11.glVertex3i(-50,-50,50);
GL11.glVertex3i(50,-50,50);
GL11.glVertex3i(50,-50,-50);
GL11.glEnd();
GL11.glPopMatrix();
}
} |
Partager