I am trying to render some simple solid shapes in JOGL (and Eclipse) and then step through them 'layer' by 'layer'; but when I add the glClear method all I get are wire frames, not the filled shape!? If I comment that line out (as below) displays the solid shape but 'fills' to the largest the shape will be and then does not shrink down again. e.g with a sphere the front half is fine but the back half comes out as a solid cylinder if that makes sense.
public void render(GLAutoDrawab开发者_StackOverflowle gLDrawable)
{
GL2 gl = gLDrawable.getGL().getGL2();
**//gl.glClear(GL2.GL_COLOR_BUFFER_BIT | GL2.GL_DEPTH_BUFFER_BIT);**
gl.glColor3b((byte) 0, (byte) 127, (byte) 0);
gl.glLoadIdentity();
gl.glTranslatef(500, 350, -300);
glut.glutSolidSphere(300.0, 20, 16);
gl.glTranslatef(-500, -350, 300);
gl.glEnd();
gl.glFlush();
}
Any help would be much appreciated, Ic an post more of the code if needed.
Thanks Tim
EDITED To make more sense
insert this before you create your sphere... It will tell Opengl to fill the next polygons that are drawn...
gl.glPolygonMode(gl.GL_FRONT_AND_BACK, gl.GL_FILL);
if you want the wireframe again, just call:
gl.glPolygonMode(gl.GL_FRONT_AND_BACK, gl.GL_LINE);
:)
精彩评论