Пример #1
0
        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);
                }
            }
        }
Пример #2
0
 public void Dispose()
 {
     if (!_disposed)
     {
         SDL.DestroyTexture(_texture);
         _disposed = true;
     }
 }
Пример #3
0
 public void Unload()
 {
     if (Loaded)
     {
         SDL.DestroyTexture(TextureHandle);
         TextureHandle = IntPtr.Zero;
         Loaded        = false;
     }
 }
Пример #4
0
 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());
         }
     }
 }
Пример #5
0
        protected virtual void Dispose(bool disposing)
        {
            if (_disposed)
            {
                return;
            }

            Util.OutputDebugString($"Disposing Texture: disposing = {disposing}");

            SDL.DestroyTexture(TexturePtr);

            _disposed = true;
        }
Пример #6
0
        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()}");
            }
        }
Пример #7
0
 public void Dispose()
 {
     SDL.DestroyTexture(this.IntPtr);
 }