Hi mason-wolf, here what i do:
-
Don’t zoom with the camera, stay at 1x scale.
-
Declare a
RenderTarget2Dwith the native resolution you want, for me, it was 320x240. (Don’t do this in the Draw loop or the Update Loop, do this before that):
PresentationParameters pp = Graphics.GraphicsDevice.PresentationParameters; _renderTarget = new RenderTarget2D(Graphics.GraphicsDevice, 320, 240, false, SurfaceFormat.Color, DepthFormat.None, pp.MultiSampleCount, RenderTargetUsage.DiscardContents); -
Before you begin to draw anything in the Draw loop, change the RenderTarget2D of the GraphicsDevice:
GraphicsDevice.SetRenderTarget(_renderTarget); GraphicsDevice.Clear(Color.Transparent); GraphicsDevice.BlendState = BlendState.AlphaBlend; GraphicsDevice.SamplerStates[0] = SamplerState.PointClamp; GraphicsDevice.RasterizerState = RasterizerState.CullNone; -
Draw what you need
-
After you have finish to draw your game, reset the RenderTarget of the GraphicsDevice:
GraphicsDevice.SetRenderTarget(null); GraphicsDevice.Clear(Color.CornflowerBlue); //I do this to have a background color -
Now you have a “Texture” of your “entire game”, simply draw it at the scale you want, here I put 640x480 (be sure the scaling is consistant if you want Perfect Pixel):
SpriteBatch.Begin(samplerState: SamplerState.PointClamp); SpriteBatch.Draw(_renderTarget, destinationRectangle: new Rectangle(0, 0, 640, 480), color: Color.White); SpriteBatch.End(); -
NOTE for Mongame.Extended.Tiled:
If you have a instantiate your Camera2D with a ViewportAdapter, be sure to that it’s aDefaultViewportAdapterand not aBoxingViewportAdapterorScalingViewportAdapter, these two seems to change the Viewport when the Window Size change (if somebody can help with that, it will be nice, but for now, it’s work withDefaultViewportAdapter)