Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: Spotlight Texturing

  1. #1
    Junior Member Newbie
    Join Date
    Jun 2002
    Location
    Bolton, United Kingdom
    Posts
    26

    Spotlight Texturing

    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

  2. #2
    Guest

    Re: Spotlight Texturing

    It seems like GL_ONE_MINUS_DST_COLOR is not allowed as the second argument to glBlendFunc. See the man page http://techpubs.sgi.com/library/tpl/cgi-...rch=glBlendFunc

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

  3. #3
    Junior Member Newbie
    Join Date
    Jun 2002
    Location
    Bolton, United Kingdom
    Posts
    26

    Re: Spotlight Texturing

    Zico,

    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.

    Andrew

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •