PDA

View Full Version : doublebuffer cause flickering prolbem



captainxyz
04-02-2006, 12:47 AM
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

Trahern
04-02-2006, 03:42 AM
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

Dirk
04-02-2006, 04:01 PM
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()


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.


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).


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