OpenGL - yszheda/wiki GitHub Wiki

Depth

Prevent Z-fighting

  • The first and most important trick is never place objects too close to each other in a way that some of their triangles closely overlap.

  • A second trick is to set the near plane as far as possible.

  • Another great trick at the cost of some performance is to use a higher precision depth buffer.

  • https://open.gl/depthstencils

The depth buffer can be cleared along with the color buffer by extending the glClear call:

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

The default clear value for the depth is 1.0f, which is equal to the depth of your far clipping plane and thus the furthest depth that can be represented. All fragments will be closer than that, so they will no longer be discarded.

Face Culling

Trouble-shooting

glGenBuffers segfault

without opening window