public Texture2dRegion Get(string filename)
 {
     filename = PathHelper.WithStandardSeparators(filename);
     if (!textures.TryGetValue(filename, out Texture2d texture))
     {
         texture = Texture2d.Load(filename, resourceContainer, textureOptions);
         textures.Add(filename, texture);
     }
     return(texture);
 }
Exemple #2
0
        public Texture2d Get(string filename)
        {
            Texture2d texture;

            if (!textures.TryGetValue(filename, out texture))
            {
                texture = Texture2d.Load(filename, resourceManager, textureOptions);
                textures.Add(filename, texture);
            }
            return(texture);
        }
Exemple #3
0
        /// <summary>
        /// Adds a bitmap to the atlas and returns the new region
        /// </summary>
        public Texture2dRegion AddRegion(Bitmap bitmap, string description)
        {
            if (bitmap.Width > width || bitmap.Height > height)
            {
                Trace.WriteLine($"Bitmap \"{description}\" doesn't fit in this atlas");

                var texture = Texture2d.Load(bitmap, description, textureOptions);
                (oversizeTextures ?? (oversizeTextures = new List <Texture2d>())).Add(texture);
                return(texture);
            }

            var atlas  = atlases.Peek();
            var region = atlas.AddRegion(bitmap, description);

            if (region == null)
            {
                Trace.WriteLine($"{this.description} is full, adding an atlas");
                atlas  = pushAtlas();
                region = atlas.AddRegion(bitmap, description);
            }
            return(region);
        }