From 4d64d6fa12f3b281cdc9a384445fc96f50902145 Mon Sep 17 00:00:00 2001 From: Colin McMillen Date: Thu, 13 Feb 2020 18:36:12 -0500 Subject: [PATCH] Initialize and dispose of whiteTexture in SneakGame. Fixes #7. GitOrigin-RevId: 024688e8fc8ed28950147baefc2fda2005e6aced --- Shared/Debug.cs | 5 ++--- Shared/SneakGame.cs | 9 +++++++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Shared/Debug.cs b/Shared/Debug.cs index 5ce38a8..0167ee0 100644 --- a/Shared/Debug.cs +++ b/Shared/Debug.cs @@ -34,9 +34,8 @@ namespace SemiColinGames { 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) { diff --git a/Shared/SneakGame.cs b/Shared/SneakGame.cs index 7fad51d..c947daa 100644 --- a/Shared/SneakGame.cs +++ b/Shared/SneakGame.cs @@ -33,6 +33,7 @@ namespace SemiColinGames { int framesToSuppress = 2; Texture2D grasslandBg1; Texture2D grasslandBg2; + Texture2D whiteTexture; Player player; World world; @@ -56,8 +57,6 @@ namespace SemiColinGames { display.Initialize(Window, graphics); display.SetFullScreen(fullScreen); - Debug.Initialize(GraphicsDevice); - sceneTarget = new RenderTarget2D( GraphicsDevice, camera.Width, camera.Height, false /* mipmap */, GraphicsDevice.PresentationParameters.BackBufferFormat, DepthFormat.Depth24); @@ -88,10 +87,16 @@ namespace SemiColinGames { linesOfSight = new LinesOfSight(GraphicsDevice); grasslandBg1 = Content.Load("grassland_bg1"); grasslandBg2 = Content.Load("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. protected override void UnloadContent() { + whiteTexture.Dispose(); + updateTimer.DumpStats(); drawTimer.DumpStats(); }