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).
Multiple implementations exists on swapbuffers(), typical one is that 2 buffers are used, and a pointer indicates which one is currently in use for drawing (the other is being displayed on screen).
buffer A
buffer B
So no wonder it is flickering, you do :
draw some data… to buffer A
swapbuffer()
draw another data… to buffer B
swapbuffer()
etc.
In general, you should assume that buffer content is undefined after each 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).
Not sure this is really what you need. Why no draw them all, in the wanted order ? Can you explain more precisely ?
I found your other posts talking about drawing partial rendering : in this case, simply call glDrawBuffer(GL_FRONT_BUFFER) then draw your stuff, and call glFinish() after each layer.
I tried the glDrawBuffer(GL_FRONT) method but the window was still flickering.
the reason of the data contains many layers and i do not draw them all once is that, my data was made up of many different types such as 3d building , 3d roads ,3d pipes ,etc. draw them all once will cost about 400 ms(maybe more than 1 s ) , so i must draw them layer by layer and shows the dynamic rendering process.