hello everyone, thx in advance for your help :).
The problem that i have is about rendering in xna4 and kinect, when i got a colorframe from kinect, i copy it to a texture2D and then render it to a rendertarget, but my render target has more resolution. that's not a problem since I dont need to fill the whole screen, but i need the sorrounding parts to be transparent ...
I obviously make a
graphicsdevice.clear(color.transparent)
, but it renders purple ... testing and testing i got that if i render it slowly (i make a check for the colorframe ready), the render target transparency works fine "sometimes", since the purple parts appears like blinking.
any idea what is happening?,
my code for rendering:
GraphicsDevice.SetRenderTarget(Full);
if (SystemElementList.OpenedFileList.Count > 0)
{
GraphicsDevice.Clear(Color.White);
for (int i = SystemElementList.OpenedFileList[SystemElementList.actualFile].LayerList.Count - 1; i > -1; i--)
{
Layer Lay = SystemElementList.OpenedFileList[SystemElementList.actualFile].LayerList[i];
if (Lay.Update && Lay.Visible)
{
if (Lay.renderedLayer == null) Lay.renderedLayer = new RenderTarget2D(GraphicsDevice, GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height);
GraphicsDevice.SetRenderTarget(Lay.renderedLayer);
GraphicsDevice.Clear(Color.Transparent);
sprite.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend);
if (Lay.HasBackground)
{
sprite.Draw(Lay.Background, Vector2.Zero, new Rectangle(0, 0, GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height), Color.White);
}
foreach (ObjetoRenderizable Obj in Lay.RenderList)
{
Obj.render2D(GraphicsDevice, ref sprite);
}
if (Lay.Cleanable)
{
}
sprite.End();
Lay.Update = false;
}
if (Lay.Visible && Lay.renderedLayer != null)
{
GraphicsDevice.SetRenderTarget(Full);
sprite.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend);
sprite.Draw(Lay.renderedLayer, Vector2.Zero, Color.White);
sprite.End();
}
Lay = null;
}
}
else
{
GraphicsDevice.Clear(Color.Gray);
}
GraphicsDevice.SetRenderTarget(null);
GraphicsDevice.Clear(Color.Gray);
sprite.Begin(SpriteSortMode.Immediate, BlendState.Opaque);
sprite.Draw(Full, Vector2.Zero, Color.White);
sprite.End();