// 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); }
// Draw_AlphaPic public static void DrawAlphaPic(int x, int y, glpic_t pic, float alpha) { if (_ScrapDirty) { UploadScrap(); } GL.Disable(EnableCap.AlphaTest); GL.Enable(EnableCap.Blend); GL.Color4(1f, 1f, 1f, alpha); Bind(pic.texnum); GL.Begin(BeginMode.Quads); GL.TexCoord2(pic.sl, pic.tl); GL.Vertex2(x, y); GL.TexCoord2(pic.sh, pic.tl); GL.Vertex2(x + pic.width, y); GL.TexCoord2(pic.sh, pic.th); GL.Vertex2(x + pic.width, y + pic.height); GL.TexCoord2(pic.sl, pic.th); GL.Vertex2(x, y + pic.height); GL.End(); GL.Color4(1f, 1f, 1f, 1f); GL.Enable(EnableCap.AlphaTest); GL.Disable(EnableCap.Blend); }
private static bool _IsMouseWindowed; // windowed_mouse (don't confuse with _windowed_mouse cvar) // scr_fullupdate set to 0 to force full redraw // SCR_Init public static void Init() { if (_ViewSize == null) { _ViewSize = new Cvar("viewsize", "100", true); _Fov = new Cvar("fov", "90"); // 10 - 170 _ConSpeed = new Cvar("scr_conspeed", "3000"); _CenterTime = new Cvar("scr_centertime", "2"); _ShowRam = new Cvar("showram", "1"); _ShowTurtle = new Cvar("showturtle", "0"); _ShowPause = new Cvar("showpause", "1"); _PrintSpeed = new Cvar("scr_printspeed", "8"); _glTripleBuffer = new Cvar("gl_triplebuffer", "1", true); } // // register our commands // Cmd.Add("screenshot", ScreenShot_f); Cmd.Add("sizeup", SizeUp_f); Cmd.Add("sizedown", SizeDown_f); _Ram = Drawer.PicFromWad("ram"); _Net = Drawer.PicFromWad("net"); _Turtle = Drawer.PicFromWad("turtle"); if (Common.HasParam("-fullsbar")) { FullSbarDraw = true; } _IsInitialized = true; }
/// <summary> /// Sbar_FinaleOverlay /// </summary> public static void FinaleOverlay() { Scr.CopyEverithing = true; glpic_t pic = Drawer.CachePic("gfx/finale.lmp"); Drawer.DrawTransPic((Scr.vid.width - pic.width) / 2, 16, pic); }
// Draw_TransPic public static void DrawTransPic(int x, int y, glpic_t pic) { if (x < 0 || (uint)(x + pic.width) > Scr.vid.width || y < 0 || (uint)(y + pic.height) > Scr.vid.height) { Sys.Error("Draw_TransPic: bad coordinates"); } DrawPic(x, y, pic); }
// Sbar_DrawPic static void DrawPic(int x, int y, glpic_t pic) { if (Client.Cl.gametype == Protocol.GAME_DEATHMATCH) { Drawer.DrawPic(x, y + (Scr.vid.height - SBAR_HEIGHT), pic); } else { Drawer.DrawPic(x + ((Scr.vid.width - 320) >> 1), y + (Scr.vid.height - SBAR_HEIGHT), pic); } }
// Sbar_DeathmatchOverlay static void DeathmatchOverlay() { Scr.CopyEverithing = true; Scr.FullUpdate = 0; glpic_t pic = Drawer.CachePic("gfx/ranking.lmp"); Menu.DrawPic((320 - pic.width) / 2, 8, pic); // scores SortFrags(); // draw the text int l = _ScoreBoardLines; int x = 80 + ((Scr.vid.width - 320) >> 1); int y = 40; for (int i = 0; i < l; i++) { int k = _FragSort[i]; Scoreboard s = Client.Cl.scores[k]; if (String.IsNullOrEmpty(s.name)) { continue; } // draw background int top = s.colors & 0xf0; int bottom = (s.colors & 15) << 4; top = ColorForMap(top); bottom = ColorForMap(bottom); Drawer.Fill(x, y, 40, 4, top); Drawer.Fill(x, y + 4, 40, 4, bottom); // draw number string num = s.frags.ToString().PadLeft(3); Drawer.DrawCharacter(x + 8, y, num[0]); Drawer.DrawCharacter(x + 16, y, num[1]); Drawer.DrawCharacter(x + 24, y, num[2]); if (k == Client.Cl.viewentity - 1) { Drawer.DrawCharacter(x - 8, y, 12); } // draw name Drawer.DrawString(x + 64, y, s.name); y += 10; } }
/// <summary> /// SCR_DrawLoading /// </summary> private static void DrawLoading() { if (!_DrawLoading) { return; } glpic_t pic = Drawer.CachePic("gfx/loading.lmp"); Drawer.DrawPic((vid.width - pic.width) / 2, (vid.height - 48 - pic.height) / 2, pic); }
/// <summary> /// Draw_TransPicTranslate /// Only used for the player color selection menu /// </summary> public static void TransPicTranslate(int x, int y, glpic_t pic, byte[] translation) { Bind(_TranslateTexture); int c = pic.width * pic.height; int destOffset = 0; uint[] trans = new uint[64 * 64]; for (int v = 0; v < 64; v++, destOffset += 64) { int srcOffset = ((v * pic.height) >> 6) * pic.width; for (int u = 0; u < 64; u++) { uint p = _MenuPlayerPixels[srcOffset + ((u * pic.width) >> 6)]; if (p == 255) { trans[destOffset + u] = p; } else { trans[destOffset + u] = Vid.Table8to24[translation[p]]; } } } GCHandle handle = GCHandle.Alloc(trans, GCHandleType.Pinned); try { GL.TexImage2D(TextureTarget.Texture2D, 0, Drawer.AlphaFormat, 64, 64, 0, PixelFormat.Rgba, PixelType.UnsignedByte, handle.AddrOfPinnedObject()); } finally { handle.Free(); } SetTextureFilters(TextureMinFilter.Linear, TextureMagFilter.Linear); GL.Color3(1f, 1, 1); GL.Begin(BeginMode.Quads); GL.TexCoord2(0f, 0); GL.Vertex2((float)x, y); GL.TexCoord2(1f, 0); GL.Vertex2((float)x + pic.width, y); GL.TexCoord2(1f, 1); GL.Vertex2((float)x + pic.width, y + pic.height); GL.TexCoord2(0f, 1); GL.Vertex2((float)x, y + pic.height); GL.End(); }
// DrawPause private static void DrawPause() { if (_ShowPause.Value == 0) // turn off for screenshots { return; } if (!Client.cl.paused) { return; } glpic_t pic = Drawer.CachePic("gfx/pause.lmp"); Drawer.DrawPic((vid.width - pic.width) / 2, (vid.height - 48 - pic.height) / 2, pic); }
//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); }
// Draw_Pic(int x, int y, qpic_t* pic) public static void DrawPic(int x, int y, glpic_t pic) { if (_ScrapDirty) { UploadScrap(); } GL.Color4(1f, 1f, 1f, 1f); Bind(pic.texnum); GL.Begin(BeginMode.Quads); GL.TexCoord2(pic.sl, pic.tl); GL.Vertex2(x, y); GL.TexCoord2(pic.sh, pic.tl); GL.Vertex2(x + pic.width, y); GL.TexCoord2(pic.sh, pic.th); GL.Vertex2(x + pic.width, y + pic.height); GL.TexCoord2(pic.sl, pic.th); GL.Vertex2(x, y + pic.height); GL.End(); }
/// <summary> /// Sbar_IntermissionOverlay /// called each frame after the level has been completed /// </summary> public static void IntermissionOverlay() { Scr.CopyEverithing = true; Scr.FullUpdate = 0; if (Client.Cl.gametype == Protocol.GAME_DEATHMATCH) { Sbar.DeathmatchOverlay(); return; } glpic_t pic = Drawer.CachePic("gfx/complete.lmp"); Drawer.DrawPic(64, 24, pic); pic = Drawer.CachePic("gfx/inter.lmp"); Drawer.DrawTransPic(0, 56, pic); // time int dig = Client.Cl.completed_time / 60; IntermissionNumber(160, 64, dig, 3, 0); int num = Client.Cl.completed_time - dig * 60; Drawer.DrawTransPic(234, 64, _Colon); Drawer.DrawTransPic(246, 64, _Nums[0, num / 10]); Drawer.DrawTransPic(266, 64, _Nums[0, num % 10]); IntermissionNumber(160, 104, Client.Cl.stats[QStats.STAT_SECRETS], 3, 0); Drawer.DrawTransPic(232, 104, _Slash); IntermissionNumber(240, 104, Client.Cl.stats[QStats.STAT_TOTALSECRETS], 3, 0); IntermissionNumber(160, 144, Client.Cl.stats[QStats.STAT_MONSTERS], 3, 0); Drawer.DrawTransPic(232, 144, _Slash); IntermissionNumber(240, 144, Client.Cl.stats[QStats.STAT_TOTALMONSTERS], 3, 0); }
/// <summary> /// Draw_TransPicTranslate /// Only used for the player color selection menu /// </summary> public static void TransPicTranslate(int x, int y, glpic_t pic, byte[] translation) { Bind(_TranslateTexture); int c = pic.width * pic.height; int destOffset = 0; uint[] trans = new uint[64 * 64]; for (int v = 0; v < 64; v++, destOffset += 64) { int srcOffset = ((v * pic.height) >> 6) * pic.width; for (int u = 0; u < 64; u++) { uint p = _MenuPlayerPixels[srcOffset + ((u * pic.width) >> 6)]; if (p == 255) trans[destOffset + u] = p; else trans[destOffset + u] = Vid.Table8to24[translation[p]]; } } GCHandle handle = GCHandle.Alloc(trans, GCHandleType.Pinned); try { GL.TexImage2D(TextureTarget.Texture2D, 0, Drawer.AlphaFormat, 64, 64, 0, PixelFormat.Rgba, PixelType.UnsignedByte, handle.AddrOfPinnedObject()); } finally { handle.Free(); } SetTextureFilters(TextureMinFilter.Linear, TextureMagFilter.Linear); GL.Color3(1f, 1, 1); GL.Begin(BeginMode.Quads); GL.TexCoord2(0f, 0); GL.Vertex2((float)x, y); GL.TexCoord2(1f, 0); GL.Vertex2((float)x + pic.width, y); GL.TexCoord2(1f, 1); GL.Vertex2((float)x + pic.width, y + pic.height); GL.TexCoord2(0f, 1); GL.Vertex2((float)x, y + pic.height); GL.End(); }
//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; }
// 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"); }
// Draw_Pic(int x, int y, qpic_t* pic) public static void DrawPic(int x, int y, glpic_t pic) { if (_ScrapDirty) UploadScrap(); GL.Color4(1f, 1f, 1f, 1f); Bind(pic.texnum); GL.Begin(BeginMode.Quads); GL.TexCoord2(pic.sl, pic.tl); GL.Vertex2(x, y); GL.TexCoord2(pic.sh, pic.tl); GL.Vertex2(x + pic.width, y); GL.TexCoord2(pic.sh, pic.th); GL.Vertex2(x + pic.width, y + pic.height); GL.TexCoord2(pic.sl, pic.th); GL.Vertex2(x, y + pic.height); GL.End(); }
/// <summary> /// M_DrawTransPicTranslate /// </summary> public static void DrawTransPicTranslate(int x, int y, glpic_t pic) { Drawer.TransPicTranslate(x + ((Scr.vid.width - 320) >> 1), y, pic, _TranslationTable); }
// Sbar_Init public static void Init() { for (int i = 0; i < 10; i++) { string str = i.ToString(); _Nums[0, i] = Drawer.PicFromWad("num_" + str); _Nums[1, i] = Drawer.PicFromWad("anum_" + str); } _Nums[0, 10] = Drawer.PicFromWad("num_minus"); _Nums[1, 10] = Drawer.PicFromWad("anum_minus"); _Colon = Drawer.PicFromWad("num_colon"); _Slash = Drawer.PicFromWad("num_slash"); _Weapons[0, 0] = Drawer.PicFromWad("inv_shotgun"); _Weapons[0, 1] = Drawer.PicFromWad("inv_sshotgun"); _Weapons[0, 2] = Drawer.PicFromWad("inv_nailgun"); _Weapons[0, 3] = Drawer.PicFromWad("inv_snailgun"); _Weapons[0, 4] = Drawer.PicFromWad("inv_rlaunch"); _Weapons[0, 5] = Drawer.PicFromWad("inv_srlaunch"); _Weapons[0, 6] = Drawer.PicFromWad("inv_lightng"); _Weapons[1, 0] = Drawer.PicFromWad("inv2_shotgun"); _Weapons[1, 1] = Drawer.PicFromWad("inv2_sshotgun"); _Weapons[1, 2] = Drawer.PicFromWad("inv2_nailgun"); _Weapons[1, 3] = Drawer.PicFromWad("inv2_snailgun"); _Weapons[1, 4] = Drawer.PicFromWad("inv2_rlaunch"); _Weapons[1, 5] = Drawer.PicFromWad("inv2_srlaunch"); _Weapons[1, 6] = Drawer.PicFromWad("inv2_lightng"); for (int i = 0; i < 5; i++) { string s = "inva" + (i + 1).ToString(); _Weapons[2 + i, 0] = Drawer.PicFromWad(s + "_shotgun"); _Weapons[2 + i, 1] = Drawer.PicFromWad(s + "_sshotgun"); _Weapons[2 + i, 2] = Drawer.PicFromWad(s + "_nailgun"); _Weapons[2 + i, 3] = Drawer.PicFromWad(s + "_snailgun"); _Weapons[2 + i, 4] = Drawer.PicFromWad(s + "_rlaunch"); _Weapons[2 + i, 5] = Drawer.PicFromWad(s + "_srlaunch"); _Weapons[2 + i, 6] = Drawer.PicFromWad(s + "_lightng"); } _Ammo[0] = Drawer.PicFromWad("sb_shells"); _Ammo[1] = Drawer.PicFromWad("sb_nails"); _Ammo[2] = Drawer.PicFromWad("sb_rocket"); _Ammo[3] = Drawer.PicFromWad("sb_cells"); _Armor[0] = Drawer.PicFromWad("sb_armor1"); _Armor[1] = Drawer.PicFromWad("sb_armor2"); _Armor[2] = Drawer.PicFromWad("sb_armor3"); _Items[0] = Drawer.PicFromWad("sb_key1"); _Items[1] = Drawer.PicFromWad("sb_key2"); _Items[2] = Drawer.PicFromWad("sb_invis"); _Items[3] = Drawer.PicFromWad("sb_invuln"); _Items[4] = Drawer.PicFromWad("sb_suit"); _Items[5] = Drawer.PicFromWad("sb_quad"); _Sigil[0] = Drawer.PicFromWad("sb_sigil1"); _Sigil[1] = Drawer.PicFromWad("sb_sigil2"); _Sigil[2] = Drawer.PicFromWad("sb_sigil3"); _Sigil[3] = Drawer.PicFromWad("sb_sigil4"); _Faces[4, 0] = Drawer.PicFromWad("face1"); _Faces[4, 1] = Drawer.PicFromWad("face_p1"); _Faces[3, 0] = Drawer.PicFromWad("face2"); _Faces[3, 1] = Drawer.PicFromWad("face_p2"); _Faces[2, 0] = Drawer.PicFromWad("face3"); _Faces[2, 1] = Drawer.PicFromWad("face_p3"); _Faces[1, 0] = Drawer.PicFromWad("face4"); _Faces[1, 1] = Drawer.PicFromWad("face_p4"); _Faces[0, 0] = Drawer.PicFromWad("face5"); _Faces[0, 1] = Drawer.PicFromWad("face_p5"); _FaceInvis = Drawer.PicFromWad("face_invis"); _FaceInvuln = Drawer.PicFromWad("face_invul2"); _FaceInvisInvuln = Drawer.PicFromWad("face_inv2"); _FaceQuad = Drawer.PicFromWad("face_quad"); Cmd.Add("+showscores", ShowScores); Cmd.Add("-showscores", DontShowScores); _SBar = Drawer.PicFromWad("sbar"); _IBar = Drawer.PicFromWad("ibar"); _ScoreBar = Drawer.PicFromWad("scorebar"); //MED 01/04/97 added new hipnotic weapons if (Common.GameKind == GameKind.Hipnotic) { _HWeapons[0, 0] = Drawer.PicFromWad("inv_laser"); _HWeapons[0, 1] = Drawer.PicFromWad("inv_mjolnir"); _HWeapons[0, 2] = Drawer.PicFromWad("inv_gren_prox"); _HWeapons[0, 3] = Drawer.PicFromWad("inv_prox_gren"); _HWeapons[0, 4] = Drawer.PicFromWad("inv_prox"); _HWeapons[1, 0] = Drawer.PicFromWad("inv2_laser"); _HWeapons[1, 1] = Drawer.PicFromWad("inv2_mjolnir"); _HWeapons[1, 2] = Drawer.PicFromWad("inv2_gren_prox"); _HWeapons[1, 3] = Drawer.PicFromWad("inv2_prox_gren"); _HWeapons[1, 4] = Drawer.PicFromWad("inv2_prox"); for (int i = 0; i < 5; i++) { string s = "inva" + (i + 1).ToString(); _HWeapons[2 + i, 0] = Drawer.PicFromWad(s + "_laser"); _HWeapons[2 + i, 1] = Drawer.PicFromWad(s + "_mjolnir"); _HWeapons[2 + i, 2] = Drawer.PicFromWad(s + "_gren_prox"); _HWeapons[2 + i, 3] = Drawer.PicFromWad(s + "_prox_gren"); _HWeapons[2 + i, 4] = Drawer.PicFromWad(s + "_prox"); } _HItems[0] = Drawer.PicFromWad("sb_wsuit"); _HItems[1] = Drawer.PicFromWad("sb_eshld"); } if (Common.GameKind == GameKind.Rogue) { _RInvBar[0] = Drawer.PicFromWad("r_invbar1"); _RInvBar[1] = Drawer.PicFromWad("r_invbar2"); _RWeapons[0] = Drawer.PicFromWad("r_lava"); _RWeapons[1] = Drawer.PicFromWad("r_superlava"); _RWeapons[2] = Drawer.PicFromWad("r_gren"); _RWeapons[3] = Drawer.PicFromWad("r_multirock"); _RWeapons[4] = Drawer.PicFromWad("r_plasma"); _RItems[0] = Drawer.PicFromWad("r_shield1"); _RItems[1] = Drawer.PicFromWad("r_agrav1"); // PGM 01/19/97 - team color border _RTeamBord = Drawer.PicFromWad("r_teambord"); // PGM 01/19/97 - team color border _RAmmo[0] = Drawer.PicFromWad("r_ammolava"); _RAmmo[1] = Drawer.PicFromWad("r_ammomulti"); _RAmmo[2] = Drawer.PicFromWad("r_ammoplasma"); } }
/// <summary> /// GL_LoadPicTexture /// </summary> static int LoadTexture(glpic_t pic, ByteArraySegment data) { return LoadTexture(String.Empty, pic.width, pic.height, data, false, true); }
public static void DrawTransPic(int x, int y, glpic_t pic) { Drawer.DrawTransPic(x + ((Scr.vid.width - 320) >> 1), y, pic); }
// 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"); }
// Draw_AlphaPic public static void DrawAlphaPic(int x, int y, glpic_t pic, float alpha) { if (_ScrapDirty) UploadScrap(); GL.Disable(EnableCap.AlphaTest); GL.Enable(EnableCap.Blend); GL.Color4(1f, 1f, 1f, alpha); Bind(pic.texnum); GL.Begin(BeginMode.Quads); GL.TexCoord2(pic.sl, pic.tl); GL.Vertex2(x, y); GL.TexCoord2(pic.sh, pic.tl); GL.Vertex2(x + pic.width, y); GL.TexCoord2(pic.sh, pic.th); GL.Vertex2(x + pic.width, y + pic.height); GL.TexCoord2(pic.sl, pic.th); GL.Vertex2(x, y + pic.height); GL.End(); GL.Color4(1f, 1f, 1f, 1f); GL.Enable(EnableCap.AlphaTest); GL.Disable(EnableCap.Blend); }
/// <summary> /// GL_LoadPicTexture /// </summary> static int LoadTexture(glpic_t pic, ByteArraySegment data) { return(LoadTexture(String.Empty, pic.width, pic.height, data, false, true)); }
} // sb_lines scan lines to draw // Sbar_Init public static void Init() { for (int i = 0; i < 10; i++) { string str = i.ToString(); _Nums[0, i] = Drawer.PicFromWad("num_" + str); _Nums[1, i] = Drawer.PicFromWad("anum_" + str); } _Nums[0, 10] = Drawer.PicFromWad("num_minus"); _Nums[1, 10] = Drawer.PicFromWad("anum_minus"); _Colon = Drawer.PicFromWad("num_colon"); _Slash = Drawer.PicFromWad("num_slash"); _Weapons[0, 0] = Drawer.PicFromWad("inv_shotgun"); _Weapons[0, 1] = Drawer.PicFromWad("inv_sshotgun"); _Weapons[0, 2] = Drawer.PicFromWad("inv_nailgun"); _Weapons[0, 3] = Drawer.PicFromWad("inv_snailgun"); _Weapons[0, 4] = Drawer.PicFromWad("inv_rlaunch"); _Weapons[0, 5] = Drawer.PicFromWad("inv_srlaunch"); _Weapons[0, 6] = Drawer.PicFromWad("inv_lightng"); _Weapons[1, 0] = Drawer.PicFromWad("inv2_shotgun"); _Weapons[1, 1] = Drawer.PicFromWad("inv2_sshotgun"); _Weapons[1, 2] = Drawer.PicFromWad("inv2_nailgun"); _Weapons[1, 3] = Drawer.PicFromWad("inv2_snailgun"); _Weapons[1, 4] = Drawer.PicFromWad("inv2_rlaunch"); _Weapons[1, 5] = Drawer.PicFromWad("inv2_srlaunch"); _Weapons[1, 6] = Drawer.PicFromWad("inv2_lightng"); for (int i = 0; i < 5; i++) { string s = "inva" + (i + 1).ToString(); _Weapons[2 + i, 0] = Drawer.PicFromWad(s + "_shotgun"); _Weapons[2 + i, 1] = Drawer.PicFromWad(s + "_sshotgun"); _Weapons[2 + i, 2] = Drawer.PicFromWad(s + "_nailgun"); _Weapons[2 + i, 3] = Drawer.PicFromWad(s + "_snailgun"); _Weapons[2 + i, 4] = Drawer.PicFromWad(s + "_rlaunch"); _Weapons[2 + i, 5] = Drawer.PicFromWad(s + "_srlaunch"); _Weapons[2 + i, 6] = Drawer.PicFromWad(s + "_lightng"); } _Ammo[0] = Drawer.PicFromWad("sb_shells"); _Ammo[1] = Drawer.PicFromWad("sb_nails"); _Ammo[2] = Drawer.PicFromWad("sb_rocket"); _Ammo[3] = Drawer.PicFromWad("sb_cells"); _Armor[0] = Drawer.PicFromWad("sb_armor1"); _Armor[1] = Drawer.PicFromWad("sb_armor2"); _Armor[2] = Drawer.PicFromWad("sb_armor3"); _Items[0] = Drawer.PicFromWad("sb_key1"); _Items[1] = Drawer.PicFromWad("sb_key2"); _Items[2] = Drawer.PicFromWad("sb_invis"); _Items[3] = Drawer.PicFromWad("sb_invuln"); _Items[4] = Drawer.PicFromWad("sb_suit"); _Items[5] = Drawer.PicFromWad("sb_quad"); _Sigil[0] = Drawer.PicFromWad("sb_sigil1"); _Sigil[1] = Drawer.PicFromWad("sb_sigil2"); _Sigil[2] = Drawer.PicFromWad("sb_sigil3"); _Sigil[3] = Drawer.PicFromWad("sb_sigil4"); _Faces[4, 0] = Drawer.PicFromWad("face1"); _Faces[4, 1] = Drawer.PicFromWad("face_p1"); _Faces[3, 0] = Drawer.PicFromWad("face2"); _Faces[3, 1] = Drawer.PicFromWad("face_p2"); _Faces[2, 0] = Drawer.PicFromWad("face3"); _Faces[2, 1] = Drawer.PicFromWad("face_p3"); _Faces[1, 0] = Drawer.PicFromWad("face4"); _Faces[1, 1] = Drawer.PicFromWad("face_p4"); _Faces[0, 0] = Drawer.PicFromWad("face5"); _Faces[0, 1] = Drawer.PicFromWad("face_p5"); _FaceInvis = Drawer.PicFromWad("face_invis"); _FaceInvuln = Drawer.PicFromWad("face_invul2"); _FaceInvisInvuln = Drawer.PicFromWad("face_inv2"); _FaceQuad = Drawer.PicFromWad("face_quad"); Cmd.Add("+showscores", ShowScores); Cmd.Add("-showscores", DontShowScores); _SBar = Drawer.PicFromWad("sbar"); _IBar = Drawer.PicFromWad("ibar"); _ScoreBar = Drawer.PicFromWad("scorebar"); //MED 01/04/97 added new hipnotic weapons if (Common.GameKind == GameKind.Hipnotic) { _HWeapons[0, 0] = Drawer.PicFromWad("inv_laser"); _HWeapons[0, 1] = Drawer.PicFromWad("inv_mjolnir"); _HWeapons[0, 2] = Drawer.PicFromWad("inv_gren_prox"); _HWeapons[0, 3] = Drawer.PicFromWad("inv_prox_gren"); _HWeapons[0, 4] = Drawer.PicFromWad("inv_prox"); _HWeapons[1, 0] = Drawer.PicFromWad("inv2_laser"); _HWeapons[1, 1] = Drawer.PicFromWad("inv2_mjolnir"); _HWeapons[1, 2] = Drawer.PicFromWad("inv2_gren_prox"); _HWeapons[1, 3] = Drawer.PicFromWad("inv2_prox_gren"); _HWeapons[1, 4] = Drawer.PicFromWad("inv2_prox"); for (int i = 0; i < 5; i++) { string s = "inva" + (i + 1).ToString(); _HWeapons[2 + i, 0] = Drawer.PicFromWad(s + "_laser"); _HWeapons[2 + i, 1] = Drawer.PicFromWad(s + "_mjolnir"); _HWeapons[2 + i, 2] = Drawer.PicFromWad(s + "_gren_prox"); _HWeapons[2 + i, 3] = Drawer.PicFromWad(s + "_prox_gren"); _HWeapons[2 + i, 4] = Drawer.PicFromWad(s + "_prox"); } _HItems[0] = Drawer.PicFromWad("sb_wsuit"); _HItems[1] = Drawer.PicFromWad("sb_eshld"); } if (Common.GameKind == GameKind.Rogue) { _RInvBar[0] = Drawer.PicFromWad("r_invbar1"); _RInvBar[1] = Drawer.PicFromWad("r_invbar2"); _RWeapons[0] = Drawer.PicFromWad("r_lava"); _RWeapons[1] = Drawer.PicFromWad("r_superlava"); _RWeapons[2] = Drawer.PicFromWad("r_gren"); _RWeapons[3] = Drawer.PicFromWad("r_multirock"); _RWeapons[4] = Drawer.PicFromWad("r_plasma"); _RItems[0] = Drawer.PicFromWad("r_shield1"); _RItems[1] = Drawer.PicFromWad("r_agrav1"); // PGM 01/19/97 - team color border _RTeamBord = Drawer.PicFromWad("r_teambord"); // PGM 01/19/97 - team color border _RAmmo[0] = Drawer.PicFromWad("r_ammolava"); _RAmmo[1] = Drawer.PicFromWad("r_ammomulti"); _RAmmo[2] = Drawer.PicFromWad("r_ammoplasma"); } }
// 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; }
// Sbar_DrawTransPic static void DrawTransPic(int x, int y, glpic_t pic) { if (Client.cl.gametype == Protocol.GAME_DEATHMATCH) Drawer.DrawTransPic(x, y + (Scr.vid.height - SBAR_HEIGHT), pic); else Drawer.DrawTransPic(x + ((Scr.vid.width - 320) >> 1), y + (Scr.vid.height - SBAR_HEIGHT), pic); }
// SCR_Init public static void Init() { if (_ViewSize == null) { _ViewSize = new Cvar("viewsize", "100", true); _Fov = new Cvar("fov", "90"); // 10 - 170 _ConSpeed = new Cvar("scr_conspeed", "3000"); _CenterTime = new Cvar("scr_centertime", "2"); _ShowRam = new Cvar("showram", "1"); _ShowTurtle = new Cvar("showturtle", "0"); _ShowPause = new Cvar("showpause", "1"); _PrintSpeed = new Cvar("scr_printspeed", "8"); _glTripleBuffer = new Cvar("gl_triplebuffer", "1", true); } // // register our commands // Cmd.Add("screenshot", ScreenShot_f); Cmd.Add("sizeup", SizeUp_f); Cmd.Add("sizedown", SizeDown_f); _Ram = Drawer.PicFromWad("ram"); _Net = Drawer.PicFromWad("net"); _Turtle = Drawer.PicFromWad("turtle"); if (Common.HasParam("-fullsbar")) FullSbarDraw = true; _IsInitialized = true; }