Hello everyone. I am having trouble with OpenGL 1.1 lighting. My code works on the iPhone 4 but not the iPhone 3G. Everything appears unlit (flat colours). I don't have a 3GS so I can't find out if it works on that one or not.
Here is my lighting setup:
- (void)setupLighting
{
const GLfloat lightAmbient[] = {0.2, 0.2, 0.2, 1.0};
const GLfloat matAmbient[] = {0.6, 0.6, 0.6, 1.0};
const GLfloat matDiffuse[] = {1.0, 1.0, 1.0, 1.0};
const GLfloat matSpecular[] = {0.6, 0.6, 0.6, 0.1};
const GLfloat lightPosition[] = {0.0, 0.0, 0.0, 0.0};
const GLfloat lightShininess = 100.0;
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, matAmbient);
glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, matDiffuse);
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, matSpecular);
glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, lightShininess);
glLightfv(GL_LIGHT0, GL_AMBIENT, lightAmbient);
glLightfv(GL_LIGHT0, GL_POSITION, lightPosition);
glShadeModel(GL_SMOOTH);
NSLog(@"Lighting sorted");
}
I supply normal vectors and so on after that, which successfully renders on the newer iPhone... however, I would really like to support all three iPhones. (It also works on the iPad).