For example, if I have several figures rendered over a black background, is it more efficient to call glClear(GL_COLOR_BUFFER_BIT) each frame, or render black triangles over artifacts from the past frame? Answers pertaining to other versions of OpenGL are also greatly appreciated.

  • 1
    \$\begingroup\$ I would expect glClear to be faster, but you'd have to profile to be sure. \$\endgroup\$ Commented Nov 3, 2017 at 21:08
  • \$\begingroup\$ wouldn't you need to glClear the depth buffer to draw ontop of existing stuff? \$\endgroup\$
    – Jimmy
    Commented Nov 3, 2017 at 21:39
  • \$\begingroup\$ @Jimmy: Depends whether or not the OP is drawing with depth testing enabled. A simple 2D game might not even use a depth buffer. \$\endgroup\$ Commented Jan 8, 2018 at 10:09

1 Answer 1


It depends

  • Sometimes glClear can be a signal to the driver and/or GPU that you're done with the prior contents of the framebuffer, which it can then use to optimize internally.

  • Sometimes glClear needs to touch every pixel in the framebuffer whereas drawing a handful of primitives doesn't.

  • Sometimes you're overdrawing the entire color buffer each frame anyway so it might be worth skipping the clear.

  • Sometimes your GPU is a tile-based deferred architecture which may operate more efficiently if you clear every frame.

  • Sometimes your driver or GPU may have a fast path for glClear which may be the equivalent of just swapping a couple of pointers.

  • Sometimes other factors may apply.

In other words, the particular workload you're doing or the GL version you're targetting aren't the only factors that can affect this. In general terms, using the API the way it was designed to be used will be preferable to tricksy stuff, but that's not always the case and exceptions always exist.

Fortunately both options are utterly trivial to code, so you should code both and benchmark them on your own target platform(s).


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .