Hello everyone.
I am working on a small project with C# and DX9, and I have recently encountered some difficulties with colorkeying. For some reason, instead of making transparent the pixels in magenta (my color key), I get them rendered in black right on top of the lower layers..... I have no clue of why DX is behaving in such a way and therefore ask for your help and knowledge.
Here you have some code snipets:
Where memStream is just a MemoryStrem object which has a complete bmp in memory (I have my own custom resource file format). Before you ask the texture is loaded perfectly, the only problem is how the color key is rendered by DX.
As you may see from the renderstate settings, I'm rendering using TLVertexs.
I'm really clueless.... I tried a few things but nothing seems to work.....
Thanks in advanced for all your help.
I am working on a small project with C# and DX9, and I have recently encountered some difficulties with colorkeying. For some reason, instead of making transparent the pixels in magenta (my color key), I get them rendered in black right on top of the lower layers..... I have no clue of why DX is behaving in such a way and therefore ask for your help and knowledge.
Here you have some code snipets:
Code:
private const int COLOR_KEY = unchecked((int) 0xffff00ff);
Code:
texture.d3dTexture = TextureLoader.FromStream(device, memStream, 0, 0, 1, Usage.None, Format.Unknown, Pool.Managed, Filter.Point, Filter.Point, COLOR_KEY);
Where memStream is just a MemoryStrem object which has a complete bmp in memory (I have my own custom resource file format). Before you ask the texture is loaded perfectly, the only problem is how the color key is rendered by DX.
Code:
// Set up render state
device.RenderState.AlphaBlendEnable = true; // Enable alpha
device.RenderState.AlphaDestinationBlend = Blend.InvSourceAlpha; // Set up alpha for colorkeying
device.RenderState.AlphaSourceBlend = Blend.SourceAlpha; // Set up alpha for colorkeying
device.RenderState.Clipping = false; // Disable clipping
device.RenderState.Lighting = false; // Disable lightning
device.RenderState.CullMode = Cull.None; // Disable culling
device.RenderState.DebugMonitorTokenEnabled = false; // Disable monitor debuging
device.RenderState.ZBufferEnable = false; // Disable Z Buffer
device.RenderState.FillMode = fillMode; // Set the selected fill mode
As you may see from the renderstate settings, I'm rendering using TLVertexs.
I'm really clueless.... I tried a few things but nothing seems to work.....
Thanks in advanced for all your help.