コード例 #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
ファイル: Texture.cs プロジェクト: m1lka/DuckHunter
 public void Dispose()
 {
     if (!_disposed)
     {
         SDL.DestroyTexture(_texture);
         _disposed = true;
     }
 }
コード例 #3
0
ファイル: Sprite.cs プロジェクト: slagusev/HatlessEngine
 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
ファイル: Texture.cs プロジェクト: italodirenzo93/sdl2net
        protected virtual void Dispose(bool disposing)
        {
            if (_disposed)
            {
                return;
            }

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

            SDL.DestroyTexture(TexturePtr);

            _disposed = true;
        }
コード例 #6
0
ファイル: Texture.cs プロジェクト: m1lka/DuckHunter
        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);
 }