Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Game1 : Game
- {
- private GraphicsDeviceManager graphics;
- private SpriteBatch spriteBatch;
- private RenderTarget2D renderTarget;
- private int gameWidth = 320;
- private int gameHeight = 180;
- private Rectangle upScaledResulution= new Rectangle(0, 0, 1920, 1080);
- public Game1()
- {
- graphics = new GraphicsDeviceManager(this);
- Content.RootDirectory = "Content";
- IsMouseVisible = true;
- }
- protected override void Initialize()
- {
- // TODO: Add your initialization logic here
- graphics.PreferredBackBufferWidth = 1920;
- graphics.PreferredBackBufferHeight = 1080;
- graphics.ApplyChanges();
- renderTarget = new RenderTarget2D(GraphicsDevice, gameWidth, gameHeight);
- base.Initialize();
- }
- protected override void LoadContent()
- {
- spriteBatch = new SpriteBatch(GraphicsDevice);
- //load your content like normal here
- }
- protected override void Update(GameTime gameTime)
- {
- if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
- Exit();
- base.Update(gameTime);
- }
- protected override void Draw(GameTime gameTime)
- {
- GraphicsDevice.SetRenderTarget(renderTarget);
- GraphicsDevice.Clear(Color.CornflowerBlue);
- spriteBatch.Begin(samplerState: SamplerState.PointClamp);
- //draw your sprites, just like you normally would here
- spriteBatch.End();
- GraphicsDevice.SetRenderTarget(null);
- spriteBatch.Begin(samplerState: SamplerState.PointClamp);
- //this will draw the rendertarget to the screen
- spriteBatch.Draw(renderTarget, upScaledResulution, Color.White);
- spriteBatch.End();
- base.Draw(gameTime);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement