Part of the Khronos Group

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: Shadows

  1. #1
    Junior Member Newbie
    Join Date
    Nov 2000


    I am trying to learn how to do shadows in opengl and having been looking at scube.c found at http://www.sgi/com/software/opengl/glut/examples. In the code to produce the shadow are the lines...

    myShadowMatrix(groundPlane, lightPos);
    glTranslatef(0.0, 0.0, 2.0);
    glMultMatrixf((const GLfloat *) cubeXform);

    My question is "Why is
    glTranslatef(0.0, 0.0, 2.0);
    I know that it isn't called then the shadow does not appear in the correct place. But it seems like to magic to me. I understand what myShadowmatrix does and what the glMultMatrix call does but the translation escapes me entirely. Please help!

  2. #2
    Intern Newbie
    Join Date
    Apr 2000

    Re: Shadows

    the link didn't work for me (and i'm new to opengl) but the logical reason i see for the translate along the z axis is:
    you're probably facing the face you're drawing the shadow plane to. the translation would move the shadow face above the object 2 units above the geometry plane.
    (i really don't know though, and i'm sure there are many others on this forum that could reply more intellegently than i)


  3. #3
    Senior Member OpenGL Pro
    Join Date
    May 2000
    Hannover, Germany

    Re: Shadows

    That would be correct, if a face offset would have the same result. Or, try to set depth test mode to GL_EQUAL and comment that line out. If it's just so simple, both ways will produce the same as the translate does.

Posting Permissions

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