From f0630d167940372a5030cdd24b4e8daa54c1ea6a Mon Sep 17 00:00:00 2001 From: Colin McMillen Date: Thu, 9 Jan 2020 16:20:46 -0500 Subject: [PATCH] go back to just a single RenderTarget GitOrigin-RevId: 0b8fc3090098f84047a85804bb5eb2a15249aadd --- Shared/SneakGame.cs | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/Shared/SneakGame.cs b/Shared/SneakGame.cs index f8c0f65..828e3db 100644 --- a/Shared/SneakGame.cs +++ b/Shared/SneakGame.cs @@ -8,12 +8,7 @@ using System.Collections.Generic; namespace SemiColinGames { public class SneakGame : Game { GraphicsDeviceManager graphics; - - // TODO: use a History but implement functions that let us re-use the - // RenderTargets instead of re-creating them every frame? - const int numRenderTargets = 1; - RenderTarget2D[] renderTargets = new RenderTarget2D[numRenderTargets]; - int renderTargetIdx = 0; + RenderTarget2D renderTarget; SpriteBatch spriteBatch; SpriteFont font; @@ -45,11 +40,9 @@ namespace SemiColinGames { Debug.Initialize(GraphicsDevice); - for (int i = 0; i < renderTargets.Length; i++) { - renderTargets[i] = new RenderTarget2D( - GraphicsDevice, camera.Width, camera.Height, false /* mipmap */, - GraphicsDevice.PresentationParameters.BackBufferFormat, DepthFormat.Depth24); - } + renderTarget = new RenderTarget2D( + GraphicsDevice, camera.Width, camera.Height, false /* mipmap */, + GraphicsDevice.PresentationParameters.BackBufferFormat, DepthFormat.Depth24); base.Initialize(); } @@ -109,8 +102,6 @@ namespace SemiColinGames { fpsCounter.Update(); // Draw scene to RenderTarget. - RenderTarget2D renderTarget = renderTargets[renderTargetIdx]; - renderTargetIdx = (renderTargetIdx + 1) % renderTargets.Length; GraphicsDevice.SetRenderTarget(renderTarget); GraphicsDevice.Clear(Color.CornflowerBlue); spriteBatch.Begin(SpriteSortMode.Deferred, null, SamplerState.LinearWrap, null, null);