<p>Yes, the back buffer is for the GPU to write the frame that's in-progress, while the display controller sends the front buffer to the attached display. <em>Swapping</em> buffers doesn't really copy anything these days. The display controller has a register which tells it the address of the frame buffer to display. Swapping buffers simply puts the address of the old back buffer in this register, making it the front buffer. You should only swap buffers when the frame is complete (i.e. you've finished drawing all the objects) and you want it to be displayed. This frame will continue to be displayed until you swap buffers again.</p>

<p>In some configurations (e.g. in EGL it depends on what swap interval you set) swapping buffers will make the CPU wait (block) until the GPU has finished rendering that frame. In others, the CPU can continue to queue up draw calls for further frames.</p>

CC BY-SA 3.0
2017-01-16T16:13:36.873Z
"*Swapping buffers doesn't really copy anything these days.*" I wouldn't be too sure. Lots of implementations swap via copy, especially if your application is windowed.
Nicol Bolas
CC BY-SA 3.0
2017-01-16T16:43:50.140Z
@NicolBolas Well OK, if you're going into a compositor, there will probably be a copy *somewhere* along the line. I was more thinking of the case where the output is going into the display controller directly. My point is that OP was thinking that each `eglSwapBuffers` or equivalent is pausing while it copies a bunch of data, but the problem is something completely different.
Dan Hulme
CC BY-SA 3.0
2017-01-16T19:48:21.557Z
You only explained what I already knew.
My question is, Why does my screen slow when I do not swap the buffers?
Adrian
CC BY-SA 3.0
2017-01-16T20:16:31.603Z
Lol I tried my code again and now it doesn't slow down the screen. Anyway, thanks for all.
Adrian
CC BY-SA 3.0
2017-01-16T10:50:19.880Z
2017-01-16T10:50:19.880Z
Dan Hulme
<p>As I understand, the back-buffer is used for rendering the image while the front-buffer is drawn on the screen. So if you have only one image to be drawn on the screen, then you only need to swap the buffers one time because in the second swap the image is already drawn and there is no point to draw the same image again. However, when I tried to swap buffers no more than 2 times the graphics slow down a lot and move the window from one position to another takes 10-20 seconds. My question is... Why?
How double-buffers works then?</p>

<opengl><buffers>
How do double-buffers work in opengl?
Adrian
# How do double-buffers work in opengl?

(Asked by: username_0 on 2017-01-15)

As I understand, the back-buffer is used for rendering the image while the front-buffer is drawn on the screen. So if you have only one image to be drawn on the screen, then you only need to swap the buffers one time because in the second swap the image is already drawn and there is no point to draw the same image again. However, when I tried to swap buffers no more than 2 times the graphics slow down a lot and move the window from one position to another takes 10-20 seconds. My question is... Why?
How double-buffers works then?

**Tags:** opengl, buffers


---

## 1 answers

### Answer by username_1 on 2017-01-16. Score: 6 | Accepted answer

Yes, the back buffer is for the GPU to write the frame that's in-progress, while the display controller sends the front buffer to the attached display. *Swapping* buffers doesn't really copy anything these days. The display controller has a register which tells it the address of the frame buffer to display. Swapping buffers simply puts the address of the old back buffer in this register, making it the front buffer. You should only swap buffers when the frame is complete (i.e. you've finished drawing all the objects) and you want it to be displayed. This frame will continue to be displayed until you swap buffers again.

In some configurations (e.g. in EGL it depends on what swap interval you set) swapping buffers will make the CPU wait (block) until the GPU has finished rendering that frame. In others, the CPU can continue to queue up draw calls for further frames.

> **Comments:**
> **username_2**: "*Swapping buffers doesn't really copy anything these days.*" I wouldn't be too sure. Lots of implementations swap via copy, especially if your application is windowed.  
> **username_1**: @username_2 Well OK, if you're going into a compositor, there will probably be a copy *somewhere* along the line. I was more thinking of the case where the output is going into the display controller directly. My point is that OP was thinking that each `eglSwapBuffers` or equivalent is pausing while it copies a bunch of data, but the problem is something completely different.  
> **username_0**: You only explained what I already knew. My question is, Why does my screen slow when I do not swap the buffers?  
> **username_0**: Lol I tried my code again and now it doesn't slow down the screen. Anyway, thanks for all.  

---

