Results 1 to 6 of 6

Thread: Blitting a transparent backed DDraw surface? *Fixed*

  1. #1

    Thread Starter
    Lively Member FireSlash518's Avatar
    Join Date
    Nov 2001
    Posts
    67

    Red face 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.

    Leader of the Maxoverkill Mods
    -Fire§lash

  2. #2
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    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...

  3. #3

    Thread Starter
    Lively Member FireSlash518's Avatar
    Join Date
    Nov 2001
    Posts
    67
    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

    Leader of the Maxoverkill Mods
    -Fire§lash

  4. #4
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    I'm not 100% sure, but I still think you have to use a ColorKey...

  5. #5

    Thread Starter
    Lively Member FireSlash518's Avatar
    Join Date
    Nov 2001
    Posts
    67
    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

    Leader of the Maxoverkill Mods
    -Fire§lash

  6. #6

    Thread Starter
    Lively Member FireSlash518's Avatar
    Join Date
    Nov 2001
    Posts
    67
    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

    Leader of the Maxoverkill Mods
    -Fire§lash

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width