2
$\begingroup$

I am told that in computer graphics, the screen refreshes in number of times(in this scenario let say that it renders 60 times per second). The screen is cleared and drawn to 60 times per second.

My question is how can I see the Image being shown 60 times per second yet I cannot see the Clear Color which is also being displayed 60 times per second too? Or does this have to do with how our eyes see or how our brain interprets things we see?

$\endgroup$

1 Answer 1

7
$\begingroup$

You're confusing the screen (the physical display) with the framebuffer (the memory which gets read out by the display controller). The framebuffer might get cleared at the start of each frame period, but that doesn't change the display. The order of events is as follows:

  • At the start of a new frame, glClear or equivalent sets the framebuffer to the clear colour.
  • glDraw or equivalent calls draw more stuff on top of the clear colour.
  • eglSwapBuffers or equivalent queues the finished frame to be drawn on the display.
  • When the display is ready, this process is followed. It reads out the contents of the framebuffer and shows them on the physical screen.

The framebuffer that's being drawn into is never shown on the screen; only when it's finished can it be shown. Double- or triple-buffering gives you multiple copies of the framebuffer, so the application can be using one while the display is using the other. It's nothing to do with your eyes or brain.


It's actually a lot more complicated than this, because most GL implementations today are not immediate-mode, so none of the real work happens when you call the functions named above. In fact, clearing the buffer might not even happen at all: if every pixel is drawn to anyway, there's no need to. Back when clearing the framebuffer took significant time, games would go faster by not calling glClear. Today it's more important to call glClear because it lets the implementation know when the start of the new frame is, but it will probably do something smarter than just writing to every pixel.

$\endgroup$
1
  • $\begingroup$ Thanks for the enlightenment! Never thought about it this way. $\endgroup$
    – nightrobin
    Dec 14, 2017 at 15:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.