private void CreateRenderTargets(GraphicsDevice graphics) { var pp = graphics.PresentationParameters; currLightMapScale = GameMain.Config.LightMapScale; LightMap?.Dispose(); LightMap = new RenderTarget2D(graphics, (int)(GameMain.GraphicsWidth * GameMain.Config.LightMapScale), (int)(GameMain.GraphicsHeight * GameMain.Config.LightMapScale), false, pp.BackBufferFormat, pp.DepthStencilFormat, pp.MultiSampleCount, RenderTargetUsage.DiscardContents); SpecularMap?.Dispose(); SpecularMap = new RenderTarget2D(graphics, (int)(GameMain.GraphicsWidth * GameMain.Config.LightMapScale), (int)(GameMain.GraphicsHeight * GameMain.Config.LightMapScale), false, pp.BackBufferFormat, pp.DepthStencilFormat, pp.MultiSampleCount, RenderTargetUsage.DiscardContents); HighlightMap?.Dispose(); HighlightMap = new RenderTarget2D(graphics, (int)(GameMain.GraphicsWidth * GameMain.Config.LightMapScale), (int)(GameMain.GraphicsHeight * GameMain.Config.LightMapScale), false, pp.BackBufferFormat, pp.DepthStencilFormat, pp.MultiSampleCount, RenderTargetUsage.DiscardContents); LosTexture?.Dispose(); LosTexture = new RenderTarget2D(graphics, (int)(GameMain.GraphicsWidth * GameMain.Config.LightMapScale), (int)(GameMain.GraphicsHeight * GameMain.Config.LightMapScale), false, SurfaceFormat.Color, DepthFormat.None); }
/// <summary> /// Dispose resources /// </summary> public void Dispose() { if (Mesh != null) { Mesh.Dispose(); } Mesh = null; if (SpecularMap != null) { SpecularMap.Dispose(); } SpecularMap = null; if (HeightMap != null) { HeightMap.Dispose(); } HeightMap = null; if (BumpMap != null) { BumpMap.Dispose(); } BumpMap = null; if (DiffuseMap != null) { DiffuseMap.Dispose(); } DiffuseMap = null; }
private bool disposedValue = false; // To detect redundant calls protected virtual void Dispose(bool disposing) { if (!disposedValue) { if (disposing) { // TODO: dispose managed state (managed objects). } if (DiffuseMap != null) { DiffuseMap.Dispose(); } if (NormalMap != null) { NormalMap.Dispose(); } if (DiffuseAlphaMap != null) { DiffuseAlphaMap.Dispose(); } if (ColorTable != null) { ColorTable.Dispose(); } if (MaskMap != null) { MaskMap.Dispose(); } if (SpecularMap != null) { SpecularMap.Dispose(); } // TODO: free unmanaged resources (unmanaged objects) and override a finalizer below. // TODO: set large fields to null. disposedValue = true; } }