Skip to content

Instantly share code, notes, and snippets.

@tuttlem
Created November 28, 2012 13:33
Show Gist options
  • Save tuttlem/4161317 to your computer and use it in GitHub Desktop.
Save tuttlem/4161317 to your computer and use it in GitHub Desktop.
RecreateBuffer
RecreateBackBuffer PROC hWin:DWORD
; make sure we've destroyed anything already setup
invoke DestroyBackBuffer, hWin
; get an updated reading on the window's area
invoke GetClientRect, hWin, ADDR clientRect
; acquire a new DC for the window
invoke GetDC, hWin
mov winDC, eax
; create a new memory DC based off the window DC
invoke CreateCompatibleDC, winDC
mov memDC, eax
; make eax,ebx the width,height pair
mov eax, clientRect.right
sub eax, clientRect.left
mov ebx, clientRect.bottom
sub ebx, clientRect.top
; create our off-screen drawing surface
invoke CreateCompatibleBitmap, winDC, eax, ebx
mov memBitmap, eax
; this is where we'll draw to from here on
invoke SelectObject, memDC, memBitmap
mov memOldBitmap, eax
xor eax, eax
ret
RecreateBackBuffer ENDP
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment