Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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:

 

private const int COLOR_KEY = unchecked((int) 0xffff00ff);

 

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.

 

// 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.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...