Skip to main content
gamedev.net
🔒 Locked

Transparent Sprite

Started by Soulnafein Nov 29, 2004 at 5:30 AM 8 replies 1.9k views
Original Post
Soulnafein
Soulnafein
Hi, i have a little problem. I have to show a little sprite. I loaded it using hResult = pd3dDevice->CreateOffscreenPlainSurface(width, height, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &surface, NULL); if (FAILED(hResult)) return NULL; hResult = D3DXLoadSurfaceFromFile(surface, NULL, NULL, filename.c_str(), NULL, D3DX_DEFAULT, 0, NULL); if (FAILED(hResult)) return NULL; I suppose that passing 0 to D3DXLoadSurfaceFromFile's 7th parameter, DirectX isn't going to show black pixel. When i call pd3dDevice->StretchRect(srcSurface, srcRect, getBackBuffer(), destRect, D3DTEXF_NONE); directx show sprite with black pixels. Why? P.S. I'm sorry for my bad english...
My dream game programming, my passion game programming, my life is game programming
Soulnafein
Soulnafein
No solutions?
My dream game programming, my passion game programming, my life is game programming
Syranide
Syranide
You are actually wrong there...
You should use the builtin defines for constructing values...

0 in this case is 0x00000000
black is 0xFF000000 (FF to the left I think)

because, you have to specify what alphavalue to that should be transparent... 0 means the black pixel with 0% visibility.

Use D3DCOLOR_RGBA do create these values as D3DCOLOR_RGBA(0,0,0,255) in your case is "black".


Soulnafein
Soulnafein
I change the parameter value but the result is the same. I see sprite in black box.
My dream game programming, my passion game programming, my life is game programming
Syranide
Syranide
Hmm, ok, first of I wonder, why do you use surfaces and StretchRect to draw simple 2D?

Using ID3DXSprite is much much more powerful and in most cases much faster and offers many more features and effects.

So, what I'm guessing is, either, the color is not (0,0,0), StrecthRect doesn't work well with transparent keys or a renderstate or something disables the transparency-key.


Soulnafein
Soulnafein
I use MS Paint to draw the bitmap
My dream game programming, my passion game programming, my life is game programming
Syranide
Syranide
Uhm, that's not what I meant, why draw using StrechRect in the IDirect3DDevice when you can use ID3DXSprite which is much more powerful and "better" in all ways as far as I know.


Soulnafein
Soulnafein
i'm following a book: Beginning DirectX 9 by Wendy Jones.
I use Stretch because She use stretch. I know that ID3DXSprite is more powerful than StretchRect but i need to learn StretchRect.
Thank you.
My dream game programming, my passion game programming, my life is game programming
DrunkenHyena
DrunkenHyena
Quote:
Original post by Soulnafein
i'm following a book: Beginning DirectX 9 by Wendy Jones.
I use Stretch because She use stretch. I know that ID3DXSprite is more powerful than StretchRect but i need to learn StretchRect.
Thank you.

StretchRect copies a rectangle exactly as it is. You cannot do transparency with it. I would hope that Ms Jones' book goes into that but I've never read it.
Stay Casual,KenDrunken Hyena</FON
boolean010
boolean010
You might be able to get some information from this article. It draws a bunch of green sprites on the screen without their background color. i.e. no box around sprite.

Here is the link: http://www.gamedev.net/reference/articles/article1972.asp
http://www.gamedev.net/reference/articles/article1608.asp

[Edited by - boolean010 on November 29, 2004 10:06:02 PM]
** boolean010 **

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.