Hello, i am drawing a Texture2D on a RenderDevice2D in order to store the generated Image for later use.
Actually this works fine for me in many scenarios, but i got one scenario, where i all Pixels turn Black+Transparency on draw, and i have no idea why. Its MonoGame on WindowsGL. I use Cocos2D on top, but it is not involved here in any way.
public Microsoft.Xna.Framework.Graphics.Texture2D ApplyShaderToTexture(Microsoft.Xna.Framework.Graphics.Texture2D texture)
{
Texture2D blurredTexture = m_gaussianBlurShader.ApplyShaderToTexture(texture);
//the blurredTexture do have color informationen.
RenderTarget2D renderTarget = new RenderTarget2D(m_graphicsDevice, texture.Width, texture.Height);
m_graphicsDevice.SetRenderTarget(renderTarget);
m_graphicsDevice.Clear(Color.Transparent);
using (SpriteBatch batch = new SpriteBatch(m_graphicsDevice))
{
// i tried several begin Options here, but all i tried deliver the black graphic, or an entire transparent one.
//batch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend);
batch.Begin();
// batch.Begin(0, BlendState.Opaque, null, null, null, null);
//todo: apply another effect here.
batch.Draw(blurredTexture, new Microsoft.Xna.Framework.Rectangle(0, 0, blurredTexture.Width, blurredTexture.Height), Color.Transparent);
batch.End();
}
m_graphicsDevice.SetRenderTarget(null);
return renderTarget;