I've been diving into openGL head first on the iOS over the past week and have just finished writing a file parser for loading in models. I'm currently just working with triangles and normals and lighting - I'm not attempting textures at the moment and am simply organizing the data internally in an array of triangles before I attempt to do triangle strips.
The model I've loaded is concave and looks correct unless at certain angles (I don't have a depth buffer in yet). I'm currently just rotating the model about it's x-axis and have one light in the scene. The issue is, even with culling on, the model is appearing completely white when turned 180 degrees and completely black while turned 0 degrees.
It's more than possible I'm just making a stupid beginners mistake. The light position should be well outside the geometry of the object and I've tried both back and front culling so I'm not sure what else could be the issue.
Here is some code:
//creating openGL lighting
GLfloat lightAmbient[] = {0.2f, 0.2f, 0.2f, 0.0f};
GLfloat lightDiffuse[] = {1.0f, 1.0f, 1.0f, 0.0f};
GLfloat lightSpecular[] = {1.0f, 1.0f, 1.0f, 0.0f};
glLightfv(GL_LIGHT0, GL_AMBIENT, lightAmbient);
glLightfv(GL_LIGHT0, GL_DIFFUSE, lightDiffuse);
glLightfv(GL_LIGHT0, GL_SPECULAR, lightSpecular);
glShadeModel(GL_SMOOTH);
GLfloat lightPosition[] = {0.0f, 0.0f, 10.0f, 1.0f};
glLightfv(GL_LIGHT0, GL_POSITION, lightPosition);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
//face culling
glEnable(GL_CULL_FACE);
glCullFace(GL_BACK);
[(EAGLView *)self.view setFramebuffer];
MeshInstance *tempMesh = [MeshLibrary createMeshInstance:MESH_RED_BLOOD_CELL];
glClearColor(0.5f, 0.5f, 0.5f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glScalef(0.5, 0.5, 0.5);
glTranslatef(0, 0, 0);
rotX += 0.5f;
glRotatef(rotX, 1.0, 0, 0);
transY += 0.075f;
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3, GL_FLOAT, 0, tempMesh.meshPtr.vertices);
glEnableClientState(GL_NORMAL_ARRAY);
glNormalPointer(GL_FLOAT, 0, tempMesh.meshPtr.normals);
glDrawArrays(GL_TRIANGLES, 0, tempMesh.meshPtr.vertexCount);
[tempMesh dealloc];
[(EAGLView *)self.view presentFramebuffer];
And here are some screenshots demonstrating the issue:


Any help would be greatly appreciated!


