🔒 Locked
Transparent Sprite
Advertisement
Original Post
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...
No solutions?
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".
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".
I change the parameter value but the result is the same. I see sprite in black box.
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.
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.
I use MS Paint to draw the bitmap
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.
I use Stretch because She use stretch. I know that ID3DXSprite is more powerful than StretchRect but i need to learn StretchRect.
Thank you.
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.
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]
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]
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement