Clearing Buffers

Probably the most common graphics activity after rendering is clearing buffers. You will probably do it once per frame (at least), and as such, OpenGL tries to optimize that operation by clearing all of the active buffers at the same time. As you’ve seen in our examples, we set the value that each type of buffer should be initialized to in init() (if we don’t use the default values), and then clear all the buffers we need.

The following commands set the clearing values for each buffer:

Get OpenGL Programming Guide: The Official Guide to Learning OpenGL, Version 4.3, Eighth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.