Hey... Iam trying to get spot and pointlights working. I had a look at the gl Reference and got this code.
// Is this Matrix stuff needed? I read something about the position coordinates being transformed by the ModelView Matrix?
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
glEnable( GL_LIGHTING );
GLfloat light1_diffuse[] = { 1.0, 0.0, 0.0, 1.0 };
GLfloat light1_position[] = { 278.0, 1282.0, 80.0, 1.0 };
GLfloat light1_dir[] = { 0,0, -1};
glLightfv(GL_LIGHT0, GL_DIFFUSE, light1_diffuse);
glLightfv(GL_LIGHT0, GL_POSITION, light1_position);
glLightf(GL_LIGHT0, GL_SPOT_CUTOFF, 45.0);
glLightfv(GL_LIGHT0, GL_SPOT_DIRECTION, light1_dir);
glLightf(GL_LIGHT0, GL_SPOT_EXPONENT, 2.0);
glShadeModel(GL_SMOOTH);
glLightModelfv(GL_LIGHT_MODEL_AMBIENT,light1_ambient);
glEnable(GL_COLOR_MATERIAL);
glColorMaterial(GL_FRONT,GL_AMBIENT_AND_DIFFUSE);
glEnable( GL_LIGHT0 );
glEnable(GL_COLOR_MATERIAL);
glPopMatrix();
(The code is called once in the initialization of my engine)
The problem is that I cant see any sign of light at the location I passed to the glLight* function. It should be a spot at 278 1282 80 pointing down and leaving a red spot on the ground... At this location, theres nothing. If I go away from the spot to an 'outdoor' area of my map, I can see a very dark red shimmer on the skybox. Thats why I guess the lights position isnt transmitted correctly to gl ... Any ideas?
TIA
[edited by - Dtag on February 1, 2003 3:32:46 AM]
[edited by - Dtag on February 1, 2003 3:33:34 AM]