سؤال

I don't understand why I need to use depth buffer, because in this project cube draws without depth buffer.

Sorry for my bad English. I'm russian and started to learn English 1.5 years ago.

هل كانت مفيدة؟

المحلول

When doing simple rendering where it's easy to determine which surfaces occlude others, for instance, just by depth sorting the surfaces, then the depth buffer is an unnecessary burden. In more realistic rendering scenarios, particularly when surfaces can intersect, no amount of depth sorting will produce correct results. the depth buffer allows you to draw surfaces in any order, and preserves only the rendering that is closest to the screen. This can actually improve performance for non-trivial scenes.

نصائح أخرى

Not iPhone related, but a depth buffer (or z-buffer) will allow drawing the faces in any order and still have them rendered correctly.

Read some tutorials about it (use Google), images will illustrate better. See this tutorial for instance.

Depth Buffer enabled Depth Buffer enabled

Depth Buffer disabled Depth Buffer disabled

That project above is full of hacks, unfortunately - had me confused as well.

If you want 3D, use a depth buffer, enable depth testing, and don't do front face culling like in that cube example.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top