Пример #1
0
        public Texture2D FindTextureByPath(string path)
        {
            if (loadedTextures.ContainsKey(path))
            {
                return(loadedTextures[path]);
            }
            var e = VFileSystemManager.GetFile(path);

            if (e == null)
            {
                return(null);
            }
            string    ext    = e.GetExtension();
            Texture2D result = null;

            switch (ext)
            {
            case ".dds":
                System.Drawing.Bitmap bmp = new DDSImage(e.ReadAllBytes()).BitmapImage;
                result = CreateTexture2DFromBitmap(engine.device, CreateWICBitmapFromGDI(bmp));
                bmp.Dispose();
                break;
            }
            if (result != null)
            {
                loadedTextures.Add(path, result);
            }
            return(result);
        }