// Draw_CachePic public static glpic_t CachePic(string path) { for (int i = 0; i < _MenuNumCachePics; i++) { cachepic_t p = _MenuCachePics[i]; if (p.name == path)// !strcmp(path, pic->name)) { return(p.pic); } } if (_MenuNumCachePics == MAX_CACHED_PICS) { Sys.Error("menu_numcachepics == MAX_CACHED_PICS"); } cachepic_t pic = _MenuCachePics[_MenuNumCachePics]; _MenuNumCachePics++; pic.name = path; // // load the pic from disk // byte[] data = Common.LoadFile(path); if (data == null) { Sys.Error("Draw_CachePic: failed to load {0}", path); } dqpicheader_t header = Sys.BytesToStructure <dqpicheader_t>(data, 0); Wad.SwapPic(header); int headerSize = Marshal.SizeOf(typeof(dqpicheader_t)); // HACK HACK HACK --- we need to keep the bytes for // the translatable player picture just for the menu // configuration dialog if (path == "gfx/menuplyr.lmp") { Buffer.BlockCopy(data, headerSize, _MenuPlayerPixels, 0, header.width * header.height); //memcpy (menuplyr_pixels, dat->data, dat->width*dat->height); } glpic_t gl = new glpic_t(); gl.width = header.width; gl.height = header.height; //gl = (glpic_t *)pic->pic.data; gl.texnum = LoadTexture(gl, new ByteArraySegment(data, headerSize)); gl.sl = 0; gl.sh = 1; gl.tl = 0; gl.th = 1; pic.pic = gl; return(gl); }
public static void Init(quakeparms_t parms) { _Params = parms; Cache.Init(1024 * 1024 * 16); // debug Cbuf.Init(); Cmd.Init(); View.Init(); Chase.Init(); InitVCR(parms); Common.Init(parms.basedir, parms.argv); InitLocal(); Wad.LoadWadFile("gfx.wad"); Key.Init(); Con.Init(); Menu.Init(); Progs.Init(); Mod.Init(); Net.Init(); Server.Init(); //Con.Print("Exe: "__TIME__" "__DATE__"\n"); //Con.Print("%4.1f megabyte heap\n",parms->memsize/ (1024*1024.0)); Render.InitTextures(); // needed even for dedicated servers if (Client.Cls.state != ClientActivityState.Dedicated) { _BasePal = Common.LoadFile("gfx/palette.lmp"); if (_BasePal == null) { Sys.Error("Couldn't load gfx/palette.lmp"); } _ColorMap = Common.LoadFile("gfx/colormap.lmp"); if (_ColorMap == null) { Sys.Error("Couldn't load gfx/colormap.lmp"); } // on non win32, mouse comes before video for security reasons Input.Init(); Vid.Init(_BasePal); Drawer.Init(); Scr.Init(); Render.Init(); Sound.Init(); CDAudio.Init(); Sbar.Init(); Client.Init(); } Cbuf.InsertText("exec quake.rc\n"); _IsInitialized = true; Con.DPrint("========Quake Initialized=========\n"); }
//qpic_t *Draw_PicFromWad (char *name); public static glpic_t PicFromWad(string name) { int offset = Wad.GetLumpNameOffset(name); IntPtr ptr = new IntPtr(Wad.DataPointer.ToInt64() + offset); dqpicheader_t header = (dqpicheader_t)Marshal.PtrToStructure(ptr, typeof(dqpicheader_t)); glpic_t gl = new glpic_t(); // (glpic_t)Marshal.PtrToStructure(ptr, typeof(glpic_t)); gl.width = header.width; gl.height = header.height; offset += Marshal.SizeOf(typeof(dqpicheader_t)); // load little ones into the scrap if (gl.width < 64 && gl.height < 64) { int x, y; int texnum = AllocScrapBlock(gl.width, gl.height, out x, out y); _ScrapDirty = true; int k = 0; for (int i = 0; i < gl.height; i++) { for (int j = 0; j < gl.width; j++, k++) { _ScrapTexels[texnum][(y + i) * BLOCK_WIDTH + x + j] = Wad.Data[offset + k];// p->data[k]; } } texnum += _ScrapTexNum; gl.texnum = texnum; gl.sl = (float)((x + 0.01) / (float)BLOCK_WIDTH); gl.sh = (float)((x + gl.width - 0.01) / (float)BLOCK_WIDTH); gl.tl = (float)((y + 0.01) / (float)BLOCK_WIDTH); gl.th = (float)((y + gl.height - 0.01) / (float)BLOCK_WIDTH); _PicCount++; _PicTexels += gl.width * gl.height; } else { gl.texnum = LoadTexture(gl, new ByteArraySegment(Wad.Data, offset)); } return(gl); }
public Host(MainWindow window) { MainWindow = window; Cvars = new Cvars(); // Factories Commands = AddFactory <CommandFactory>( ); CVars = AddFactory <ClientVariableFactory>( ); Commands.Initialise(CVars); // Old Cache = new Cache( ); //CommandBuffer = new CommandBuffer( this ); //Command = new Command( this ); //CVar.Initialise( Command ); View = new View(this); ChaseView = new ChaseView(this); GfxWad = new Wad( ); Keyboard = new Keyboard(this); Console = new Con(this); Menu = new Menu(this); Programs = new Programs(this); ProgramsBuiltIn = new ProgramsBuiltIn(this); Model = new Mod(this); Network = new Network(this); Server = new server(this); Client = new client(this); Video = new Vid(this); DrawingContext = new Drawer(this); Screen = new Scr(this); RenderContext = new render(this); Sound = new snd(this); CDAudio = new cd_audio(this); Hud = new Hud(this); DedicatedServer = new DedicatedServer( ); WadFiles = new Dictionary <String, Wad>( ); WadTextures = new Dictionary <String, String>( ); }
// Draw_Init public static void Init() { for (int i = 0; i < _MenuCachePics.Length; i++) { _MenuCachePics[i] = new cachepic_t(); } if (_glNoBind == null) { _glNoBind = new Cvar("gl_nobind", "0"); _glMaxSize = new Cvar("gl_max_size", "1024"); _glPicMip = new Cvar("gl_picmip", "0"); } // 3dfx can only handle 256 wide textures string renderer = GL.GetString(StringName.Renderer); if (renderer.Contains("3dfx") || renderer.Contains("Glide")) { Cvar.Set("gl_max_size", "256"); } Cmd.Add("gl_texturemode", TextureMode_f); // load the console background and the charset // by hand, because we need to write the version // string into the background before turning // it into a texture int offset = Wad.GetLumpNameOffset("conchars"); byte[] draw_chars = Wad.Data; // draw_chars for (int i = 0; i < 256 * 64; i++) { if (draw_chars[offset + i] == 0) { draw_chars[offset + i] = 255; // proper transparent color } } // now turn them into textures _CharTexture = LoadTexture("charset", 128, 128, new ByteArraySegment(draw_chars, offset), false, true); byte[] buf = Common.LoadFile("gfx/conback.lmp"); if (buf == null) { Sys.Error("Couldn't load gfx/conback.lmp"); } dqpicheader_t cbHeader = Sys.BytesToStructure <dqpicheader_t>(buf, 0); Wad.SwapPic(cbHeader); // hack the version number directly into the pic string ver = String.Format("(c# {0,7:F2}) {1,7:F2}", (float)QDef.CSQUAKE_VERSION, (float)QDef.VERSION); int offset2 = Marshal.SizeOf(typeof(dqpicheader_t)) + 320 * 186 + 320 - 11 - 8 * ver.Length; int y = ver.Length; for (int x = 0; x < y; x++) { CharToConback(ver[x], new ByteArraySegment(buf, offset2 + (x << 3)), new ByteArraySegment(draw_chars, offset)); } _ConBack = new glpic_t(); _ConBack.width = cbHeader.width; _ConBack.height = cbHeader.height; int ncdataIndex = Marshal.SizeOf(typeof(dqpicheader_t)); // cb->data; SetTextureFilters(TextureMinFilter.Nearest, TextureMagFilter.Nearest); _ConBack.texnum = LoadTexture("conback", _ConBack.width, _ConBack.height, new ByteArraySegment(buf, ncdataIndex), false, false); _ConBack.width = Scr.vid.width; _ConBack.height = Scr.vid.height; // save a texture slot for translated picture _TranslateTexture = _TextureExtensionNumber++; // save slots for scraps _ScrapTexNum = _TextureExtensionNumber; _TextureExtensionNumber += MAX_SCRAPS; // // get the other pics we need // _Disc = PicFromWad("disc"); _BackTile = PicFromWad("backtile"); }
public void Initialise(QuakeParameters parms) { Parameters = parms; //Command.SetupWrapper( ); // Temporary workaround - change soon! Cache.Initialise(1024 * 1024 * 512); // debug Commands.Add("flush", Cache.Flush); //CommandBuffer.Initialise( ); // Command.Initialise( ); View.Initialise( ); ChaseView.Initialise( ); InitialiseVCR(parms); MainWindow.Common.Initialise(MainWindow, parms.basedir, parms.argv); InitialiseLocal( ); // Search wads foreach (var wadFile in FileSystem.Search("*.wad")) { if (wadFile == "radiant.wad") { continue; } if (wadFile == "gfx.wad") { continue; } var data = FileSystem.LoadFile(wadFile); if (data == null) { continue; } var wad = new Wad( ); wad.LoadWadFile(wadFile, data); WadFiles.Add(wadFile, wad); var textures = wad._Lumps.Values .Select(s => Encoding.ASCII.GetString(s.name).Replace("\0", "")) .ToArray( ); foreach (var texture in textures) { if (!WadTextures.ContainsKey(texture)) { WadTextures.Add(texture, wadFile); } } } GfxWad.LoadWadFile("gfx.wad"); Keyboard.Initialise( ); Console.Initialise( ); Menu.Initialise( ); Programs.Initialise( ); ProgramsBuiltIn.Initialise( ); Model.Initialise( ); Network.Initialise( ); Server.Initialise( ); //Con.Print("Exe: "__TIME__" "__DATE__"\n"); //Con.Print("%4.1f megabyte heap\n",parms->memsize/ (1024*1024.0)); RenderContext.InitTextures( ); // needed even for dedicated servers if (Client.cls.state != cactive_t.ca_dedicated) { BasePal = FileSystem.LoadFile("gfx/palette.lmp"); if (BasePal == null) { Utilities.Error("Couldn't load gfx/palette.lmp"); } ColorMap = FileSystem.LoadFile("gfx/colormap.lmp"); if (ColorMap == null) { Utilities.Error("Couldn't load gfx/colormap.lmp"); } // on non win32, mouse comes before video for security reasons MainWindow.Input.Initialise(this); Video.Initialise(BasePal); DrawingContext.Initialise( ); Screen.Initialise( ); RenderContext.Initialise( ); Sound.Initialise( ); CDAudio.Initialise( ); Hud.Initialise( ); Client.Initialise( ); } else { DedicatedServer.Initialise( ); } Commands.Buffer.Insert("exec quake.rc\n"); IsInitialised = true; Console.DPrint("========Quake Initialized=========\n"); }