Jump to content
  • Advertisement
Sign in to follow this  
Jimmy Valavanis

Semi-Transparent drawing in DX Immediate Mode

This topic is 5096 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, Can anyone tell me how can I render semi-transparent triangles in DirectX 7.0 Immediate mode? Eg. I'd like to make a 3D view of a lake, and see below the surface of the lake, but also see the surface of the lake. Or another example: make a dark glass (sunglasses maybe).

Share this post


Link to post
Share on other sites
Advertisement
What you want to look up is Alpha Blending. This allows you to blend two colors together to get a resulting color. DX7 had this capability. Do a search for it in the SDK docs and you should come up with some good information.

neneboricua

Share this post


Link to post
Share on other sites
Well, alpha blending has a disadvantage, semi transparent textures much rendered after the other, I just want to know if there is a way to make semi transparent textures regardless the render ordering. for example:


D3DDevice7->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, 1);
D3DDevice7->SetRenderState(D3DRENDERSTATE_SRCBLEND, Integer(D3DBLEND_ZERO));
D3DDevice7->SetRenderState(D3DRENDERSTATE_DESTBLEND, Integer(D3DBLEND_SRCCOLOR));
D3DDevice7->SetTexture( 0, aGrayTexture7);
D3DDevice7->DrawPrimitive(PrimitiveType, D3DDXFVF_VERTEX, TheVertexes, NumVertexes, 0);

D3DDevice7->SetRenderState(D3DRENDERSTATE_SRCBLEND, Integer(D3DBLEND_ONE));
D3DDevice7->SetRenderState(D3DRENDERSTATE_DESTBLEND, Integer(D3DBLEND_INVSRCCOLOR));
D3DDevice7->SetTexture( 0, aTexture7);
D3DDevice7->DrawPrimitive(PrimitiveType, D3DDXFVF_VERTEX, TheVertexes, NumVertexes, 0);


where aGrayTexture7 is a gray texture and aTexture7 the texture we need to render semi transparent. The above code must be at the end of the BeginScene() - EndScene() sequence. Is there a way to make semi transparend blending without this restriction??

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!