OpenGL lighting with glOrtho

So, I have a 3D object that I draw with the following light:

    GLfloat light_diffuse[] = {1.0, 1.0, 1.0, 0.9};  /* White light. */
GLfloat light_position[] = {300.0, 300.0, 300.0, 0.0};  
glShadeModel(GL_SMOOTH);
glEnable(GL_COLOR_MATERIAL);
glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse);
glLightfv(GL_LIGHT0, GL_POSITION, light_position);
glEnable(GL_LIGHT0);
glEnable(GL_LIGHTING);

My object is highlighted, as I expect it, when I draw it in a "normal" context (i.e. no glOrtho).

However, I work on orthogonal projections of the object and use glOrtho for this purpose (on the ModelView matrix). I initialize the light after calling glOrtho, then draw the object in exactly the same way as when it worked (three-dimensional case). But for some reason, lighting does not work on orthogonal projections, i.e. When I made a call to glOrtho.

This is not a problem with normals, since it works in the three-dimensional case. I assume that with the glOrtho call, everything is compressed on a thin layer, which explains why the light does not behave as expected ... but, frankly, I do not experience lighting, so this may be wrong.

Does anyone know what is going on?

+3
source share
1 answer

Lighting occurs in the space of the eyes, that is, before the projection is applied at all. You are probably using transformation matrices incorrectly. glOrtho, glFrustung or gluPerspective are included in the GL_PROJECTION matrix, gluLookAt and other materials for placing the camera are included in GL_MODELVIEW.

+1
source

All Articles