Original Post
Hi,
I am trying to implement some lighting on an eight sided polygon drawn with OpenGL. I have declared the type of light and how the surfaces react and position in my constructor:
ambientLight[4] = 0.3f, 0.5f, 0.8f, 1.0f;
diffuseLight[4] = 0.25f, 0.25f, 0.25f, 1.0f;
spotLightPosition[4] = -25.0f, 0.0f, -230.0f, 1.0f;
matAmbient[4] = 1.0f, 1.0f, 1.0f, 1.0f;
matDiff[4] = 1.0f, 1.0f, 1.0f, 1.0f;
Next I have an initialise function for the above:
void CNutObsticle::initialize()
{
glClearColor(1.0f, 0.0f, 0.0f, 0.0f);
glShadeModel(GL_SMOOTH);
glEnable(GL_DEPTH_TEST);
glEnable(GL_CULL_FACE);
glFrontFace(GL_CCW);
glEnable(GL_LIGHTING);
glMaterialfv(GL_FRONT, GL_AMBIENT, matAmbient);
glMaterialfv(GL_FRONT, GL_DIFFUSE, matDiff);
glLightfv(GL_LIGHT0, GL_AMBIENT, ambientLight);
glLightfv(GL_LIGHT0, GL_DIFFUSE, ambientLight);
glLightfv(GL_LIGHT0, GL_POSITION, spotLightPosition);
glEnable(GL_LIGHT0);
glDisable(GL_LIGHTING);
}
If anyone has any ideas I would be grateful the code does compile but there is no lighting effect.
Thanks.
I am trying to implement some lighting on an eight sided polygon drawn with OpenGL. I have declared the type of light and how the surfaces react and position in my constructor:
ambientLight[4] = 0.3f, 0.5f, 0.8f, 1.0f;
diffuseLight[4] = 0.25f, 0.25f, 0.25f, 1.0f;
spotLightPosition[4] = -25.0f, 0.0f, -230.0f, 1.0f;
matAmbient[4] = 1.0f, 1.0f, 1.0f, 1.0f;
matDiff[4] = 1.0f, 1.0f, 1.0f, 1.0f;
Next I have an initialise function for the above:
void CNutObsticle::initialize()
{
glClearColor(1.0f, 0.0f, 0.0f, 0.0f);
glShadeModel(GL_SMOOTH);
glEnable(GL_DEPTH_TEST);
glEnable(GL_CULL_FACE);
glFrontFace(GL_CCW);
glEnable(GL_LIGHTING);
glMaterialfv(GL_FRONT, GL_AMBIENT, matAmbient);
glMaterialfv(GL_FRONT, GL_DIFFUSE, matDiff);
glLightfv(GL_LIGHT0, GL_AMBIENT, ambientLight);
glLightfv(GL_LIGHT0, GL_DIFFUSE, ambientLight);
glLightfv(GL_LIGHT0, GL_POSITION, spotLightPosition);
glEnable(GL_LIGHT0);
glDisable(GL_LIGHTING);
}
If anyone has any ideas I would be grateful the code does compile but there is no lighting effect.
Thanks.