ZBufferState

What is it? What is it used for?



thanks

…a "RTFM" would be good, too. but specifing which "manual" :smiley:

Here you go:



http://msdn.microsoft.com/library/default.asp?url=/library/en-us/opengl/glfunc01_5kkj.asp



ZBuffer state sets how overlapping pixels are handled. I.e. which is rendered, and which is tossed.

“ZBuffer state sets how overlapping pixels are handled. I.e. which is rendered, and which is tossed.”



this that you said is more clear than the link you wrote (that page reports the same words of the JME Api reference ones).



I’d like to have some information about what is overlapping in detail, which function does what? mmm… maybe I could see on NeHe tutorials? Let me see…

A ZBuffer is an actual algorithm. ZBufferState talks to the algorithm. Lookup what a ZBuffer is, why we use one, and what it does. That will make understanding the state much easier.

mmm… maybe my english makes some tricks some times. sorry.



Try with this: which are the visual effects between the functions of the zbuffer? if I choose one instead of another, what will be the difference while seeing it?

imagine drawing a cube… it consists of drawing 6 quads. The order you draw those quads is indeterminate, but to make it look like a cube, you need the quads closer to you to overlap the quads further away.



Each quad you draw sets it’s depth in the depth buffer. When you draw the next quad, you can tell OpenGL to test the depth buffer and decide to draw or not draw based on the test results. So for example, we’d want to use CF_LEQUAL for our cube, meaning the distance from the camera or depth of the thing we are trying to draw is LESS THAN OR EQUAL to what was drawn previously, having the effect of the nearer items covering up the farther items, no matter what order they were drawn in. GEQUAL would of course have the opposite effect and basically make it so it looks like the front of the cube is chopped off and you can look inside.



Not using the depth buffer means you are at the mercy of whatever quad happens to draw first and thus the results can vary as the cube spins or you rotate around it.



Hope that helps!

now it’s quite clear, thank you very much!

I don’t know, whether you’re aware of it, but I suggest the following source of information for newcomers:

http://www.opengl.org/documentation/red_book_1.0/



This may cover some of your questions :slight_smile: