I have a problem resizing textures.
Have a mission screen with a 15 frame animation that plays when you enter the screen and a 17 frame animation when you leave it.
The plane loadout screen has the same animations but it does not resize. I don't get any error on that screen so I know its the resize.
When you run the game, there are no errors generated by the 2 screens but if you go back to the screen before the mission select screen and go through again, then I get an error.
Error message:
<
StartRendering : All active render targets must be the same size with the same multisample type.
Source: Void VerifyDepthRenderTargetCompat()
Stack trace: at Microsoft.Xna.Framework.Graphics.GraphicsDevice.VerifyDepthRenderTargetCompat()
at Microsoft.Xna.Framework.Graphics.GraphicsDevice.Clear(ClearOptions options, Color color, Single depth, Int32 stencil, Rectangle[] regions)
at Microsoft.Xna.Framework.Graphics.GraphicsDevice.Clear(Color color)
at ChaseCameraSample.ChaseCameraGame.StartRendering() in G:\Business\GameCo\Dev\PrizeFlyerCanyons1\ChaseCamera\Game.cs:line 749
>
The code:
public Texture2D resizeTexture(Texture2D sourceTexture, int newWidth,int newHeight)
{
Texture2D resultTexture;
GraphicsDevice graphicsDevice;
RenderTarget2D renderTarget;
Rectangle destinationRectangle;
graphicsDevice = graphics.GraphicsDevice;
renderTarget = new RenderTarget2D(graphicsDevice,
newWidth, newHeight,
1,
graphics.GraphicsDevice.PresentationParameters.BackBufferFormat);//SurfaceFormat.Color
destinationRectangle = new Rectangle(0, 0, newWidth, newHeight);
graphicsDevice.SetRenderTarget(0, renderTarget);
spriteBatchl.Begin();
spriteBatchl.Draw(sourceTexture, destinationRectangle, Color.White);
spriteBatchl.End();
graphicsDevice.SetRenderTarget(0, null);
resultTexture = renderTarget.GetTexture();
return (resultTexture);
}
How can I fix this problem?