Jump to content
  • Advertisement

Archived

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

TheHermit

Transperent bit

This topic is 5847 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 am using textured quads to produce a 2d game, and would like to know how to discard one colour in favour of a transperent section of bitmap. Ie, texture quad to display a circle without the square around it. Have tried g_d3dDev->SetRenderState( D3DRS_ALPHABLENDENABLE , TRUE ); g_d3dDev->SetRenderState( D3DRS_SRCBLEND , D3DBLEND_SRCALPHA ); g_d3dDev->SetRenderState( D3DRS_DESTBLEND , D3DBLEND_DESTALPHA ); which had promising effect to start, but it seems to make the whole image 50% tansperant, instead of just the one colour 100% transparent. Any help, links, suggestions welcome. Thanks...

Share this post


Link to post
Share on other sites
Advertisement
Hello,

You need to set the color key value in your texture when you create it.


D3DXCreateTextureFromFileEx(m_pd3dDevice,
Image,
NULL,
NULL,
NULL,
NULL,
D3DFMT_A8R8G8B8,
D3DPOOL_MANAGED,
D3DX_DEFAULT,
D3DX_DEFAULT ,
0xFFFF00FF, //colorkey value
NULL,
NULL,
&m_pPlayerTextures);



This texture uses 255,0,255 as the transparancy color.

PigHeaded

Share this post


Link to post
Share on other sites
if you mean something a little like this,

HRESULT hr = D3DXCreateTextureFromResourceEx(g_d3dDev ,NULL ,MAKEINTRESOURCE(IDB_DUALH) ,0 ,0 ,1 ,0 ,D3DFMT_A8R8G8B8 ,D3DPOOL_MANAGED ,D3DX_FILTER_NONE ,D3DX_DEFAULT ,0xffff00ff ,NULL ,NULL ,&g_d3dDualH);

I already had it.

Right now I Clear(..) to a green background, and bounce 3 graphics on the screen. The magenta is transformed to an opaque black which means that (i guess) I need to do something else extra to make it dissappear?

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
g_d3dDev->SetRenderState( D3DRS_SRCBLEND , D3DBLEND_SRCALPHA );
g_d3dDev->SetRenderState( D3DRS_DESTBLEND , 3DBLEND_SRCINVALPHA );

I think

Or go with alphacompare, it''s faster if you don''t do other (real) blending...

Share this post


Link to post
Share on other sites
Anon was me.
Shoulda been alphatesting. If hw supports it, try using that instead like this:

if (m_d3dCaps.AlphaCmpCaps & D3DPCMPCAPS_GREATEREQUAL)
{
m_pd3dDevice->SetRenderState(D3DRS_ALPHATESTENABLE, TRUE);
m_pd3dDevice->SetRenderState(D3DRS_ALPHAREF, 0x00);
m_pd3dDevice->SetRenderState(D3DRS_ALPHAFUNC, D3DCMP_GREATER);
}

Share this post


Link to post
Share on other sites
These are the render state settings I use.

// Set diffuse blending for alpha set in vertices.
m_pd3dDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, TRUE );

m_pd3dDevice->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_SRCALPHA );

m_pd3dDevice->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA );


PigHeaded

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!