views:

34

answers:

2

I'm new to OpenGL. I'm using Java/JOGL.

I'm having difficulty with polygon faces. I want to be able to control which side is the front or back. I've been working through this documentation.

I thought this line of code, in my display() method, would make all poly faces be drawn, but it had no effect:

gl.glPolygonMode(GL.GL_FRONT_AND_BACK, GLU.GLU_LINE);

Using this, I am able to flip which sides get rendered:

gl.glFrontFace(GL.GL_CW);

but half my polys are facing one way, and half are facing the other, so only half of them are ever rendered.

I tried using gl.glNormal3f() to set the normal, hoping that that would have something to do with which is the "front", but it had no effect.

What am I supposed to be doing here?

Thanks.

+4  A: 

The front is not defined by normals, but the order of the vertices. When looking at the polygon from the front, if you follow the vertices in the order in which they were created, you'll end up tracing the polygon either clockwise or counterclockwise. If you look at the polygon from the other side, you'll trace it in the opposite direction.

glFrontFace sets which direction is considered the front. Make sure all your vertices are defined in the same order when viewed from the direction that's supposed to be the front.

Matti Virkkunen
+2  A: 

Maybe you have culling enabled. If you disable it with

glDisable(GL_CULL_FACE);

then all of your faces ought to get rasterized, but it's really best to make sure your polygons aren't inside out.

jleedev