Archived

This topic is now archived and is closed to further replies.

Red Ant

How do you do double buffering in Windows?

Recommended Posts

Red Ant    471
When I scroll through my windows application, the writing gets kinda f***up. I did an OpenGl console application a while ago ad I seem to recall that the solution to this was double buffering. But how do you do that in Windows?

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
Turn Auto-Redraw on. This saves the data that is drawn in your window to a "back-buffer" (aka memory) and will redraw it whenever it needs too (like when it scrolls, resizes, etc).

Billy

Share this post


Link to post
Share on other sites
JOL    160
The idea of Double buffering is like this...
You draw everything to a offscreen image - could be a DXsurface a array[w][h] or a windows GraphicsDevice.
then you draw this buffer on your screen - this will have the effect of drawing everything simultaneously and you avoid flickering.
(It also has some advantages when it comes to waiting on the vertical retrace on your monitor to avoid ''snow''. ( right-like you''d need that with DX )

It is hard to answer your question without knowing how you draw your graphics... I guess it is WIN32 !?! - then use functions like - (sort of pseudocode) .

HDC memDC = CreateCompatibleDC(...); // backbuffer
Ellipse(memDC, 0, 0, 100, 100); // draw
BitBlt(realDC, ..., memDC ,...); // draw Bbuffer on screen

-! if you need scrolling you can draw on a third bigger buffer and just draw the right part to the backbuffer...

Share this post


Link to post
Share on other sites