Lighting in OpenGL ES

Hey everyone -

I running OpenGL via the iPhone, and I’m getting some weird problems with my models, which seems to be determined by lighting. Basically, I’m using glDrawArrays to draw a big model out via GL_TRIANGLES. It’s also UV mapped… both of those work fine. The problem is that I get weird holes in my model and some ugly flickering or blackened out polys, and this appears to be due to the lighting. My lighting is this:

Don’t worry, I know about the pointer issues there, those are just the values simplified for the forum.

glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glLightfv(GL_LIGHT0, GL_AMBIENT, {0.1, 0.1, 0.1, 1.0});
glLightfv(GL_LIGHT0, GL_DIFFUSE, {1.0, 1.0, 1.0, 1.0});
glLightfv(GL_LIGHT0, GL_POSITION, {0.0, 0.0, 5.0, 0.0});
glLightfv(GL_LIGHT0, GL_SPECULAR, {1.0, 1.0, 1.0, 1.0});
glLightfv(GL_LIGHT0, GL_SHININESS, 5.0);

My object is being drawn at a Z position of -2.0f and its longest dimension is 1.0, all polys considered.

The object has the materials like this:

glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, {0, 0, 0, 1} );
glColor4f(0, 0, 0, 1);
glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, {0, 0, 0, 1});
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, {1, 1, 1, 1} );
glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 0);

So… is there something I’m doing wrong that would cause holes at certain rotations, blackened triangles, and weird transparency (I can see one side of the model through the other, but only at certain angles). Let me know if you need more information to help me diagnose this.

Thanks a lot!

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.