I want to start game programming soon and I'm now starting with the rendering part. I'll begin with using GDI and I may later port the whole thing to DirectDraw/Direct3D, but now I want it to work with double duffering :D
My rendering function currently looks like this:
int render(HWND hwnd)
{
//Variables
BITMAP bmAvatar;
PAINTSTRUCT psInfo;
//Prepare painting
HDC hdc = BeginPaint(hwnd, &psInfo);
HDC hdcMem = CreateCompatibleDC(hdc);
//Load picture
HBITMAP hbmOld = (HBITMAP)SelectObject(hdcMem, g_Avatar);
GetObject(g_Avatar, sizeof(bmAvatar), &bmAvatar);
//Draw stuff
BitBlt(hdc, mx, my, bmAvatar.bmWidth, bmAvatar.bmHeight, hdcMem, 0, 0, SRCCOPY);
//Destroy it all again
SelectObject(hdcMem, hbmOld);
DeleteDC(hdcMem);
//Stop painting
EndPaint(hwnd, &psInfo);
return 1;
}
So, how do I add double buffering to this? If you need more information, just say so :)


Sign In
Create Account

Back to top









