internal static void CleanupFontTextures() { foreach (Font font in Fonts.Values) { List <Tuple <string, Color> > removeTextures = new List <Tuple <string, Color> >(); foreach (KeyValuePair <Tuple <string, Color>, IntPtr> texture in font.Textures) { //delete texture if it hasn't been used for 10 steps if (font.TexturesDrawsUnused[texture.Key] == 10) { SDL.DestroyTexture(texture.Value); removeTextures.Add(texture.Key); } font.TexturesDrawsUnused[texture.Key]++; } foreach (Tuple <string, Color> texture in removeTextures) { font.Textures.Remove(texture); font.TexturesDrawsUnused.Remove(texture); } } }
public void Dispose() { if (!_disposed) { SDL.DestroyTexture(_texture); _disposed = true; } }
public void Unload() { if (Loaded) { SDL.DestroyTexture(TextureHandle); TextureHandle = IntPtr.Zero; Loaded = false; } }
public void Dispose() { SDL.DestroyRenderer(this.IntPtr); if (TextureManager != null) { var queue = new Queue <IntPtr>(TextureManager.Values.Select(x => x.IntPtr)); while (queue.Any()) { SDL.DestroyTexture(queue.Dequeue()); } } }
protected virtual void Dispose(bool disposing) { if (_disposed) { return; } Util.OutputDebugString($"Disposing Texture: disposing = {disposing}"); SDL.DestroyTexture(TexturePtr); _disposed = true; }
public void LoadTextureFromBMP(string pathToFile, IntPtr renderer) { if (_texture != IntPtr.Zero) { SDL.DestroyTexture(_texture); } var surface = SDL.LoadBMP(pathToFile); if (surface == IntPtr.Zero) { throw new Exception($"BMP was not loaded. Error: {SDL.GetError()}"); } _texture = SDL.CreateTextureFromSurface(renderer, surface); SDL.FreeSurface(surface); if (_texture == IntPtr.Zero) { throw new Exception($"Texture was not create. Error: {SDL.GetError()}"); } }
public void Dispose() { SDL.DestroyTexture(this.IntPtr); }