Spotlight Texturing

I need to simulate a projected spotlight beam on a floor plane … I’ve got a texture tiled plane and I blend a spotlight texture on to it … neither texture has an associated alpha channel but I found that the code snippet below worked fine …

glNewList(fGenList, GL_COMPILE);
glColor3ub(80, 80, 80);

glBindTexture(GL_TEXTURE_2D, GLTextures[cSpotLight]);
glNormal3f(0.0, 1.0, 0.0);
glTexCoord2f(0.0, 0.0); glVertex3f(-100.0, -17.0, -100.0);
glTexCoord2f(0.0, 1.0); glVertex3f(-100.0, -17.0, 100.0);
glTexCoord2f(1.0, 1.0); glVertex3f( 100.0, -17.0, 100.0);
glTexCoord2f(1.0, 0.0); glVertex3f( 100.0, -17.0, -100.0);

glBindTexture(GL_TEXTURE_2D, GLTextures[cCarpet]);
glNormal3f( 0.0, 1.0, 0.0);
glTexCoord2f( 0.0, 0.0); glVertex3f(-100.0, -17.0, -100.0);
glTexCoord2f( 0.0, 20.0); glVertex3f(-100.0, -17.0, 100.0);
glTexCoord2f(20.0, 20.0); glVertex3f( 100.0, -17.0, 100.0);
glTexCoord2f(20.0, 0.0); glVertex3f( 100.0, -17.0, -100.0);

(Delphi - so please don’t tell me that the closing bracket syntax is wrong !)

But … here’s a lesson to all … The code only works on my GeForce2 … other cards … well, the ‘blue screen’ of death was all that happened ! Reason … it seems to be caused by the glBlendFunc setting that uses GL_DST_COLOR …

So how do I do this thing properly ? Is there an easy way of doing it without alpha or is there a way of emulating the needed alpha from the spotlight texture ? Or how do I do it using alpha ?

And … my tip … disable hardware acceleration from time to time to see how compatible your project is … I found that I was also binding textures after a gLBegin … my driver / card didn’t object … others did by crashing !!!

Many thanks


It seems like GL_ONE_MINUS_DST_COLOR is not allowed as the second argument to glBlendFunc. See the man page…rch=glBlendFunc

NVidia has a presentation about projective textures for among other things spotlight effects with examples .


Many thanks … just call me stupid ! I’ve always had problems glBlend and I usually resort to trial and error until it does what I want … I forgot that src and dst do not have common parameter settings.