partial work toward keeping multiple render targets around for GIF encoding
GitOrigin-RevId: 8061896562453a95013ada91df852afc9e904c76
This commit is contained in:
parent
524ed70b9d
commit
df6cee8df1
@ -2,13 +2,16 @@
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Microsoft.Xna.Framework.Input;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Jumpy {
|
||||
public class JumpyGame : Game {
|
||||
GraphicsDeviceManager graphics;
|
||||
RenderTarget2D renderTarget;
|
||||
|
||||
const int numRenderTargets = 1;
|
||||
RenderTarget2D[] renderTargets = new RenderTarget2D[numRenderTargets];
|
||||
int renderTargetIdx = 0;
|
||||
|
||||
SpriteBatch spriteBatch;
|
||||
SpriteFont font;
|
||||
KeyboardInput keyboardInput = new KeyboardInput();
|
||||
@ -30,9 +33,11 @@ namespace Jumpy {
|
||||
display.Initialize(Window, graphics);
|
||||
display.SetFullScreen(fullScreen);
|
||||
|
||||
renderTarget = new RenderTarget2D(
|
||||
for (int i = 0; i < renderTargets.Length; i++) {
|
||||
renderTargets[i] = new RenderTarget2D(
|
||||
GraphicsDevice, Camera.Width, Camera.Height, false /* mipmap */,
|
||||
GraphicsDevice.PresentationParameters.BackBufferFormat, DepthFormat.Depth24);
|
||||
}
|
||||
|
||||
base.Initialize();
|
||||
}
|
||||
@ -77,8 +82,9 @@ namespace Jumpy {
|
||||
fpsCounter.Update();
|
||||
|
||||
// Draw scene to RenderTarget.
|
||||
RenderTarget2D renderTarget = renderTargets[renderTargetIdx];
|
||||
renderTargetIdx = (renderTargetIdx + 1) % renderTargets.Length;
|
||||
GraphicsDevice.SetRenderTarget(renderTarget);
|
||||
// GraphicsDevice.DepthStencilState = new DepthStencilState() { DepthBufferEnable = true };
|
||||
GraphicsDevice.Clear(Color.CornflowerBlue);
|
||||
spriteBatch.Begin();
|
||||
player.Draw(gameTime, spriteBatch);
|
||||
|
Loading…
Reference in New Issue
Block a user