• Advertisement
Sign in to follow this  

How to make alpha blending?

This topic is 4218 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,everybody. I want to change my Primitive's alpha value. I think I can change the vertex's color(a,r,g,b) to make alpha blending.But it need to lock the vertexbuffer and unlock it every time. Then I learn another method from dx9.0sdk.It uses materials to do alpha blending. So I write the following codes,however no alpha-blending appears. m_pD3DDevice->SetRenderState( D3DRS_ALPHABLENDENABLE,TRUE) ; m_pD3DDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA ); m_pD3DDevice->SetRenderState(D3DRS_DESTBLEND,D3DBLEND_INVSRCALPHA); m_pd3dDevice->SetRenderState( D3DRS_DIFFUSEMATERIALSOURCE, D3DMCS_MATERIAL ); D3DMATERIAL9 mtrl; mtrl.Diffuse = mtrl.Ambient = mtrl.Specular = mtrl.Emissive = D3DXCOLOR(1,0,0,0.5f) m_pd3dDevice->SetMaterial(&mtrl); primitive->render(); I hope someone give me some advice. Thanks in advance!

Share this post


Link to post
Share on other sites
Advertisement
I change the D3DFVF_QUADVERTEX (D3DFVF_XYZRHW|D3DFVF_DIFFUSE|D3DFVF_TEX1)
to D3DFVF_QUADVERTEX2 (D3DFVF_XYZ|D3DFVF_NORMAL|D3DFVF_DIFFUSE|D3DFVF_TEX1).
And it works just like I want.

Share this post


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

  • Advertisement