Stencil Buffer Problem

Hi there,
i’m currently playing with Stencil Shadows. So far it works fine, if i render my shadow volume to the screen it looks right.
if i render it to the stencil buffer and render the stencil buffer nothing happens.
Although i’m quite sure the stencil setup is ok. Even if i’m writing to the stencil buffer directly via glDrawPixels nothing happens
Any ideas?

thx, andi

Did you remember to request a pixel format with a stencil buffer?

– Tom

sure =)

  • mulat

Yeah at one time I had this problem when I wrote my first shadow volume program demo. I was sure I requested 8 bits of stencil. I just KNEW I was doing so. Well turns out I really WASN’T! My OpenGL framework class was broken and I wasn’t aware of it. So make certain you are requesting 8 stencil bits. Also check and make sure you really are getting the pixel format you are requesting. If all that is ok, then there must be a problem with your stencil funcs somewhere.

-SirKnight

hmm, i’m using GLUT with GLUT_DOUBLE… and GLUT_STENCIL
reading the stencil buffer using glReadPixels(…) showed something was written.
thx anyway

What does glGetIntegerv(GL_STENCIL_BITS, &val) return?

hi. i get 8 bit for the stencil buffer.
so : if i render my shadow volume and it looks right, and i can see it, and it is cutting other objects : so my geometry is right?

– mulat

Using the right stencil operations?

glEnable(GL_STENCIL_TEST);?

hi again.
so, now stecil buffer works. but i still have problems with the shadows =)
(here’s a pic: www.code-guru.de/pics/debug_shot.jpg )
it looks like the light if moving if i rotate the object, although i’m reversing the rotate-calls before calculation light position in world space (via light_obj_pos * MODELVIEW_MATRIX )

– mulat