How to create a SpotLight?

here is my code, i just want a light beam going up, like a spotlight, i just get lighter or darker colorasions on the whole screen…

void init(void){
glLightf(GL_LIGHT0,GL_SPOT_CUTOFF, 20.0);
glLightfv(GL_LIGHT0, GL_POSITION, rightspotlightpos);
glLightf(GL_LIGHT0, GL_LINEAR_ATTENUATION, 1.0);
glLightfv(GL_LIGHT0, GL_DIFFUSE, rightspotlightdif);
glLightfv(GL_LIGHT0,GL_SPOT_EXPONENT, rightspotlight);

glShadeModel(GL_SMOOTH);
glEnable(GL_COLOR_MATERIAL);
glEnable(GL_LIGHT0);
glEnable(GL_LIGHTING);
}//end init

First of all, does rightspotlightpos have 4 floats? For a spotlight, you need to have the 4th float be 1.0. If it is 0.0 a directional light is created.

Next, you may have to try subdividing your polys. Lighting in OpenGL is calculated per-vertex, so if you have a really big triangle, and the spotlight shines right in the center of that triangle without hitting any of the vertices, you are not going to see any effect.

Finally, lights are affected by the current matrix, so the order that you set light position/direction and matrix transformations does make a difference.

[This message has been edited by Deiussum (edited 04-29-2001).]