Semi-Transparent drawing in DX Immediate Mode
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).
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
neneboricua
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:
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??
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??
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement