Results 1 to 9 of 9

Thread: DirectDraw - blitting silhouette

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jul 2000
    Posts
    225

    DirectDraw - blitting silhouette

    Hiyas,

    I've been writting a large-scale squad-based tile-based isometric game (a solo project), and everything is going great... I'm about half way through development, and I'm doing everything (coding, gfx, sfx) myself, and I'm loving it.

    I've made a design decision, but I'm not sure how to program it... I've decided that tiles which aren't visible to the player should still be blitted, although they should be blacked out. That is, a black solid shadow-like outline of the tile should be blitted (sortof like the black/white 'cutout' used with transparent BitBlt-ing). This way the player can still sortof see the outline of a tile, but they're not sure what it is because they can't see the 'face' of it... (since it's black)

    How do I go about doing this? I'm guessing I might have to use alpha channels (I think that's their name), but I'd rather not because I think the coding looks too confusing. Is there any other option(s)? (Btw I don't want to load pre-drawn 'cutout' images, as that would just be silly )

    Thanks,

    -Git
    Last edited by git; Jul 21st, 2001 at 05:25 AM.

  2. #2

    Thread Starter
    Addicted Member
    Join Date
    Jul 2000
    Posts
    225
    Hi Bryk,

    Thanks for your reply. I have to agree that it would be quicker to write, but I'm really trying to be tight with the memory consumption. After all, I switched to DD for two main reasons: speed and to get rid of the BitBlt mask images... To double my tileset's size just to get a feature, the easy way, is out of the question. =/

    I just remembered that BitBlt does something like what I want to do. Here's an example of a normal blit, using a transparency mask.

    BitBlt Pic.hDC, x, y, 10, 10, PicSource.hDC, 10, 0, vbSrcAnd
    BitBlt Pic.hDC, x, y, 10, 10, PicSource.hDC, 0, 0, vbSrcPaint

    That will blit a 10x10 image with the black mask removed. However, check this out.

    BitBlt Pic.hDC, x, y, 10, 10, PicSource.hDC, 10, 0, vbSrcAnd

    If only this line is run, only a black silhouette without the transparent areas will be blitted. The other stuff which is 'supposed' to be blitted won't be blitted. This is exactly what I want to do - blit only a black silhouette (I didn't think to use this word before - it may explain what I want to do, a bit better).

    If this is easy enough to do in BitBlt, surely there's an easy way to do it in Direct Draw...?!

    Thanks for any more help,

    -Git
    Last edited by git; Jul 21st, 2001 at 04:18 AM.

  3. #3
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    you can do any rasteroperations with DirectDrawSurface7.BltFx, just flag them on in DDBLTFX.dwrop
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  4. #4
    Zaei
    Guest
    This may sound a bit silly, but if the player can't see what the tile is, why would you have to have a shadowed version of every tile? Wouldn't it make sense to just have a Generic Brand Shadowed Tile™, and blit it when the player can't see it?

    Z.

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Jul 2000
    Posts
    225
    Zaei - it's not just tiles actually. It's walls, objects, and floor tiles.

    Kedaman - Thanks - I tried that, but then I realised there's a problem with doing it this way...

    With BitBlt, vbSrcAnd is used to blit the B&W mask, which makes the black sillouette. I don't have a B&W mask on my surface/tileset, only the original image...so I don't think I can do it like that.

    Is there any other way to do this? (without resorting to having a doublesized tileset)

    -Git

  6. #6
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    I'm not sure but I think there's no HEL version for most rasterops in ddraw, only copy, whiteness and blackness, so in case you need software emulation, you should go coding that part in C++
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Jul 2000
    Posts
    225
    Hmm...damn...looks like I might have to have a double sized tileset. I do have a couple of ideas though.

    How about going through each pixel of the 40x70 pixel tile (on the source surface), check the colour, and if it's not purple (the transparent colour), then blit/fill a 1x1 black pixel on the screen corresponding to that location? Pseudo code:

    Code:
    For x = 1 to 40
        For y = 1 to 70
            If not functiontogetcolourfromsource(x,y) = vbMagenta then
                blt to screenx/screeny from x/y
            Else
                'this pixel is transparent - don't blit it !
            End if
        Next y
    Next x
    Or would this be really really really slow?

    Another idea... What if I blitted the tile normally, but also sortof combined that with the fill command? (so it blit's it transparently, and fills the non-transparent area) Just a wild idea...

  8. #8
    Member
    Join Date
    Jul 2001
    Location
    Minneapolis, MN USA
    Posts
    32
    Okay ... I'll give another try ...

    How about the following:

    1> Create a DD surface the size of a tile
    2> Do whatever you need to prepare the tile "background"
    3> Get the surface hDC
    4> Use the normal API methods you mentioned before using the locked surface's handle
    5> Unlock the surface
    6> Use DD to draw the surface to your buffer

    This might be slow if you have a lot of "silhouetted" tiles, though ...

    -Bryk

  9. #9
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    Have you tried creating a surface from a DC?
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

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