Advertisement Jump to content
Sign in to follow this  

help: Using double buffers and still getting flicker...due to RedrawWindow I think.

This topic is 4967 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

Hello, I am doing some simple 2d animations but am having the oddest problem. When I redraw the window, the new image never gets redrawn ontop of it. Ok, that's not entirely true. But the flicker is worse then normal filckering. I think about 90% of the time it is grey and 10% of the time I can see my image. I have to Redraw the window because my animation has transparent pixels and moves and if I don't redraw it, there is blurring since each frame is drawn ontop of the previous one (there is no flickering, however, if I don't use RedrawWindow). Is there a better way to erase the background. There must be since other programs seem to animate fine without blurring or flickering. What am I doing wrong? I really really really appreciate any help on this one as it's been keeping me busy for way too long. //I'm only redrawing the background for half of the animation to see what is going on. RECT visRect = {0,0,32,64}; RedrawWindow(g_hWnd,&visRect,NULL,RDW_ERASE| RDW_INVALIDATE ); //Bitmap memBmp; HDC hdcMem; HBITMAP hbmMem; HANDLE hOld; // Create an off-screen DC for double-buffering hdcMem = CreateCompatibleDC(hdcScreen); hbmMem = CreateCompatibleBitmap(hdcScreen, 64, 64); hOld = SelectObject(hdcMem, hbmMem); // Draw into hdcMem...note that i is a changing image Graphics g2(hdcMem); g2.DrawImage(&i,0,0,64,64,64,64,UnitPixel ); // Transfer the off-screen DC to the screen BitBlt(hdcScreen, 0, 0, 64, 64, hdcMem, 0, 0, SRCCOPY); // Free-up the off-screen DC SelectObject(hdcMem, hOld); DeleteObject(hbmMem); g2.ReleaseHDC(hdcMem); DeleteDC (hdcMem);

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!