- // Save Light status
- gl.glPushAttrib(GL.GL_LIGHTING);
- // Disable Light
- gl.glDisable(GL.GL_LIGHTING);
- // Save current modelview matrix
- gl.glPushMatrix();
- // Set the billboard's position
- gl.glTranslatef(position.x, position.y, position.z);
- // Get the current modelview matrix
- DoubleBuffer modelview = DoubleBuffer.allocate(16);
- gl.glGetDoublev(GL.GL_MODELVIEW_MATRIX, modelview);
- // Identity matrix
- double[] identity = { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0 };
- // Overwrite rotation values
- modelview.put(identity);
- gl.glLoadMatrixd(modelview);
- // Draw billboard
- gl.glBegin(GL.GL_QUADS);
- gl.glVertex3f(-1, 1, 0);
- gl.glVertex3f(-1, -1, 0);
- gl.glVertex3f( 1, -1, 0);
- gl.glVertex3f( 1, 1, 0);
- gl.glEnd();
- // restore
- gl.glPopMatrix();
- gl.glPopAttrib(); // GL_LIGHTING