AndrewJJ
06-14-2002, 01:04 AM
Hi,
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]);
glBegin(GL_QUADS);
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);
glEnd;
glEnable(GL_BLEND);
glBlendFunc(GL_DST_COLOR, GL_ONE_MINUS_DST_COLOR);
glDepthFunc(GL_EQUAL);
glBindTexture(GL_TEXTURE_2D, GLTextures[cCarpet]);
glBegin(GL_QUADS);
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);
glEnd;
glDepthFunc(GL_LESS);
glDisable(GL_BLEND);
glEndList;
(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
Andrew
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]);
glBegin(GL_QUADS);
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);
glEnd;
glEnable(GL_BLEND);
glBlendFunc(GL_DST_COLOR, GL_ONE_MINUS_DST_COLOR);
glDepthFunc(GL_EQUAL);
glBindTexture(GL_TEXTURE_2D, GLTextures[cCarpet]);
glBegin(GL_QUADS);
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);
glEnd;
glDepthFunc(GL_LESS);
glDisable(GL_BLEND);
glEndList;
(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
Andrew