Does anyone have example code using double buffering for an animation? From what I've read one simply sets up an offscreen bitmap and device context for an animation's background , uses "BitBlit" to add any animated elements on top of the offscreen bitmap and then bitblits the offscreen bitmap to the desired Windows control surface. Am I correct here? Thanks for any input....
Search the forum for CreateCompatibleDC - there are many good examples.
If that is not enough, search \masm32\examples for the 33 assembler files containing the string CreateCompatibleDC.
If you like to display an animation there is a simple way without CreateCompatibleDC, BitBlt Bitmap action.
Use CreateWindowEx with the animation control class.
The avi must be silent and you can load it from HDD or include it in resource.
szSysAnimate32 db "SysAnimate32",0
Only an idea.
You can use this, you will only need donkey graph lib
fLayer struct
DC dword 0
bmp dword 0
fLayer ends
fNewLayer proc uses esi lpLayerStruct:dword,_width:dword,height:dword
mov esi,lpLayerStruct
invoke CreateCompatibleDC,0
.if eax==0
invoke MessageBox,0,0,0,0
.endif
mov [esi].fLayer.DC,eax
invoke CreateIndependantBitmap,eax,_width,height
mov [esi].fLayer.bmp,eax
invoke SelectObject,[esi].fLayer.DC,[esi].fLayer.bmp
invoke DeleteObject,eax
ret
fNewLayer endp
fDeleteLayer proc uses esi lpLayerStruct:dword
mov esi,lpLayerStruct
invoke DeleteObject,[esi].fLayer.bmp
invoke DeleteDC,[esi].fLayer.DC
ret
fDeleteLayer endp
How to use it:
.data
gbuff fLayer <?>
.code
.elseif WM_CREATE
invoke fNewLayer,addr gbuff,1024,768
; Draw everything to gbuff.DC
.endif
;On your draw procedure
invoke BitBlt,hDC,0,0,1024,768,gbuff.DC,0,0,SRCCOPY
Easy is not it?