Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi!,

 

I'm trying to render a rectangle with a transparent color. I made a vertexbuffer like this:

 

CustomVertex.TransformedColored[] pVerts = new CustomVertex.TransformedColored[4];
//590; 494
		GraphicsStream pStream = m_pVertex.Lock(0,0,0);

		pVerts[0].Position = new Vector4(Position.X+Size.Width,Position.Y,Position.Z,1.0f);
		pVerts[1].Position = new Vector4(Position.X+Size.Width,Position.Y+Size.Height,Position.Z,1.0f);
		pVerts[2].Position =new Vector4(Position.X,Position.Y+Size.Height,Position.Z,1.0f);
		pVerts[3].Position =new Vector4(Position.X,Position.Y,Position.Z,1.0f);

		pVerts[0].Color = BackColor.ToArgb();
		pVerts[1].Color = BackColor.ToArgb();
		pVerts[2].Color = BackColor.ToArgb();
		pVerts[3].Color = BackColor.ToArgb();

		pStream.Write(pVerts);

		m_pVertex.Unlock();

 

The BackColor defines a color with an alpha channel.

When i try to render the vertexbuffer, no transparency is applied but the color is visible. The renderstate is defined like this:

 

m_pDevice.RenderState.SeparateAlphaBlendEnabled = true;
		m_pDevice.RenderState.DestinationBlend = Blend.InvSourceAlpha;
		m_pDevice.RenderState.SourceBlend = Blend.SourceAlpha;

 

Any ideas?

Posted
m_pDevice.RenderState.SeparateAlphaBlendEnabled = true;
		m_pDevice.RenderState.DestinationBlend = Blend.InvSourceAlpha;
		m_pDevice.RenderState.SourceBlend = Blend.SourceAlpha;

I think you want to set AlphaBlendEnable, not SeparateAlphaBlendEnabled.

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