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
| public void init(GLDrawable glDrawable){
GL gl=glDrawable.getGL();
gl.glClearColor(1.f,1.f,1.f,0.5f);
gl.glPointSize(4.f);
}
public void display(GLDrawable glDrawable){
GL gl=glDrawable.getGL();
GLU glu=glDrawable.getGLU();
gl.glClear(GL.GL_COLOR_BUFFER_BIT);
gl.glMatrixMode(GL.GL_MODELVIEW);
glu.gluLookAt(0,0,10,0,0,0,0,1,0);
gl.glPointSize(40.f);
gl.glBegin (GL.GL_QUADS);
gl.glColor3d(1,0,0);
gl.glVertex3d (-.5,.5,0);
gl.glColor3d(0,1,0);
gl.glVertex3d (.5,.5,0);
gl.glColor3d(0,0,1);
gl.glVertex3d (.5,-.5,0);
gl.glColor3d(1,1,1);
gl.glVertex3d (-.5,-.5,0);
gl.glEnd ();
gl.glFlush();
}
public void reshape(GLDrawable glDrawable,int x,int y,int width,int height){
final GL gl=glDrawable.getGL();
final GLU glu=glDrawable.getGLU();
gl.glViewport(0,0,width,height);
gl.glMatrixMode(GL.GL_PROJECTION);
gl.glLoadIdentity();
glu.gluPerspective(45,1,1,100);
} |
Partager