Search code examples
iphonedepth-bufferopengl-es-2.0

Why do you need the depth buffer?


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.


Solution

  • 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.