|
-
Dec 8th, 2001, 05:13 PM
#1
Thread Starter
Member
Transparent colors (BLT)
How do make a color transparent when using BLT in Directx 7
I’m trying to write a tile engine and need to make a color transparent so I can overlay
My tiles. Please help!
Cool site for VB gaming dev :-
http://rookscape.com/vbgaming/tutorials.php
-
Dec 9th, 2001, 01:08 PM
#2
Frenzied Member
After creating the surface, use this:
VB Code:
'Set the color key to black
Dim Key As DDCOLORKEY
Key.low = 0
Key.high = Key.low
DestSurface.SetColorKey DDCKEY_SRCBLT, Key
This way, black will be the transparent color
-
Dec 9th, 2001, 02:59 PM
#3
Good Ol' Platypus
If you are using 16-bit colour, take a look here:
http://www.vbexplorer.com/directx4vb/
He has code for 16 bit colour keys (that one only works in 24- and 32- bit colour).
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation. 
(Just a heads-up)
-
Dec 9th, 2001, 03:39 PM
#4
Frenzied Member
The code I gave you uses black no matter what the color depth is, unless it's 8-bits and you have a really weird palette
-
Dec 9th, 2001, 03:54 PM
#5
Good Ol' Platypus
Yea, it will work there but for other colours forget it
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation. 
(Just a heads-up)
-
Dec 9th, 2001, 04:39 PM
#6
Frenzied Member
Why would you need any other colors?
-
Dec 9th, 2001, 07:40 PM
#7
Thread Starter
Member
Thanks Guys - One more thing
Can anyone help my with Orthogonal tile engines. I can make nice square one, and I’ve nearly got an orthogonal engine but I’m missing something. I’m using an offset to overlap my tiles.
For example.
---------------------------------------------------------------------------
Do the first line of tiles,
Then on the next line I move the tiles along half a tile’s width so that the edges line up.
The space between lines is half a tile’s height
And move it back to the same place as the fist tile, on the third line
And so on.
------------------------------------------------------------------------------
If you didn’t understand that, don’t worry, I can’t explain anything
But when moving tiles, the movement isn’t looking right!!!
** Could someone give me a example or some theory **
Cool site for VB gaming dev :-
http://rookscape.com/vbgaming/tutorials.php
-
Dec 11th, 2001, 06:47 PM
#8
Frenzied Member
Hum, I understand why you'd use diagonal tiles for a fake 3D effect, but I can't see why you'd wanna use ortogonal tiles - you can easily simulate that with fast square tiles
-
Dec 31st, 2006, 06:01 AM
#9
Lively Member
Re: Transparent colors (BLT)
Why am I getting... User defined type not defined.. for
Dim Key As DDCOLORKEY
-
Jan 1st, 2007, 08:30 AM
#10
Re: Transparent colors (BLT)
 Originally Posted by HaLLa
Why am I getting... User defined type not defined.. for
Dim Key As DDCOLORKEY
Its because you didn't goto the menu in Project > References > and DirectX7 For Visual Basic Type Library.
Why are you even using DirectDraw at all? DirectDraw is very old, and very limited in capabilities. Although still fast. DD was designed for older cards that was more for 2D than 3D. They got rid of it in DX8 but brought it back in DX9 for those who were still using DX7 just for people to use DirectDraw.
Instead of DD, use Direct3D (DX8) using a TLVertex so the Z coordinate is ignored by the computer. That way you can do nifty special effects and have more control over your 2D sprites:
VB Code:
'This is the Flexible-Vertex-Format description for a 2D vertex (Transformed and Lit)
Const FVF = D3DFVF_XYZRHW Or D3DFVF_TEX1 Or D3DFVF_DIFFUSE Or D3DFVF_SPECULAR
'This structure describes a transformed and lit vertex - it's identical to the DirectX7 type "D3DTLVERTEX"
Private Type TLVERTEX
X As Single
Y As Single
Z As Single
rhw As Single
color As Long
specular As Long
tu As Single
tv As Single
End Type
And on top of that, you don't need no stupid multiple color keys and tons of code just to pull off transparency. In Direct3D you just set one color that you want transparent when loading a texture, and these two lines of code in the initialization so the computer knows how its gonna be transparent.
VB Code:
D3DDevice.SetRenderState D3DRS_ALPHAREF, 255
D3DDevice.SetRenderState D3DRS_ALPHAFUNC, D3DCMP_GREATEREQUAL
I also have a Massive DX 2D tutorial in my signature.
Last edited by Jacob Roman; Jan 1st, 2007 at 08:34 AM.
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
|