Results 1 to 3 of 3

Thread: Spotlight Texturing

  1. #1
    Junior Member Newbie
    Join Date
    Feb 2000
    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
    Feb 2000
    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

Similar Threads

  1. spotLight
    By franciscoBiaso in forum OpenGL: GLSL
    Replies: 7
    Last Post: 01-20-2012, 04:09 PM
  2. Spotlight with Texture
    By matdi in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 11-08-2010, 06:13 AM
  3. SpotLight
    By MACnus in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 02-14-2005, 08:50 AM
  4. Spotlight troubles
    By dpgraves in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 02-22-2002, 10:45 PM
  5. can't get spotlight to work
    By dante in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 07-06-2001, 09:37 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean