Sign in to follow this  
Jimmy Valavanis

Semi-Transparent drawing in DX Immediate Mode

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
neneboricua19    634
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this