<blockquote>
  <p>If you swap buffers, you have a triangle in your screen and a empty color buffer in the other side.</p>
</blockquote>

<p>No, you do not. Buffer swapping does not necessarily mean that the current contents of the front buffer are preserved. When you do a swap, the contents of the back buffer become the front buffer, but the state of the back buffer is <em>undefined</em> after the swap.</p>

<p>Some implementations use a true swap, where the two buffers really are switched. Other implementations copy the data from the back buffer on a swap, leaving the back buffer as whatever was there before. Still others could do something else.</p>

CC BY-SA 3.0
2017-03-19T20:32:25.210Z
2017-03-19T20:32:25.210Z
Nicol Bolas
<p>If you clear the color buffer and draw a triangle, you have nothing in the buffer that is shown in the screen and a triangle in the other buffer, so you have to swap buffers to show the triangle. If you swap buffers, you have a triangle in your screen and a empty color buffer in the other side. If you swap buffers again you should see and empty screen because you changed the buffer with the triangle by the other empty buffer. Instead of this, the triangle is shown again. Why?</p>

<opengl><c++>
Swap buffers twice does not show the first scene
Adrian
# Swap buffers twice does not show the first scene

(Asked by: username_0 on 2017-03-19)

If you clear the color buffer and draw a triangle, you have nothing in the buffer that is shown in the screen and a triangle in the other buffer, so you have to swap buffers to show the triangle. If you swap buffers, you have a triangle in your screen and a empty color buffer in the other side. If you swap buffers again you should see and empty screen because you changed the buffer with the triangle by the other empty buffer. Instead of this, the triangle is shown again. Why?

**Tags:** opengl, c++


---

## 1 answers

### Answer by username_1 on 2017-03-19. Score: 5 | Accepted answer

> If you swap buffers, you have a triangle in your screen and a empty color buffer in the other side.

No, you do not. Buffer swapping does not necessarily mean that the current contents of the front buffer are preserved. When you do a swap, the contents of the back buffer become the front buffer, but the state of the back buffer is *undefined* after the swap.

Some implementations use a true swap, where the two buffers really are switched. Other implementations copy the data from the back buffer on a swap, leaving the back buffer as whatever was there before. Still others could do something else.


---

