Archived

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

Managed DirectX Driving Me Nuts!

This topic is 5117 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

Managed DirectX is completely rediculous. There''s no docs for anything, thus I have to come here and make embarassing requests for help like this one: I have a 32 bit TGA image with an alpha channel (it''s a picture of a ship). All I want to do is load it and display it with the the parts of the image with 0 alpha not displaying. This should be easy. I''ve done it in OpenGL with this image, so I know it''s formatted correctly. I can''t figure out where the problem might be in my code. Right now I can load the texture and map it onto a square. It displays ok, but it''s not transparent. The renderer is set up like this: device.SetTexture(0,texture); device.TextureState[0].ColorOperation = TextureOperation.Modulate; device.TextureState[0].ColorArgument1 = TextureArgument.TextureColor; device.TextureState[0].ColorArgument2 = TextureArgument.Diffuse; device.TextureState[0].AlphaOperation = TextureOperation.Modulate; //device.TextureState[0].AlphaArgument1 = TextureArgument.Diffuse; device.SamplerState[0].MinFilter = TextureFilter.Linear; device.SamplerState[0].MagFilter = TextureFilter.Linear; device.RenderState.ShadeMode = ShadeMode.Gouraud; device.RenderState.AlphaBlendEnable = true; device.RenderState.AlphaSourceBlend = Direct3D.Blend.SourceAlpha; device.RenderState.AlphaDestinationBlend = Direct3D.Blend.InvSourceAlpha; Which I know is at least close to being right. Is there some state variable that I need to set that I''m missing here? I''ve currently got a book of poetry by Goeth that I''m consulting to find the answers to all my Managed DirectX 9 questions, and I have to say that it''s been more helpful than the SDK docs :-(. ---------------------------------------- Let be be finale of seem, seems to me. ---------------------------------------- Coding: http://www.stanford.edu/~jjshed/coding Miscellany: http://www.stanford.edu/~jjshed

Share this post


Link to post
Share on other sites
Shouldn`t you add something like:
device.TextureState[0].AlphaArgument1 = TextureArgument.TextureColor;

Anyway, try to look at Billboard sample, it uses transparent textures...



[edited by - Bulma on December 15, 2003 7:22:11 AM]

Share this post


Link to post
Share on other sites
OMG!

I figured it out, it''s
device.RenderState.AlphaBlendEnable = true;
device.RenderState.SourceBlend = Direct3D.Blend.SourceAlpha;
device.RenderState.DestinationBlend = Direct3D.Blend.InvSourceAlpha;

Not:

device.RenderState.AlphaBlendEnable = true;
device.RenderState.AlphaSourceBlend = Direct3D.Blend.SourceAlpha;
device.RenderState.AlphaDestinationBlend = Direct3D.Blend.InvSourceAlpha;


Those are kind of misleading names for constants. It wouldn''t be a problem if there were docs, but there ain''t, so it is. Hopefully this will save some people some pain...




----------------------------------------
Let be be finale of seem, seems to me.
----------------------------------------

Coding:
http://www.stanford.edu/~jjshed/coding

Miscellany:
http://www.stanford.edu/~jjshed

Share this post


Link to post
Share on other sites