Hi everyone, i have been doing some openGL programming on my powerbook and when i started with the lighting i got some problems. First off i tried to illuminate a sphere with two lights to "mimic" a pool ball but there seemed to be a problem with the light, i had to rotate the sphere and only half of it hat the diffuse and specular lights on it, the other half was just plain color. On top of that when the sphere rotated the change between one illuminated side and the other came with a weird swoop thing that i did not like. My first impression was the normals that i forgot to calculate so i tried using the Solid Teapot that (so i have read) is the only primitive with precalculated normals. The teapot shows even weirder behavior. With the teapot not only lighting seems weird, but the teapot has a cut in the middle, and when it turns around you can see through it as if the handle of the teapot had no alpha but the body of the teapot had some, this happens with all the faces close to the camera and i don't know what is going on, any help would be appreciated. Below i add my display method, i tried disabling face culling but don't see any improvement.
****************************************************************
void Display()
{
rot+=.01;
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
GLfloat light[]={1,1,1,1};
glLightfv(GL_LIGHT0,GL_DIFFUSE,light);
GLfloat light2[]={1,1,1,1};
glLightfv(GL_LIGHT0,GL_SPECULAR,light2);
GLfloat material[]={1,0,0
,1};
glMaterialfv(GL_FRONT_AND_BACK,GL_DIFFUSE,material);
GLfloat material2[]={1,1,1,1};
glMaterialfv(GL_FRONT_AND_BACK,GL_SPECULAR,material2);
glMaterialf(GL_FRONT_AND_BACK,GL_SHININESS,45);
GLfloat pos[]={13,5,-10,1};
glLightfv(GL_LIGHT0,GL_POSITION,pos);
glLightfv(GL_LIGHT1,GL_DIFFUSE,light);
glLightfv(GL_LIGHT1,GL_SPECULAR,light2);
glDisable(GL_CULL_FACE);
GLfloat pos1[]={-5,-5,5,1};
glLightfv(GL_LIGHT1,GL_POSITION,pos1);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glRotatef(rot,1,1,0);
//glutSolidSphere(0.3,10,10);
glutSolidTeapot(.3);
glutSwapBuffers();
glutPostRedisplay();
}
****************************************************************
****************************************************************
void Display()
{
rot+=.01;
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
GLfloat light[]={1,1,1,1};
glLightfv(GL_LIGHT0,GL_DIFFUSE,light);
GLfloat light2[]={1,1,1,1};
glLightfv(GL_LIGHT0,GL_SPECULAR,light2);
GLfloat material[]={1,0,0
,1};
glMaterialfv(GL_FRONT_AND_BACK,GL_DIFFUSE,material);
GLfloat material2[]={1,1,1,1};
glMaterialfv(GL_FRONT_AND_BACK,GL_SPECULAR,material2);
glMaterialf(GL_FRONT_AND_BACK,GL_SHININESS,45);
GLfloat pos[]={13,5,-10,1};
glLightfv(GL_LIGHT0,GL_POSITION,pos);
glLightfv(GL_LIGHT1,GL_DIFFUSE,light);
glLightfv(GL_LIGHT1,GL_SPECULAR,light2);
glDisable(GL_CULL_FACE);
GLfloat pos1[]={-5,-5,5,1};
glLightfv(GL_LIGHT1,GL_POSITION,pos1);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glRotatef(rot,1,1,0);
//glutSolidSphere(0.3,10,10);
glutSolidTeapot(.3);
glutSwapBuffers();
glutPostRedisplay();
}
****************************************************************