@binaryfish1 wrote:
Hi
I have a renderTarget texture which I would like to set transparent, draw some stuff offscreen then I copy a part of the renderTarget texture to the main screen.
My code looks like this:
GraphicsDevice.SetRenderTarget(_board2D);
GraphicsDevice.Clear(Color.Transparent);
SpriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend, SamplerState.PointWrap, null, null, null, null);
_board.Draw(SpriteBatch);
SpriteBatch.End();GraphicsDevice.SetRenderTarget(null);
GraphicsDevice.Clear(Color.Yellow);SpriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.Opaque, null, null, null, null, _screenMatrix);
SpriteBatch.Draw(textures[TEXTURE_BACKGROUND], Vector2.Zero, null, Color.White, 0f, Vector2.One, 1, SpriteEffects.None, 0.6f);SpriteBatch.Draw(_board2D,
_boardBoundsView.Location.ToVector2(),
new Rectangle((int)board.ViewPortOffset.X, (int)board.ViewPortOffset.Y, _boardBoundsView.Width, _boardBoundsView.Height),
Color.White,
0,
Vector2.Zero,
Vector2.One,
SpriteEffects.None,
DEPTHBOARD);The result is a black background. If I change the second line to:
GraphicsDevice.Clear(Color.Red);
Then the background becomes red. So a solid colour is OK but a transparent colour is not.
I looked around online and found these:
Which looks like the same as my code
I'm not sure what I am doing wrong?
I'm using Monogame.Framework.WindowsUniversal v3.6.0.1625 on Windows 10.
Posts: 1
Participants: 1