How do you do double buffering in Windows?

Started by
1 comment, last by Red Ant 22 years, 5 months ago
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?
Advertisement
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
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...
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~I'm looking for work

This topic is closed to new replies.

Advertisement