I encountered a strange RenderTarget issue, in XNA/Monogame.
I am currently updating my render target at every frame, just to test to see what is happening. When I move the camera around, the positioning of the drawing inside of my rendertarget moves as well.
Notice in the example, how the image moves inside of my render target:
Here is the code for the Render Target draw:
GraphicsDevice.SetRenderTarget(Render);
RoundLineManager.Draw(Branches.GetAllObjects(), new Color(102, 50, 18), Matrix.Identity * Camera.View * Camera.Projection, RoundLineManager.TechniqueNames[0]);
SpriteBatch.Begin(SpriteSortMode.BackToFront, null, null, null, null, null, Camera.View);
foreach (Pool<Leaf>.Node l in Leaves.ActiveNodes)
if (l.Item.Visible)
l.Item.Draw();
SpriteBatch.End();
GraphicsDevice.SetRenderTarget(null);
Here is the related Camera properties:
public Matrix View
{
get
{
return Matrix.CreateTranslation(new Vector3(-_pos.X, -_pos.Y, 0)) *
Matrix.CreateRotationZ(Rotation) *
Matrix.CreateScale(new Vector3(Zoom, Zoom, 1)) *
Matrix.CreateTranslation(new Vector3(ViewportWidth * 0.5f + shakeOffset.X, ViewportHeight * 0.5f + shakeOffset.Y, 0));
}
}
public Matrix Projection
{
get
{
return Matrix.CreateOrthographicOffCenter(0, Infinidrill.GraphicsDevice.Viewport.Width, Infinidrill.GraphicsDevice.Viewport.Height, 0, 0, 1);
}
}