hi,

i created this code to blit sprites on my window, it works perfectly on win98se:


DrawBitmap proc uses edi esi x:DWORD,y:DWORD,ptr_surface1:DWORD,ptr_surface2:DWORD,ptr_Bitmapinfo:DWORD
LOCAL rc : RECT
mov esi,[ptr_Bitmapinfo]
assume esi:ptr BITMAP
mov eax,x
mov rc.left,eax
mov rc.right,eax
mov eax,y
mov rc.top,eax
mov rc.bottom,eax
mov eax,[esi].bmWidth
add rc.right,eax
mov eax,[esi].bmHeight
add rc.bottom,eax
invoke RtlZeroMemory,addr ddbltfx,sizeof(DDBLTFX)
mov ddbltfx.dwSize,sizeof(DDBLTFX)
mov ddbltfx.dwROP,SRCAND
assume esi:nothing
mov esi,[ptr_surface1]
assume esi:ptr LPDIRECTDRAWSURFACE7
mcall [dds_back],IDirectDrawSurface7_Blt,addr rc,[esi],NULL,DDBLT_WAIT or DDBLT_ROP,addr ddbltfx
assume esi:nothing
.if eax!=DD_OK
FATAL "Bliting the first bitmap failed!"
.endif

invoke RtlZeroMemory,addr ddbltfx,sizeof(DDBLTFX)
mov ddbltfx.dwSize,sizeof(DDBLTFX)
mov ddbltfx.dwROP,SRCINVERT
mov esi,[ptr_surface2]
assume esi:ptr LPDIRECTDRAWSURFACE7
mcall [dds_back],IDirectDrawSurface7_Blt,addr rc,[esi],NULL,DDBLT_WAIT or DDBLT_ROP
,addr ddbltfx
assume esi:nothing
.if eax!=DD_OK
FATAL "Bliting the second bitmap failed!"
.endif

ret
DrawBitmap endp


but winxp / win2k seems to have problems with:


mcall [dds_back],IDirectDrawSurface7_Blt,addr rc,[esi],NULL,DDBLT_WAIT or DDBLT_ROP
,addr ddbltfx

it seems not accepting DDBLT_ROP, because i get the first/ second error message. if i let "or DDBLT_ROP" out, everything works fine, but of course Blt ignores the SRCINVERT and SCRAND.

can you help me?
Posted on 2002-07-20 17:33:59 by NOP-erator
hi,

i'm totally demotivated.. here's what i found out:
Blitting effects include the standard raster operations (ROPs) used by GDI functions such as BitBlt. The only ROPs supported by the HEL are SRCCOPY (the default), BLACKNESS, and WHITENESS. Hardware support for other ROPs can be examined in the DDCAPS structure for the driver. If you wish to use any of the standard ROPS with the Blt method, you flag them in the dwROP member of the DDBLTFX structure.


and obviously my HEL (whatever that is) / my hardware on the xp machines *does not* support SCRAND and SCRINVERT es a ROP.
then i found another possibility: there is another member of the ddbltfx structure called "dwDDROP" for DirectDraw specific raster operations, BUT:
The dwDDROP member of the DDBLTFX structure is for specifying ROPs specific to DirectDraw. However, no such ROPs are currently defined.
PERFECT!!!

so, what possibilities do i have to Blit sprites on my screen with directdraw? as you surely noticed i have two bitmaps for each sprite at the moment, the mask is blitted with SRCAND and the real sprite bitmap is blitted with SRCINVERT over the mask.. and as i said it works on my win98se machine, but it seems to be a hardware problem..

please help me.. :(

bye
Posted on 2002-07-21 05:38:48 by NOP-erator
Two possibilities you have:

i) Use the blt-method using colorkeys (set source colorkey to transparentcolor)

ii) use the dxsprite-interface of d3dx8 (take a look at my intro-example on my www-site if you want to have further details)

Greetings, Caleb
Posted on 2002-07-21 07:16:52 by Caleb
hey, thanks caleb, at least one answer.. :(

but:
1) would you please explain that a bit more in detail for me? please.. i'm a beginner in DD..

2) this means, that i have to port all the code i've already done into dx8?? but that means a LOT of work, and learning how to code with dx8.. :(

