Browse Source

Initialize and dispose of whiteTexture in SneakGame.

Fixes #7.

GitOrigin-RevId: 024688e8fc
master
Colin McMillen 4 years ago
parent
commit
4d64d6fa12
  1. 5
      Shared/Debug.cs
  2. 9
      Shared/SneakGame.cs

5
Shared/Debug.cs

@ -34,9 +34,8 @@ namespace SemiColinGames {
static Texture2D whiteTexture; static Texture2D whiteTexture;
public static void Initialize(GraphicsDevice graphics) {
whiteTexture = new Texture2D(graphics, 1, 1);
whiteTexture.SetData(new Color[] { Color.White });
public static void Initialize(Texture2D white) {
whiteTexture = white;
} }
public static void WriteLine(string s) { public static void WriteLine(string s) {

9
Shared/SneakGame.cs

@ -33,6 +33,7 @@ namespace SemiColinGames {
int framesToSuppress = 2; int framesToSuppress = 2;
Texture2D grasslandBg1; Texture2D grasslandBg1;
Texture2D grasslandBg2; Texture2D grasslandBg2;
Texture2D whiteTexture;
Player player; Player player;
World world; World world;
@ -56,8 +57,6 @@ namespace SemiColinGames {
display.Initialize(Window, graphics); display.Initialize(Window, graphics);
display.SetFullScreen(fullScreen); display.SetFullScreen(fullScreen);
Debug.Initialize(GraphicsDevice);
sceneTarget = new RenderTarget2D( sceneTarget = new RenderTarget2D(
GraphicsDevice, camera.Width, camera.Height, false /* mipmap */, GraphicsDevice, camera.Width, camera.Height, false /* mipmap */,
GraphicsDevice.PresentationParameters.BackBufferFormat, DepthFormat.Depth24); GraphicsDevice.PresentationParameters.BackBufferFormat, DepthFormat.Depth24);
@ -88,10 +87,16 @@ namespace SemiColinGames {
linesOfSight = new LinesOfSight(GraphicsDevice); linesOfSight = new LinesOfSight(GraphicsDevice);
grasslandBg1 = Content.Load<Texture2D>("grassland_bg1"); grasslandBg1 = Content.Load<Texture2D>("grassland_bg1");
grasslandBg2 = Content.Load<Texture2D>("grassland_bg2"); grasslandBg2 = Content.Load<Texture2D>("grassland_bg2");
whiteTexture = new Texture2D(GraphicsDevice, 1, 1);
whiteTexture.SetData(new Color[] { Color.White });
Debug.Initialize(whiteTexture);
} }
// Called once per game. Unloads all game content. // Called once per game. Unloads all game content.
protected override void UnloadContent() { protected override void UnloadContent() {
whiteTexture.Dispose();
updateTimer.DumpStats(); updateTimer.DumpStats();
drawTimer.DumpStats(); drawTimer.DumpStats();
} }

Loading…
Cancel
Save