doublebuffer cause flickering prolbem

Hi,

i use doublebuffer mode to display data(swapbuffer),but the window become flickering. i guess the reason of flickering is that i used the swapbuffer command more than once,codes as following:

draw some data…
swapbuffer()

draw another data…
swapbuffer()
if i only use the swapbuffers command once,the window is not flickering anymore, codes as following:

draw some data…
draw another data…
swapbuffer()

but my data is made of many layers(just like CAD layers),i want to display them layer by layer,so i used the swapbuffer commands more than once(i have to).

anybody can help me ? Thanks

Captain Wens

make sure you have WGL_SWAP_COPY_ARB ( no EXCHANGE ) in your pixel format ( if you are on windows ). In exchange mode the two buffers are simply switched. In copy mode you always draw to the back-buffer and during the swapBuffer command the back-buffer is copied to the front-buffer.

Also make sure you are not clearing your framebuffer when you are drawing additional data

1 Like

[b] Hi,

i use doublebuffer mode to display data(swapbuffer),but the window become flickering. i guess the reason of flickering is that i used the swapbuffer command more than once,codes as following:

draw some data…
swapbuffer()
[/b]

At this point the contents of the backbuffer are undefined. Swap really means swap, not copy. If you want to copy you’ll have to copy the data explicitly from back to front (see glReadBuffer, glDrawBuffer and glCopyPixels for details).


draw another data…
swapbuffer()

This draws unto an undefined (probably empty) buffer, so the old data is not there.

[b]
if i only use the swapbuffers command once,the window is not flickering anymore, codes as following:

draw some data…
draw another data…
swapbuffer()

but my data is made of many layers(just like CAD layers),i want to display them layer by layer,so i used the swapbuffer commands more than once(i have to).
[/b]

Swapbuffers just does not do what you want to do. You can either use glCopyPixels or draw into a texture (FBO) and copy it to the screens after you’ve finished a layer.

Hope it helps