LIGHTING Crash

I have made a scene with some objets. The first time I display it with color tracking and ligthing enable, it works perfectly. But when I made some transformations like (rotation), the programm crashs and I have a message error that says there has been an exception in OpenGl32.dll. Ok but when I do not use LIGHTNING the programm is able to do the transformations!?

Here is the function that initialize lighting and colour tracking :

void initBodyModel(void)
{
glClearColor(1,1,1,0);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glEnable(GL_DEPTH_TEST);
glColorMaterial(GL_FRONT,GL_DIFFUSE);
glEnable(GL_COLOR_MATERIAL);
}

Do you have GL_NORMALIZE enabled ?? is it possible that your transforms are somehow causing your normals to have zero length, then when OGL attempts to normalize them you get a divide by zero exception ??

one way to check would be to look at the length of the axes described in the rotation matrix.

HTH

actually, the square root would screw up, before we get around to the divide…but whatever, it would break…

Have you set up any attributes for the lighting?
:stuck_out_tongue:

Thanks a lot! It was a scalef problem. Some spheres were too small to draw with lighting enable.