> >Are you sure your device supports a stencil buffer?
> No, how can I find this out?
You can ask for a pixel format or visual, using wglChoosePixelFormat or
glxChooseVisual, and if NULL comes back, you're out of luck.
> > Are you trying to use more bits than your stencil buffer supports?
> Not sure about this. The stencil buffer bits were set to 8, I tried
> increasing it to 32 but that did not work, how do I know if I am using
> bits than I have supported?
There's a glGet for this, I think it's GL_STENCIL_BITS, look in gl.h or
check the blue book. I don't know of an OpenGL implementation that provides
more than 8 bit deep stencil buffers. You should certainly be able to do
what you want with a single bit; set it to 1 for the floor pixels and leave
it 0 for all the other pixels in your scene. Then simply draw your shadow
where the stencil values are 1.
> >Have you tried writing a small test program to duplicate your problem?
> My application isn't that big so I would consider it a small test program
> now :)
I can envision something even smaller: use an orthographic projection and
draw a triangle with stencil set up to draw 1 bits into the stencil buffer.
Then draw a second overlapping triangle, depth test disabled, with stencil
test set to only draw where the stencil buffer is 1. This is a
straightforward program which should tell you whether your device has some
defect or missing functionality, or your larger program is simply doing
Quote:> Is there a clear and simple explanation of the Stencil Buffer? I am
> it a bit confusing (no pun intended).
:-) Just think of the stencil buffer as providing per-pixel clipping. Once
values are set in the stencil buffer, you can set the stencil function to
either draw or not draw into certain pixels based on their stencil buffer
A quick read of the gStencil*() funcstions in the blue book should provide
sufficient information. The red book provuides some example code and
extended info. The GLUT distribution comes with lots of examples which use
the stencil buffer.
Hewlett Packard Workstation Systems Lab
Remove DONTSPAM to reply