PDA

View Full Version : Stencil Buffer Problem



mulat
02-19-2003, 07: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, 07:57 AM
Did you remember to request a pixel format with a stencil buffer?

-- Tom

mulat
02-19-2003, 08:03 AM
sure =)


- mulat

SirKnight
02-19-2003, 08: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.

-SirKnight

mulat
02-19-2003, 09: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

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

mulat
02-20-2003, 02: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

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

kon
02-20-2003, 03:23 AM
glEnable(GL_STENCIL_TEST);?

mulat
02-20-2003, 05: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