Im trying to incorporate lighting into my code using the methods from the filtering and lighting tutorial. Im almost 100% ive got evrything set up properly, and i cant get the lighting to work at all!
I want the lighting to be enabled by default so here is my init function:
int InitGL(GLvoid) // All Setup For OpenGL Goes Here
{
if (!LoadGLTextures()) // Jump To Texture Loading Routine ( NEW )
{
return FALSE; // If Texture Didn''t Load Return FALSE
}
glEnable(GL_TEXTURE_2D); // Enable Texture Mapping ( NEW )
glShadeModel(GL_SMOOTH); // Enable Smooth Shading
glClearColor(0.0f, 0.0f, 0.0f, 0.5f); // Black Background
glClearDepth(1.0f); // Depth Buffer Setup
glEnable(GL_DEPTH_TEST); // Enables Depth Testing
glDepthFunc(GL_LEQUAL); // The Type Of Depth Testing To Do
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); // Really Nice Perspective Calculations
return TRUE; // Initialization Went OK
// SET UP LIGHTING
glLightfv(GL_LIGHT1, GL_AMBIENT, LightAmbient);
glLightfv(GL_LIGHT1, GL_DIFFUSE, LightDiffuse);
glLightfv(GL_LIGHT1, GL_POSITION, LightPosition);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT1);
}
Does it matter where glEnable(GL_LIGHTING); is called? i tried moving it to the render function but then i got no light at all. Im using the same values for lighting as in the filtering tutorial:
// LIGHTING
GLfloat LightDiffuse[] = { 1.0f, 1.0f, 1.0f, 1.0f }; // Direct Light
GLfloat LightAmbient[] = { 0.5f, 0.5f, 0.5f, 1.0f }; // Fill Ligh
GLfloat LightPosition[] = { 0.0f, 0.0f, 2.0f, 1.0f }; // Position