//qpic_t *Draw_PicFromWad (char *name); public static BasePicture FromWad(BaseDevice device, Wad wad, string name, string filter = "GL_LINEAR_MIPMAP_NEAREST") { if (BasePicture.PicturePool.ContainsKey(name)) { return(BasePicture.PicturePool[name]); } var offset = wad.GetLumpNameOffset(name); var ptr = new IntPtr(wad.DataPointer.ToInt64( ) + offset); var header = ( WadPicHeader )Marshal.PtrToStructure(ptr, typeof(WadPicHeader)); offset += Marshal.SizeOf(typeof(WadPicHeader)); return(BasePicture.FromBuffer(device, new(wad.Data, offset), header.width, header.height, name, filter)); }
public static BasePicture FromFile(BaseDevice device, string path, string filter = "GL_LINEAR_MIPMAP_NEAREST", bool ignoreAtlas = false) { if (BasePicture.PicturePool.ContainsKey(path)) { return(BasePicture.PicturePool[path]); } var data = FileSystem.LoadFile(path); if (data == null) { Utilities.Error($"BaseTexture_FromFile: failed to load {path}"); } var ext = Path.GetExtension(path).ToLower( ).Substring(1); switch (ext) { case "lmp": var header = Utilities.BytesToStructure <WadPicHeader>(data, 0); EndianHelper.SwapPic(header); var headerSize = Marshal.SizeOf(typeof(WadPicHeader)); return(BasePicture.FromBuffer(device, new(data, headerSize), ( int )header.width, ( int )header.height, path, filter, ignoreAtlas)); case "jpg": case "bmp": case "png": break; case "tga": break; } return(null); }