I got a question..Swapping Buffers

The next line shows what's going on.



//swap the buffers

display.getRenderer().displayBackBuffer();



Normally you paint everyhting into the backbuffer and when you are done you grab that buffer and dump it on the screen.

Search for doublebuffer to find out more about it.


Surely that means the offscreen buffer is dumped to the onscreen buffer, it displays the back (hidden) buffer?

Jup

Whats happening differently here then?

it's not "dumped" into the onscreen buffer…  the pointer to which buffer is fore and which is back is swapped.  Thus the comment.

To answer your question in regards to purpose…



In just about every game double (or triple) buffering is used:

The purpose of the backbuffer is basically to provide a place for the renderer to do its dirty work in the short period of time the user is looking at an already-drawn frame, then swaps the backbuffer to be displayed on the screen.  This is to prevent certain artifacts that could be seen by the user while drawing directly to the display, as well as flickering and tearing.  For instance, the user will see an animation you have created in the same way any media is viewed: precreated frames that are swapped in between, except in this case we're doing the creation as we go along.



Maybe a bad example, I don't know.  It's late and I need to sleep.  Couldn't help but ramble.