thanks.. bye

edit: ok, not THAT much work, but i wouldn't even know where to start..
Posted on 2002-07-21 07:20:32 by NOP-erator
wait a moment please if you're answering atm..
Posted on 2002-07-21 07:22:42 by NOP-erator
ok,
Color key flags
DDBLT_KEYDEST
Uses the color key associated with the destination surface.
DDBLT_KEYSRC
Uses the color key associated with the source surface.


ok, this has to be in the call as dwFlags. but:
1) how to set the color key?
2) i don't understand clearly what KEYDEST and KEYSRC are.. i mean the difference..
3) my background isn't just one colour, but it's a bitmap with a lot of colours..

a code sample perhaps? :tongue:

thanks,
bye
Posted on 2002-07-21 07:25:27 by NOP-erator
i can't run your stars example on your site, the main.exe tells me, that it misses d3dx8d.dll and after that it says that it misses fmod.dll. after copying both into the folder of main.exe it says: "D3D8-initialisation failed!"..

:( :( :(
Posted on 2002-07-21 08:01:07 by NOP-erator
hi!!!!!!!!!!!! :grin: :alright:

thank you very much caleb!!!!!!! you helped me a lot, i solved it, just with your little "hint"!!! thank you, thank you, thank you!!!!

this is what i've done:



DrawSimpleBitmap2 proc uses edi esi x:DWORD,y:DWORD,ptr_surface:DWORD,ptr_Bitmapinfo:DWORD
LOCAL rc : RECT
mov edi,[ptr_surface]
assume edi:ptr LPDIRECTDRAWSURFACE7
mov colorkey.dwColorSpaceLowValue,0
mov colorkey.dwColorSpaceHighValue,0
mcall [[edi]],IDirectDrawSurface7_SetColorKey,DDCKEY_SRCBLT,addr colorkey
assume edi:nothing
mov esi,[ptr_Bitmapinfo]
assume esi:ptr BITMAP
mov eax,x
mov rc.left,eax
mov rc.right,eax
mov eax,y
mov rc.top,eax
mov rc.bottom,eax
mov eax,[esi].bmWidth
add rc.right,eax
mov eax,[esi].bmHeight
add rc.bottom,eax
invoke RtlZeroMemory,addr ddbltfx,sizeof(DDBLTFX)
mov ddbltfx.dwSize,sizeof(DDBLTFX)
assume esi:nothing
mov esi,[ptr_surface]
assume esi:ptr LPDIRECTDRAWSURFACE7
mcall [dds_back],IDirectDrawSurface7_Blt,addr rc,[esi],NULL,DDBLT_WAIT or DDBLT_KEYSRC,addr ddbltfx
assume esi:nothing
.if eax!=DD_OK
FATAL "Bliting the bitmap failed!"
.endif


ret
DrawSimpleBitmap2 endp


you see, that i've just set the source color and blitted the bitmap on the screen, everything works fine now, thanks again!!!!! but one last thing, what are these two values used for? i mean... shouldn't there just be one transparent color? are they used for a range of colours that should be transparent?


mov colorkey.dwColorSpaceLowValue,0
mov colorkey.dwColorSpaceHighValue,0


thanks!!!!!!!

:alright: :grin:

bye
Posted on 2002-07-21 08:22:58 by NOP-erator
for all the people who would like to see what i've done, here is an alpha version of my program.
type in the game speed in the first field (from 0-150?(because it's an alpha just type in 10 steps like: 10,20,30, etc)), and in the second field type in the number of players (atm 2 players are possible, first player on cursor keys, and second on w,a,s,d), and then click ok!. to start the game press "S", to quit press escape.. have fun!

bye
Posted on 2002-07-21 08:31:13 by NOP-erator
Hi !

many (question-)posts in a short time-range ;) ...

The answer of the last question is that it is possible to declare a whole color-range as transparent. This is quite usefull for antialiased borders or the blue-background-trick of video-filmers !



Greetings, Caleb
Posted on 2002-07-21 10:44:06 by Caleb
are the two values RGB values?

bye
Posted on 2002-07-21 10:45:19 by NOP-erator