Hello.Please tell me why doestn’t lighting work when depth test is enabled.Or, if it is working , why doesn’t my program show my illuminated sphere until i delete the enable depth test command.Thank you for your help.
How can you imagine that we could help you with such a poor information?! Please, learn how to ask question and expose your problem. As Satan (not related to the evil) once suggest, check this out.
Ok.here the code from my application:
static GLfloat unghi=0.0,x=1.0f,z=0.0f;
glClear(GL_COLOR_BUFFER_BIT); glColor3ub(255,0,0); glPushMatrix(); glutWireCube(1.6); gluLookAt(x,0.0,z,0.0,0.0,0.0,0.0,1.0,0.0); glutSolidCube(1.6); glPopMatrix(); glutSwapBuffers();
glEnable(GL_COLOR_MATERIAL); glColorMaterial(GL_FRONT,GL_AMBIENT_AND_DIFFUSE); glClearColor(0.0f,0.0f,0.0f,1.0f);
void ChangeSize(GLsizei w,GLsizei h)
glViewport(0,0,w,h); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glFrustum(-1.0,1.0,-1.0,1.0,1.5,20.0); glMatrixMode(GL_MODELVIEW); glLoadIdentity();
void Timp(int value)
int main(int argc,char* argv)
glutMainLoop(); return 0;
if I run the above code, the application works perfectly,but if I turn on depth testing it doesn’t show anything.What is the reason?
try replacing glClear(GL_COLOR_BUFFER_BIT) with glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);