Jump to content
  • Advertisement
Sign in to follow this  
Soulnafein

Transparent Sprite

This topic is 4956 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
Advertisement
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".

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!