News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Direct Draw

Started by Farabi, July 03, 2005, 07:40:42 AM

Previous topic - Next topic

Farabi

Hai. How to move my buffer to DDraw screen? And how to get the memory address? And how set the resolution? Any example?
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

daydreamer

Quote from: Farabi on July 03, 2005, 07:40:42 AM
Hai. How to move my buffer to DDraw screen? And how to get the memory address? And how set the resolution? Any example?
search for a dirextx plasma demo w source
here is how to setup dx, note you need to set cooperative level DDSCL_EXCLUSIVE or DDSCL_FULLSCREEN when using setdisplaymode
windowed mode, use DDSCL_NORMAL or DDSCL_NOWINDOWCHANGES
put these code right after you created your window

INVOKE DirectDrawCreate, NULL, ADDR lpDD, NULL
DDINVOKE SetCooperativeLevel, lpDD, hWnd,DDSCL_NORMAL or DDSCL_NOWINDOWCHANGES;DDSCL_EXCLUSIVE or DDSCL_FULLSCREEN
;DDINVOKE SetDisplayMode, lpDD, ddwidth, ddheight, ddbpp

mov [ddsd.dwSize], sizeof DDSURFACEDESC
mov [ddsd.dwFlags], DDSD_CAPS
mov [ddsd.ddsCaps.dwCaps], DDSCAPS_PRIMARYSURFACE
DDINVOKE CreateSurface, lpDD, ADDR ddsd, ADDR lpDDSPrimary, NULL


here is my mainloop, lock and unlock surface, wait for verticalblank
mov ddsd.dwFlags, DDSD_PITCH for let lock return Lpitch


mov [ddsd.dwSize], sizeof DDSURFACEDESC
mov [ddsd.dwFlags], DDSD_PITCH

;.WHILE 1
DDSINVOKE mLock, lpDDSPrimary, NULL, ADDR ddsd, DDLOCK_WAIT, NULL

;.BREAK .IF eax == DD_OK

;.IF eax == DDERR_SURFACELOST
; DDSINVOKE Restore, lpDDSPrimary
;.ELSE
;FATAL "Couldn't lock surface"
;.ENDIF
;.ENDW

DDINVOKE WaitForVerticalBlank, lpDD, DDWAITVB_BLOCKBEGIN, NULL
                       

call render

DDSINVOKE Unlock, lpDDSPrimary, ddsd.lpSurface



here is how I start my loop with getting adress of buffer in ebx and increment to get to next line in edi
this is normal for ddraw as some videocards doesnt have a linear buffer
so a normal loop is to have a innerloop that transfers lines, outer loop that decrement your counter back to start of line and adds lPitch


mov ebx,[ddsd.lpSurface]
mov edi,[ddsd.lPitch]


you also need data section from plasma demo for this to work