I have a little problem with my program, it gets far to complex, and at the moment i am putting in a new feature, which uses the stencil buffer.
But it seems that i can’t write to the stencil Buffer. I know that my general setup works (pixelformat and so on) because i am doing shadowvolumes with the stencilbuffer, and there it works.
But my rendering code is so complex, that i might oversee something that is just happening inbetween that disables stenciling.
So my Question :
What can lead to disabled stenciling ?
Some side notes. I test the working of the stencilbuffer by writing it out with readpixels and the packed_depth_stencil extension from nvidia. I use a geforce2mx with the 20.81 Drivers. My stencilsettings are:
The stencilfunction is set to always, and it replaces with the ref Value of 128 on pass and fail, only zfail keeps.
Thanks in advance
Are you sure each function you call restore every changed state before it returns? Can be thar one function changes something, but “forgets” to restore it again, which causes the stencil buffer to behave strange.
I am shure that they do not do this, cause some of them shouldn’t for performance reasons. Because of this i would like to which state changes can affect stenciling.
Note that zfail is ignored when there is no depth buffer, or when
the depth buffer is not enabled. In these cases, fail and zpass specify
stencil action when the stencil test fails and passes, respectively.[\QUOTE]
This would be my best guess, that you have disabled depth-testing.
[This message has been edited by DaViper (edited 09-17-2001).]
No, i just disabled z-writing, and i explicitly enable depthtesting before drawing.
I also tested with enebled z-writing, but i only get some z-flickering (i try to make some decals and wana use the stencil to avoid the flickering and to make decals that make a hole where they are) between wall and decal.
Some additional state information. Writing to the colorbuffer is disabled, also alpha blending. Stenciling is enabled of course. Lighting is disabled and the drawn triangles only consist of Vertex-coordiantes and texture-coordiantes.
By the way is there a possibilty to print out the current complete opengl state in a readable form ?
You indirectly solved my problem !
I just looked into my wrapper methods to look if have correctly implemented the zpass situation, cause i couldn’t remember it (and it does not exist :-)) But i found an stupid error, which only occurs when calling my wrapper functions in the wrong sequence.
Sorry that i disturbed you all.
But printing the OpenGL State could be usefull, does anybody know a way to do this ?
Or do i need to check everything by hand ?