0

I've got some different controls I have that I'm drawing to different size render targets.

If I draw a 64x64 textureA to an 800x600 render target like this.

Graphics.SetRenderTarget(Canvas);
_spriteBatch.Draw(textureA, new Rectangle(0, 0, 64, 64), srcRectangle, Color.White)

And then draw the 800x600 render target to a 1600x900 screen with a call like this

Graphics.SetRenderTarget(null);
_spriteBatch.Draw(Canvas, new Rectangle(100,100,800,600), Color.White

Why is it drawing my textureA very warped and small on the screen.

If I make my Canvas the same size as the backbuffer then it shows up fine, but I'm wondering why this thinks it should shrink my texture, and is there a way to turn this off?

I want to able to create render targets of arbitrary sizes, and then draw them to the screen at their original sizes. Is this possible?

Kyle Gobel
  • 5,530
  • 9
  • 45
  • 68

1 Answers1

0

When you draw to a RenderTarget, the back buffer (or preferred back buffer) is still used. If you are scaling down from the back buffer dimension then any texture that is drawn to the RenderTarget will also be scaled and modified by any changes in the aspect ratio.

If you want to keep your textures in the same aspect, you will need to track the scale and aspect ratio to apply to the destination rectangle when you draw. Would be happy to elaborate or provide code snippets if you could elaborate a bit more on what you are trying to accomplish.

dreamwagon
  • 1,219
  • 1
  • 15
  • 17