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
| private float[]pointsf = { 1.000000f, -1.000000f, -1.000000f, 1.000000f, -1.000000f, 1.000000f, -1.000000f, -1.000000f, 1.000000f, -1.000000f, -1.000000f, -1.000000f, 1.000000f, 1.000000f, -0.999999f, 0.999999f, 1.000000f, 1.000001f, -1.000000f, 1.000000f, 1.000000f, -1.000000f, 1.000000f, -1.000000f };
private FloatBuffer rectVertices;
@Override public void display(GLAutoDrawable gld ) { GL2 gl = gld.getGL().getGL2(); gl.glClear( GL2.GL_COLOR_BUFFER_BIT | GL2.GL_DEPTH_BUFFER_BIT ); gl.glMatrixMode( GL2.GL_MODELVIEW ); gl.glLoadIdentity(); gl.glTranslatef( 0.0f, 0.0f, -5.0f ); gl.glRotatef( 0, 1.0f, 0.0f, 0.0f ); gl.glRotatef( 0, 0.0f, 1.0f, 0.0f ); rectVertices = GLBuffers.newDirectFloatBuffer( pointsf.length ); rectVertices.put( pointsf ); rectVertices.rewind(); gl.glVertexPointer( 3, GL2.GL_FLOAT, 0, rectVertices ); gl.glEnableClientState( GL2.GL_VERTEX_ARRAY ); gl.glNormal3f( 0,0,1 ); gl.glDrawArrays( GL2.GL_POINTS, 0, pointsf.length ); gl.glDisableClientState( GL2.GL_VERTEX_ARRAY ); }
public void init(GLAutoDrawable gld ) { GL2 gl = gld.getGL().getGL2(); glu = new GLU(); gl.glClearColor( 0.0f, 0.0f, 0.0f, 1.0f ); gl.glEnable( GL2.GL_DEPTH_TEST ); gl.glMatrixMode( GL2.GL_PROJECTION ); gl.glLoadIdentity(); glu.gluPerspective( 45.0, 500.0 / 500.0, 1.0, 500.0 ); gl.glPointSize( 5.0f ); } |