spot light question

I’ve been trying to work this code from the red book on a cube…
but I cant seem to see any spotlight happening…
can someone help me please! thank you

///
GLfloat light1_ambient[] = { 0.2, 0.2, 0.2, 1.0 };
GLfloat light1_diffuse[] = { 1.0, 1.0, 1.0, 1.0 };
GLfloat light1_specular[] = { 1.0, 1.0, 1.0, 1.0 };
GLfloat light1_position[] = { -2.0, 2.0, 1.0, 1.0 };
GLfloat spot_direction[] = { -1.0, -1.0, 0.0 };

glLightfv(GL_LIGHT1, GL_AMBIENT, light1_ambient);
glLightfv(GL_LIGHT1, GL_DIFFUSE, light1_diffuse);
glLightfv(GL_LIGHT1, GL_SPECULAR, light1_specular);
glLightfv(GL_LIGHT1, GL_POSITION, light1_position);
glLightf(GL_LIGHT1, GL_CONSTANT_ATTENUATION, 1.5);
glLightf(GL_LIGHT1, GL_LINEAR_ATTENUATION, 0.5);
glLightf(GL_LIGHT1, GL_QUADRATIC_ATTENUATION, 0.2);

glLightf(GL_LIGHT1, GL_SPOT_CUTOFF, 45.0);
glLightfv(GL_LIGHT1, GL_SPOT_DIRECTION, spot_direction);
glLightf(GL_LIGHT1, GL_SPOT_EXPONENT, 2.0);

glEnable(GL_LIGHT1);

///

I see you enable the light itself, but not the lighting system.

glEnable(GL_LIGHTING);

When you use lights, you only change the color of vertices, not polygon (color of polygon is interpolated {or not} color of vertices). You will never see spot-light on polygon that has too little vertices. Maybe that is your problem. If not, surely the answer above is helpful.

Please see issue 2 in this guide from the front page:

Pitfalls

Roffe came with ultimate aswer to all basic questions :slight_smile: - doc about avoiding pitfalls. Read it all- section mentioned by Roffe is that what I wrote above, but written in better english :slight_smile: .