spotlight effect

Hi, I’m trying to create a spotlight in my openGL program.

Basically its a cube world that goes from
X range = -50 , 50 {ie 100 units wide}
Y range = -20 , 20 {ie 40 units high}
Z range = 0, -100 {100 units deep}

I’m trying to get a spotlight to shine on the wall on the right side.


GLfloat dirVector0[]={ 1.0, 0.0, 0.0, 1.0};
GLfloat lightPos0[]={ 0.0, 0.0, -30.0, 1.0};
GLfloat ambientLight0[] = {2.2f, 2.2f, 2.2f, 1.0f};
GLfloat diffuseLight0[] = {1.0f, 1.0f, 1.0f, 1.0f};

glLightfv(GL_LIGHT0, GL_AMBIENT, ambientLight0);
glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuseLight0);

glLightfv(GL_LIGHT0, GL_POSITION, lightPos0);
glLightf(GL_LIGHT0, GL_SPOT_CUTOFF, 30.0);
glLightfv(GL_LIGHT0, GL_SPOT_DIRECTION, dirVector0);


Now this gives unbelievable results:
I lights up the right side of the world, making the right wall the brightest. It looks nothing like a spotlight effect

If you change the 30.0 to anything below 25, you get no light at all.
And in the dirVector0, if you change it to anything other than the X axis, it doesn’t work.

Anybody have any ideas?

Is your cube model highly tesselated? OpenGL lighting is done per-vertex, so you need a lot of polygons for it to look like a real spotlight.