Why do we have to clear depth buffer in OpenGL during rendering?
问题 I was trying to run an OpenGL code, it didn't have GL_DEPTH_BUFFER_BIT cleared in glClear(), because of which I couldn't render my scene. I added this bit, and the scene was rendered. Why is it necessary to use this clear bit? I may know the reason for this, to clear the depth buffers values used by GPU previously, but i just want to confirm. 回答1: The Depth Buffer holds the "depth" of the pixel in the scene. When OpenGL renders your geometry, each fragment (pixel) is compared against the