• Advertisement

Archived

This topic is now archived and is closed to further replies.

I forgot how >> Transparent background with primitives

This topic is 5554 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

I did this before but i forget how: I have primitives. I use textures. I load the texture this way: TEXTURE LoadTextureFromFileEx(char* filename, long clr, long width, long height) { TEXTURE tmp; D3DXCreateTextureFromFileEx(D3DDevice, filename, width, height, D3DX_DEFAULT, 0, D3DFMT_UNKNOWN, D3DPOOL_MANAGED, D3DX_FILTER_POINT, D3DX_FILTER_POINT, clr, 0, 0, &tmp); return tmp; } I call this function this way: text = LoadTextureFromFileEx(filename, 0xffffffff, width, height); And before loading this texture, and before rendering I do this: D3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, true); D3DDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA); D3DDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA); The texture is a simple mouse-texture, with a white background. The image is displayed, but the primitive isn''t transparent: The background becomes black. How can I solve this?

Share this post


Link to post
Share on other sites
Advertisement
How can I create my primitive with an alpha component in the vertices? And how do I use the Modulate Blend?

Share this post


Link to post
Share on other sites
hi,

i guess it''s transparent, it just shows your ''real'' background which is black, meaning, you might be rendering your mouse cursor before all objects? try changing your background to another color and see if the black becomes that color too,

Share this post


Link to post
Share on other sites
Im rendering in front of a skinned mesh, and it has a background alright. Im certain of it...

Share this post


Link to post
Share on other sites
hi,

well if you''re certain then maybe we should just follow Dreddnafious Maelstrom advice eh?

i think his trying to tell you to put a D3DCOLOR on your VERTEX struct, then use this,

m_pDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_MODULATE);

Share this post


Link to post
Share on other sites
hi,

sorry can''t help you anymore then, it really seems to me that it''s working because why would the texture''s white background became black instead?

Share this post


Link to post
Share on other sites
I dont get it myself....
Well, maybe this is something:
-Lightning is OFF
-VertexShader = (D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_TEX1)
-Structure with VB:
struct CUSTOMVERTEXontop
{
D3DXVECTOR3 position;
float rhw;
DWORD color;
float tu, tv;
};

Got any ideas now? Please!?

Share this post


Link to post
Share on other sites
One thing I just found out:
If I use this:
D3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, true);
D3DDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_ONE);
D3DDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_ONE);
It does become transparent, but the foreground (a gold-colored cursor) does become half-transparent to. So which combination do I have to use?

Share this post


Link to post
Share on other sites

  • Advertisement