Jump to content
  • Advertisement


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


Page Flipping with Win32

This topic is 5680 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi. I want to set up a page flipping scheme for my Win32/GDI Tetris clone. I know I should be using DirectX but I''m not. Anyway, I''m assuming that I would do something like this:
HDC WindowDC = GetDC(hwnd);
HDC OffscreenDC = CreateCompatibleDC(WindowDC);
And, assuming that the display is 640 x 480, I can simply blit everything to OffscreenDC, and when the frame is complete, blit the OffscreenDC to WindowDC as follows:
BitBlt(WindowDC, 0, 0, 640, 480, OffscreenDC, 0, 0, SRCCOPY);
Is this correct? If so, I have one question: how does CreateCompatibleDC know what size (in this case, 640x480) to make the surface? Does it make a DC the same exact size as WindowDC? If so, then what about the memory DC''s I make for smaller bitmaps? Are they all 640x480 as well, therefore containing thousands of wasted, unused bytes? I''m confused.

Share this post

Link to post
Share on other sites
Guest Anonymous Poster
there is no surface associated with a DC. you need to create and select a bitmap into your memory DC and use that as your drawing target. blitting from the memory DC to the display DC will then cause the pixels from the memory bitmap to be copied to the display.

fwiw, you probably don''t want to blit the whole bitmap except under OS requested re-paint conditions. instead, you should only blit those portions of your bitmap that change. the dirty rectangle technique is one such way to achieve this.

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!