Archived

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

Miso

double buffering in Windows question

Recommended Posts

Miso    122
Hi all, I would like to implement double buffering in Windows. This is what I have so far: a mainWindow with a device context a bitmap with a device context I would then BitBlt the bitmap to the mainWindow each time I receive a WM_PAINT message. The way I change the contents of the bitmap is following: I have a buffer with r,g,b information in memory and just before the bitBlt I copy the color information to the bitmap using SetBitmapBits(...) My question is if there is a way to modify the bitmap color bits direcly in memory, without having to first modify it in the buffer, then copy to bitmap, and then bitBlt to mainWindow. Thanks for help.

Share this post


Link to post
Share on other sites
emptyhead    178
I believe you can use SetDIBitsToDevice to blit directly from your buffer to the DC.

Alternatively, you could use CreateDIBSection to create the bitmap, and then modify the bitmap directly through the pointer it gives you.


:wq!

Share this post


Link to post
Share on other sites
neoman    145
My solution is to create a window and its DC. Then create a BITMAPINFO with the needed parameters, which you have to use in combination with SetDIBitsToDevice. Using this function you can directly copy your buffer to the DC.

Greets,
André

Share this post


Link to post
Share on other sites