|
-
Oct 25th, 2002, 09:26 PM
#1
Thread Starter
Lively Member
Blitting a transparent backed DDraw surface? *Fixed*
Is it possible to blit a screen sized surface, but not have the background of the surface blit as well?
For instance, i have three layers.
Terrain
Units
Gui
I want to blit them, in this order, on the backbuffer, then flip. (this avoids unnessicary re-drawing)
However, it always seems to carry the surface's background with it, so i only see the gui layer.
Is there a way around this?
Last edited by FireSlash518; Oct 27th, 2002 at 10:56 AM.
-
Oct 26th, 2002, 07:53 AM
#2
If you use a colorKey, and the rest of the background is that color, it will be transparent...
Just wondering: Are your units a picture that is just as wide and high as your display?? If not, you only have to blit the source RECT to the destination RECT, and not the whole screen...
-
Oct 26th, 2002, 09:57 AM
#3
Thread Starter
Lively Member
Im basically using screen sized layers.
This way I only have to re-draw the terrain tiles, unit tiles, and gui tiles when they change. Re-drawing the terrain is a pretty hefty operation, and it dosent change that often.
For instance, one layer might have 21 tiles drawn at random locations on the screen. instead of drawing those 21 tiles each frame, they are stored in their own surface, which is layered with the terrain and gui surfaces each frame. This reduces the blits per frame count to 3 instead of 32+16*12
-
Oct 26th, 2002, 10:05 AM
#4
I'm not 100% sure, but I still think you have to use a ColorKey...
-
Oct 26th, 2002, 10:36 AM
#5
Thread Starter
Lively Member
Hmm. not having much luck. Im not completly sure what im doing, and the MSDN documentation isnt very helpful.
Code:
Dim val As DDCOLORKEY
With val
.low = 1
.high = 1
End With
sUnits.SetColorKey DDCKEY_SRCOVERLAY, val
sUnits.BltColorFill rScreen, 1
-
Oct 27th, 2002, 10:55 AM
#6
Thread Starter
Lively Member
Ah, fixed it.
Heres what I did, if anyone is intrested.
First step is to define a color to use as transparent. Direct Draw uses color keys. We can define a range of colors, but for this Im just using black (RGB(0,0,0))
Code:
Dim ddckBlack As DDCOLORKEY
With ddckBlack
.low = 0
.high = 0
End With
Now, since were changing the surface, we need to erase it to our transparent color.
Code:
sUnits.BltColorFill rScreen, 0
Note that rScreen is a RECT the size of the screen.
Finally, we set the surface to use the color key we want.
Code:
sUnits.SetColorKey DDCKEY_SRCBLT, ddckBlack
Now, when we blit, we need to tell the bltfast() command to use the source surface's color key. just use DDBLTFAST_SRCCOLORKEY
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|