Browse Source

go back to just a single RenderTarget

GitOrigin-RevId: 0b8fc30900
master
Colin McMillen 4 years ago
parent
commit
f0630d1679
  1. 17
      Shared/SneakGame.cs

17
Shared/SneakGame.cs

@ -8,12 +8,7 @@ using System.Collections.Generic;
namespace SemiColinGames {
public class SneakGame : Game {
GraphicsDeviceManager graphics;
// TODO: use a History<RenderTarget2D> 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);

Loading…
Cancel
Save