Win32 Double Buffering

Posted: October 29, 2009 in General

This Example demonstrates double buffering in a windows application. When rendering using the normal paint message approach, you can get horrible flicker due to the way windows paints objects on top of each other but updating the display after each paint operation. This can be prevented by using such styles as WS_CLIPCHILDREN, and careful use of regions to only draw what *won’t* be covered by a subsequent paint operation. But this can be tricky for general objects, and it is far more easier and convenient to simply use a double buffering technique. Which simply works by doing all the drawing offline to another bitmap, and then bliting this bitmap at the end. This way we dont see the updated buffer after each individual paint operation, but rather we see the update after all paint operations have been carried out.

I used this technique for some of the animated controls in my Win32 Library to reduce flicker.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s