antoher boring question about lighting...

ok… i started with gl some time ago and now, i’ve got a crazy idea to put some lighting to my code…

so i tried and it won’t work! (what a surprise )… just everything seems to be black and white

i tried to set up ligting using this code (stolen from nehe)

GLfloat LightAmbient[]=  {  0.5f, 0.5f,  0.5f, 0.1f };
GLfloat LightDiffuse[]=  {  1.0f, 1.0f,  1.0f, 0.1f };
GLfloat LightPosition[]= { -10.0f, 0.0f, -3.0f, 1.0f };
GLfloat SceneAmbient[]=  {  0.7f, 0.7f,  0.7f, 0.5f };

glLightfv(GL_LIGHT1, GL_AMBIENT, LightAmbient);
glLightfv(GL_LIGHT1, GL_DIFFUSE, LightDiffuse);
glLightfv(GL_LIGHT1, GL_POSITION, LightPosition);

glLightModelfv(GL_LIGHT_MODEL_AMBIENT, SceneAmbient);


what’s wrong or what’s missing?.. i’m sure normal vectors are good… i’m lost, i need your help…

Have you set material properties? When using lighting, color is based on material properties rather than what you give to glColor. You can use glColorMaterial in order to make glColor change a particular material property, though.

Yup, u r missing some code …

GLfloat mat_ambient[] = { 0.0, 0.0, 0.0, 1.0 };
GLfloat mat_diffuse[] = { 1.0, 1.0, 1.0, 1.0 };
GLfloat mat_specular[] = { 1.0, 1.0, 1.0, 1.0 };
GLfloat mat_shininess = 10.0f;

glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient);
glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse);
glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular);
glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess);

tnx a lot, people… now it’s working well