Initialize and dispose of whiteTexture in SneakGame.

Fixes #7.

GitOrigin-RevId: 024688e8fc8ed28950147baefc2fda2005e6aced
This commit is contained in:
Colin McMillen 2020-02-13 18:36:12 -05:00
parent 036d932476
commit 4d64d6fa12
2 changed files with 9 additions and 5 deletions

View File

@ -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) {

View File

@ -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<Texture2D>("grassland_bg1");
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.
protected override void UnloadContent() {
whiteTexture.Dispose();
updateTimer.DumpStats();
drawTimer.DumpStats();
}