internal static pTexture Load(string name)
        {
            TextureGl glTexture;

            if (SpriteTextureCache.TryGetValue(name, out glTexture) && glTexture.Loaded)
            {
                glTexture.usedSinceLastModeChange = true;
                return(new pTexture(glTexture, glTexture.TextureHeight, glTexture.TextureWidth));
            }

            string path = @"Skins/Default/" + name + "_" + GameBase.SpriteSheetResolution + ".png";

            if (NativeAssetManager.Instance.FileExists(path))
            {
                pTexture texture = pTexture.FromFile(path);

                if (glTexture != null)
                {
                    //steal the loaded GL texture from the newly loaded pTexture.
                    glTexture.Id         = texture.TextureGl.Id;
                    texture.TextureGl.Id = -1;

                    texture.TextureGl = glTexture;
                    return(texture);
                }

                SpriteTextureCache.Add(name, texture.TextureGl);
                return(texture);
            }

            return(null);
        }
 public static void RegisterDisposable(pTexture t)
 {
     if (t == null)
     {
         throw new NullReferenceException("tried to add a null texture to DisposableTextures");
     }
     DisposableTextures.Add(t);
 }
        internal static pTexture[] LoadAnimation(OsuTexture osuTexture, int count)
        {
            pTexture[] textures;

            string name = osuTexture.ToString();

            if (AnimationCache.TryGetValue(name, out textures))
            {
                return(textures);
            }

            textures = new pTexture[count];

            for (int i = 0; i < count; i++)
            {
                textures[i] = Load(osuTexture + i);
            }

            AnimationCache.Add(name, textures);
            return(textures);
        }
        internal static pTexture Load(OsuTexture texture)
        {
            SpriteSheetTexture info;

            if (textureLocations.TryGetValue(texture, out info))
            {
                pTexture tex = Load(info.SheetName);
                tex.OsuTextureInfo = texture;

                //necessary?
                tex.X      = info.X;
                tex.Y      = info.Y;
                tex.Width  = info.Width;
                tex.Height = info.Height;

                return(tex);
            }

            //fallback to separate files (or don't!)
            return(null);
        }