PDA

View Full Version : Incorrect Stencil Buffer Data



jlewis
04-09-2002, 09:13 AM
I am having problems with using the stencil buffer. It appears the stencil buffer data is getting corrupted. I am using the stencil buffer to cap models when the viewing volume near plane clips models. When rendering the model, I use glStencilFunc(GL_ALWAYS, 0x1, 0x1) and glStencilOp(GL_KEEP, GL_INVERT, GL_INVERT). I then render a large polygon to cover the viewport using glStencilFunc(GL_EQUAL, 0x1, 0x1). The capping works great when I render with only three drawing areas in the application. When I go to four OpenGL drawing areas, the stencil buffer does not work properly on the fourth drawing area. I get a scattering of pixels covering the silhouette area of the model.

Background on Configuration:
Linux Red Hat 7.1 Operating System
NVIDIA GeForce4 MX 440
1280 x 1042 video resolution
Using double buffering
Using depth buffer; requesting 24 bit depth
Using stencil buffer; requesting 8 bit depth

I have tried placing various calls to glFinish() and glFlush(), and I have tried playing with the stencil reference value and mask value. Please help.
__________________
Jeffery Lewis
Senior Software Engineer
Integrated Surgical Systems
Davis, California, USA

04-10-2002, 08:55 AM
It can of course be a driver bug but rendering close to the near clipping plane is tricky. Do you draw the large polygon a little into the scene and without depth testing? Two other things to double check is that the stencil buffer is cleared and that the model is not clipped by the far clipping plane. Does the scene look like expected if you do not draw the large polygon?

If it still does not work should I use a clip plane that is a little ahead of the near clip plane.

jlewis
04-10-2002, 11:51 AM
It has nothing to do with things like the viewing volume or depth testing. The reason I know this is because I can get proper rendering in a different drawing area. If I render the same thing on four drawing areas, the fourth drawing area has the problem even thougth the rendering execution is identical. I am convinced it is not my code and I am looking to NVIDIA, or anyone with a good idea, to help with a workaround.

Jeffery Lewis
Senior Software Engineer
Integrated Surgical Systems
Davis, California, USA

Anton
05-03-2002, 03:40 AM
Hi,

This may be obvious, and you might already be handling it correctly, but are you switching to the correct glxContext for each
drawable? Certainly in GTK apps it is easy to forget to make the relevant glxContext current in a callback function...

BFN,

Anton


Originally posted by jlewis:
It has nothing to do with things like the viewing volume or depth testing. The reason I know this is because I can get proper rendering in a different drawing area. If I render the same thing on four drawing areas, the fourth drawing area has the problem even thougth the rendering execution is identical. I am convinced it is not my code and I am looking to NVIDIA, or anyone with a good idea, to help with a workaround.

Jeffery Lewis
Senior Software Engineer
Integrated Surgical Systems
Davis, California, USA

jlewis
05-03-2002, 05:59 AM
I am using the same GLXContext in all drawables. What is interesting is the order of rendering can affect which drawable the stencil buffer problem occurs. If say I render in drawables 1, 2, 3, and 4, the problem occurs in drawable 4. If I change the order to 1, 2, 4, and 3, the problem occurs in drawable 3. All drawables can have the exact same rendering execution code.

Jeffery Lewis

suzyq
05-07-2002, 01:43 PM
Jeffery-
Made any progress on this?

Does everything work if you disable your stencil code? Have you tried other cards?