Results 1 to 2 of 2

Thread: Use XNA like DirectX9, Transparencies

  1. #1

    Thread Starter
    Hyperactive Member singularis's Avatar
    Join Date
    Nov 2006
    Location
    Over There!
    Posts
    372

    Use XNA like DirectX9, Transparencies

    Hi,

    I have been trying to achieve alpha blending in XNA. I don't want to use the Spritebatch class. I have tried playing around with the renderstate and setting a colour key.

    Code to create Colourkey:
    Code:
                TextureCreationParameters tt = new TextureCreationParameters();
                tt = TextureCreationParameters.Default;
                tt.ColorKey = new Color(0, 0, 0);
                tt.Format = SurfaceFormat.Rgba32;
    
                inSheet.texData = Texture2D.FromFile(device, assetName, tt);
    Code setting renderstate:
    Code:
                device.RenderState.AlphaSourceBlend = Blend.SourceAlpha;
                device.RenderState.AlphaDestinationBlend = Blend.InverseSourceAlpha;
                device.RenderState.AlphaBlendEnable = true;
    Have I gone mad and tried to use XNA like DX9?

    Or is there a way?

    Find my whole project attached.
    Attached Files Attached Files
    If what I said was helpful, give me rep!

    My Complete Games: -- 2D Zone (Space Shooter game) || _2D Zone 2_ || Ninja Blob (2D platformer) || Dren (Co-op up to 4 player base defence game)

    My Projects: -- The Dread Engine (2D VB game Engine) || A* Path Finding


    An excellent site for learning DirectX7, 8 & 9 (for VB6, C# & VB.net) would be: directx4vb.vbgamer.com --- For my projects and games see: pieper.freehostia.com

  2. #2

    Thread Starter
    Hyperactive Member singularis's Avatar
    Join Date
    Nov 2006
    Location
    Over There!
    Posts
    372

    Re: Use XNA like DirectX9, Transparencies

    ah, Fixed, it turns out all I had to do was change:
    Code:
          device.RenderState.AlphaSourceBlend = Blend.SourceAlpha;
                device.RenderState.AlphaDestinationBlend = Blend.InverseSourceAlpha;
                device.RenderState.AlphaBlendEnable = true;
    into:

    Code:
          device.RenderState.SourceBlend = Blend.SourceAlpha;
                device.RenderState.DestinationBlend = Blend.InverseSourceAlpha;
                device.RenderState.AlphaBlendEnable = true;
    I was blending the alpha values and not the colours
    If what I said was helpful, give me rep!

    My Complete Games: -- 2D Zone (Space Shooter game) || _2D Zone 2_ || Ninja Blob (2D platformer) || Dren (Co-op up to 4 player base defence game)

    My Projects: -- The Dread Engine (2D VB game Engine) || A* Path Finding


    An excellent site for learning DirectX7, 8 & 9 (for VB6, C# & VB.net) would be: directx4vb.vbgamer.com --- For my projects and games see: pieper.freehostia.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width