Esempio n. 1
0
 internal bool LoadFileInternal(GraphicsDevice gfxDevice, BinaryReader reader, ref SEFileHeader header, out object obj)
 => LoadFile(gfxDevice, reader, ref header, out obj);
Esempio n. 2
0
 protected abstract bool LoadFile(GraphicsDevice gfxDevice, BinaryReader reader, ref SEFileHeader header, out object obj);
Esempio n. 3
0
        protected override bool LoadFile(GraphicsDevice gfxDevice, BinaryReader reader, ref SEFileHeader header, out object obj)
        {
            if (gfxDevice == null)
            {
                throw new HeadlessNotSupportedException($"Texture '{reader}' was not loaded in headless display mode.");
            }

            Texture2D tex;

            if (header.OriginalExtension == ".dds")
            {
                DDSStruct ddsHeader = DDSStruct.Create(reader);
                tex = new Texture2D(gfxDevice, (int)ddsHeader.width, (int)ddsHeader.height, false, ddsHeader.GetSurfaceFormat());
                byte[] textureData = reader.ReadBytes((int)header.FileSize);
                tex.SetData(textureData, 0, textureData.Length);
            }
            else
            {
                tex = Texture2D.FromStream(gfxDevice, reader.BaseStream);
            }

            obj = tex;
            return(true);
        }