In Review
Prev | Chapter 5. Objects in Depth | Next

## In Review

In this tutorial, you have learned about the following:

- Vertex array objects encapsulate all of the state necessary to render objects. This includes vertex attribute arrays, buffer objects to feed those arrays, and the element buffer, if present.

- Indexed rendering pulls data from the current vertex arrays by using a separate sequence of indices. The sequence of indices defines the sequence that OpenGL sees the vertices in. Indexed rendering can be performed by storing index data in a buffer object, and using `glDrawElements`.

- Indices in indexed rendering calls can be offset by a value using the `glDrawElementsBaseVertex` function.

- Hidden surface elimination can be performed by using a depth buffer and properly setting up the depth test.

- Triangles that are outside of the camera zNear and zFar range are clipped against this range. This can open up holes in models if they are too close to the camera.

- Clipping holes can be repaired to a degree by activating depth clamping, so long as there is no overlap. And as long as the triangles do not extend beyond 0 in camera space.

### OpenGL Functions of Note

glGenVertexArrays/glDeleteVertexArrays

  Creates/destroys one or more vertex array objects.

glBindVertexArray

  Binds a vertex array object to the `GL_VERTEX_ARRAY` target.

glDrawElements

  Performs indexed rendering with the currently bound `GL_ELEMENT_ARRAY_BUFFER` (provided via the VAO) and the current attribute arrays.

glDrawElementsBaseVertex

  Performs indexed rendering as `glDrawElements`, except that each element index is offset by a constant value before performing the array lookup. This is useful for minimizing the number of buffer object binds performed in a program.

glEnable/glDisable(GL_DEPTH_TEST)

  Enables/disables the per-fragment depth test. If the depth test is enabled, then the result of applying the depth function, set by `glDepthFunc`, to the incoming fragment's depth and the destination pixel's depth will determine if the incoming fragment is written or not.

glDepthMask

  Sets or unsets the writing of values to the depth buffer.

glDepthFunc

  Sets the depth comparison function for depth testing. Has no effect if `GL_DEPTH_TEST` is not enabled.

glDepthRange

  Sets the mapping between NDC space and window space for the Z coordinate of the position. The XY counterpart to this function is `glViewport`. The range for the window-space depth must be [0, 1], though the near does not have to be less than the far. The range zNear value, the first value, is the window-space value that will map to -1 in NDC space. The range zFar is the window-space value that maps to +1 in NDC space.

glClearDepth

  Sets the clear depth value. This is the value that the depth buffer will be cleared to when calling `glClear` with the `GL_DEPTH_BUFFER_BIT` bit set.

glEnable/glDisable(GL_DEPTH_CLAMP)

  Enables/disables depth clamping behavior. When enabled, clipping is deactivated, and any fragments that an object would render that are outside of the [-1, 1] range in NDC space are clamped to this range.

Prev | Up | Next
Depth Clamping | Home | Glossary