View Full Version : Stencil Buffer Problem

02-19-2003, 06:55 AM
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

Tom Nuydens
02-19-2003, 06:57 AM
Did you remember to request a pixel format with a stencil buffer?

-- Tom

02-19-2003, 07:03 AM
sure =)

- mulat

02-19-2003, 07:55 AM
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.


02-19-2003, 08:28 AM
hmm, i'm using GLUT with GLUT_DOUBLE... and GLUT_STENCIL
reading the stencil buffer using glReadPixels(...) showed something was written.
thx anyway

02-19-2003, 08:43 AM
What does glGetIntegerv(GL_STENCIL_BITS, &val) return?

02-20-2003, 01:31 AM
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

02-20-2003, 01:56 AM
Using the right stencil operations?

02-20-2003, 02:23 AM

02-20-2003, 04:50 AM
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 (http://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