public static void SCR_Init() { scr_viewsize = new cvar_t("viewsize", "100", true); scr_fov = new cvar_t("fov", "90"); // 10 - 170 scr_conspeed = new cvar_t("scr_conspeed", "3000"); scr_centertime = new cvar_t("scr_centertime", "2"); scr_showram = new cvar_t("showram", "1"); scr_showturtle = new cvar_t("showturtle", "0"); scr_showpause = new cvar_t("showpause", "1"); scr_printspeed = new cvar_t("scr_printspeed", "8"); gl_triplebuffer = new cvar_t("gl_triplebuffer", "1", true); // // register our commands // Cmd_AddCommand("screenshot", SCR_ScreenShot_f); Cmd_AddCommand("sizeup", SCR_SizeUp_f); Cmd_AddCommand("sizedown", SCR_SizeDown_f); scr_ram = Draw_PicFromWad("ram"); scr_net = Draw_PicFromWad("net"); scr_turtle = Draw_PicFromWad("turtle"); if (HasParam("-fullsbar")) { fullsbardraw = true; } scr_initialized = true; }
public static void Draw_AlphaPic(int x, int y, glpic_t pic, float alpha) { if (scrap_dirty) { UploadScrap(); } GL.Disable(EnableCap.AlphaTest); GL.Enable(EnableCap.Blend); GL.Color4(1f, 1f, 1f, alpha); GL_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); }
public static glpic_t Draw_CachePic(string path) { for (int i = 0; i < menu_numcachepics; i++) { cachepic_t p = menu_cachepics[i]; if (p.name == path)// !strcmp(path, pic->name)) { return(p.pic); } } if (menu_numcachepics == q_shared.MAX_CACHED_PICS) { Sys_Error("menu_numcachepics == MAX_CACHED_PICS"); } cachepic_t pic = menu_cachepics[menu_numcachepics]; menu_numcachepics++; pic.name = path; // // load the pic from disk // byte[] data = COM_LoadFile(path); if (data == null) { Sys_Error("Draw_CachePic: failed to load {0}", path); } dqpicheader_t header = BytesToStructure <dqpicheader_t>(data, 0); game_engine.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, menuplyr_pixels, 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 = GL_LoadPicTexture(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 Sbar_FinaleOverlay() { scr_copyeverything = true; glpic_t pic = Draw_CachePic("gfx/finale.lmp"); Draw_TransPic((vid.width - pic.width) / 2, 16, pic); }
public static void Draw_TransPic(int x, int y, glpic_t pic) { if (x < 0 || (uint)(x + pic.width) > vid.width || y < 0 || (uint)(y + pic.height) > vid.height) { Sys_Error("Draw_TransPic: bad coordinates"); } Draw_Pic(x, y, pic); }
public static void Sbar_DrawPic(int x, int y, glpic_t pic) { if (cl.gametype == q_shared.GAME_DEATHMATCH) { Draw_Pic(x, y + (vid.height - q_shared.SBAR_HEIGHT), pic); } else { Draw_Pic(x + ((vid.width - 320) >> 1), y + (vid.height - q_shared.SBAR_HEIGHT), pic); } }
public static void Sbar_MiniDeathmatchOverlay() { scr_copyeverything = true; scr_fullupdate = 0; glpic_t pic = Draw_CachePic("gfx/ranking.lmp"); Menu.DrawPic((320 - pic.width) / 2, 8, pic); // scores Sbar_SortFrags(); // draw the text int l = scoreboardlines; int x = 80 + ((vid.width - 320) >> 1); int y = 40; for (int i = 0; i < l; i++) { int k = fragsort[i]; scoreboard_t s = cl.scores[k]; if (String.IsNullOrEmpty(s.name)) { continue; } // draw background int top = s.colors & 0xf0; int bottom = (s.colors & 15) << 4; top = Sbar_ColorForMap(top); bottom = Sbar_ColorForMap(bottom); Draw_Fill(x, y, 40, 4, top); Draw_Fill(x, y + 4, 40, 4, bottom); // draw number string num = s.frags.ToString().PadLeft(3); Draw_Character(x + 8, y, num[0]); Draw_Character(x + 16, y, num[1]); Draw_Character(x + 24, y, num[2]); if (k == cl.viewentity - 1) { Draw_Character(x - 8, y, 12); } // draw name Draw_String(x + 64, y, s.name); y += 10; } }
public static void SCR_DrawLoading() { if (!scr_drawloading) { return; } glpic_t pic = Draw_CachePic("gfx/loading.lmp"); Draw_Pic((vid.width - pic.width) / 2, (vid.height - 48 - pic.height) / 2, pic); }
public static void Draw_TransPicTranslate(int x, int y, glpic_t pic, byte[] translation) { GL_Bind(translate_texture); 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 = menuplyr_pixels[srcOffset + ((u * pic.width) >> 6)]; if (p == 255) { trans[destOffset + u] = p; } else { trans[destOffset + u] = d_8to24table[translation[p]]; } } } GCHandle handle = GCHandle.Alloc(trans, GCHandleType.Pinned); try { GL.TexImage2D(TextureTarget.Texture2D, 0, gl_alpha_format, 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(); }
public static void DrawPause() { if (scr_showpause.value == 0) // turn off for screenshots { return; } if (!cl.paused) { return; } glpic_t pic = Draw_CachePic("gfx/pause.lmp"); Draw_Pic((vid.width - pic.width) / 2, (vid.height - 48 - pic.height) / 2, pic); }
public static void Draw_Pic(int x, int y, glpic_t pic) { if (scrap_dirty) { UploadScrap(); } GL.Color4(1f, 1f, 1f, 1f); GL_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(); }
public static glpic_t Draw_PicFromWad(string name) { int offset = game_engine.W_GetLumpName(name); IntPtr ptr = new IntPtr(game_engine._DataPtr.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 = Scrap_AllocBlock(gl.width, gl.height, out x, out y); scrap_dirty = 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) * q_shared.BLOCK_WIDTH + x + j] = game_engine.wad_base[offset + k];// p->data[k]; } } texnum += scrap_texnum; gl.texnum = texnum; gl.sl = (float)((x + 0.01) / (float)q_shared.BLOCK_WIDTH); gl.sh = (float)((x + gl.width - 0.01) / (float)q_shared.BLOCK_WIDTH); gl.tl = (float)((y + 0.01) / (float)q_shared.BLOCK_WIDTH); gl.th = (float)((y + gl.height - 0.01) / (float)q_shared.BLOCK_WIDTH); pic_count++; pic_texels += gl.width * gl.height; } else { gl.texnum = GL_LoadPicTexture(gl, new ByteArraySegment(game_engine.wad_base, offset)); } return(gl); }
public static void Sbar_IntermissionOverlay() { scr_copyeverything = true; scr_fullupdate = 0; if (cl.gametype == q_shared.GAME_DEATHMATCH) { Sbar_MiniDeathmatchOverlay(); return; } glpic_t pic = Draw_CachePic("gfx/complete.lmp"); Draw_Pic(64, 24, pic); pic = Draw_CachePic("gfx/inter.lmp"); Draw_TransPic(0, 56, pic); // time int dig = cl.completed_time / 60; Sbar_IntermissionNumber(160, 64, dig, 3, 0); int num = cl.completed_time - dig * 60; Draw_TransPic(234, 64, sb_colon); Draw_TransPic(246, 64, sb_nums[0, num / 10]); Draw_TransPic(266, 64, sb_nums[0, num % 10]); Sbar_IntermissionNumber(160, 104, cl.stats[q_shared.STAT_SECRETS], 3, 0); Draw_TransPic(232, 104, sb_slash); Sbar_IntermissionNumber(240, 104, cl.stats[q_shared.STAT_TOTALSECRETS], 3, 0); Sbar_IntermissionNumber(160, 144, cl.stats[q_shared.STAT_MONSTERS], 3, 0); Draw_TransPic(232, 144, sb_slash); Sbar_IntermissionNumber(240, 144, cl.stats[q_shared.STAT_TOTALMONSTERS], 3, 0); }
public static void Sbar_Init() { for (int i = 0; i < 10; i++) { string str = i.ToString(); sb_nums[0, i] = Draw_PicFromWad("num_" + str); sb_nums[1, i] = Draw_PicFromWad("anum_" + str); } sb_nums[0, 10] = Draw_PicFromWad("num_minus"); sb_nums[1, 10] = Draw_PicFromWad("anum_minus"); sb_colon = Draw_PicFromWad("num_colon"); sb_slash = Draw_PicFromWad("num_slash"); sb_weapons[0, 0] = Draw_PicFromWad("inv_shotgun"); sb_weapons[0, 1] = Draw_PicFromWad("inv_sshotgun"); sb_weapons[0, 2] = Draw_PicFromWad("inv_nailgun"); sb_weapons[0, 3] = Draw_PicFromWad("inv_snailgun"); sb_weapons[0, 4] = Draw_PicFromWad("inv_rlaunch"); sb_weapons[0, 5] = Draw_PicFromWad("inv_srlaunch"); sb_weapons[0, 6] = Draw_PicFromWad("inv_lightng"); sb_weapons[1, 0] = Draw_PicFromWad("inv2_shotgun"); sb_weapons[1, 1] = Draw_PicFromWad("inv2_sshotgun"); sb_weapons[1, 2] = Draw_PicFromWad("inv2_nailgun"); sb_weapons[1, 3] = Draw_PicFromWad("inv2_snailgun"); sb_weapons[1, 4] = Draw_PicFromWad("inv2_rlaunch"); sb_weapons[1, 5] = Draw_PicFromWad("inv2_srlaunch"); sb_weapons[1, 6] = Draw_PicFromWad("inv2_lightng"); for (int i = 0; i < 5; i++) { string s = "inva" + (i + 1).ToString(); sb_weapons[2 + i, 0] = Draw_PicFromWad(s + "_shotgun"); sb_weapons[2 + i, 1] = Draw_PicFromWad(s + "_sshotgun"); sb_weapons[2 + i, 2] = Draw_PicFromWad(s + "_nailgun"); sb_weapons[2 + i, 3] = Draw_PicFromWad(s + "_snailgun"); sb_weapons[2 + i, 4] = Draw_PicFromWad(s + "_rlaunch"); sb_weapons[2 + i, 5] = Draw_PicFromWad(s + "_srlaunch"); sb_weapons[2 + i, 6] = Draw_PicFromWad(s + "_lightng"); } sb_ammo[0] = Draw_PicFromWad("sb_shells"); sb_ammo[1] = Draw_PicFromWad("sb_nails"); sb_ammo[2] = Draw_PicFromWad("sb_rocket"); sb_ammo[3] = Draw_PicFromWad("sb_cells"); sb_armor[0] = Draw_PicFromWad("sb_armor1"); sb_armor[1] = Draw_PicFromWad("sb_armor2"); sb_armor[2] = Draw_PicFromWad("sb_armor3"); sb_items[0] = Draw_PicFromWad("sb_key1"); sb_items[1] = Draw_PicFromWad("sb_key2"); sb_items[2] = Draw_PicFromWad("sb_invis"); sb_items[3] = Draw_PicFromWad("sb_invuln"); sb_items[4] = Draw_PicFromWad("sb_suit"); sb_items[5] = Draw_PicFromWad("sb_quad"); sb_sigil[0] = Draw_PicFromWad("sb_sigil1"); sb_sigil[1] = Draw_PicFromWad("sb_sigil2"); sb_sigil[2] = Draw_PicFromWad("sb_sigil3"); sb_sigil[3] = Draw_PicFromWad("sb_sigil4"); sb_faces[4, 0] = Draw_PicFromWad("face1"); sb_faces[4, 1] = Draw_PicFromWad("face_p1"); sb_faces[3, 0] = Draw_PicFromWad("face2"); sb_faces[3, 1] = Draw_PicFromWad("face_p2"); sb_faces[2, 0] = Draw_PicFromWad("face3"); sb_faces[2, 1] = Draw_PicFromWad("face_p3"); sb_faces[1, 0] = Draw_PicFromWad("face4"); sb_faces[1, 1] = Draw_PicFromWad("face_p4"); sb_faces[0, 0] = Draw_PicFromWad("face5"); sb_faces[0, 1] = Draw_PicFromWad("face_p5"); sb_face_invis = Draw_PicFromWad("face_invis"); sb_face_invuln = Draw_PicFromWad("face_invul2"); sb_face_invis_invuln = Draw_PicFromWad("face_inv2"); sb_face_quad = Draw_PicFromWad("face_quad"); Cmd_AddCommand("+showscores", Sbar_ShowScores); Cmd_AddCommand("-showscores", Sbar_DontShowScores); sb_sbar = Draw_PicFromWad("sbar"); sb_ibar = Draw_PicFromWad("ibar"); sb_scorebar = Draw_PicFromWad("scorebar"); //MED 01/04/97 added new hipnotic weapons if (_GameKind == GameKind.Hipnotic) { hsb_weapons[0, 0] = Draw_PicFromWad("inv_laser"); hsb_weapons[0, 1] = Draw_PicFromWad("inv_mjolnir"); hsb_weapons[0, 2] = Draw_PicFromWad("inv_gren_prox"); hsb_weapons[0, 3] = Draw_PicFromWad("inv_prox_gren"); hsb_weapons[0, 4] = Draw_PicFromWad("inv_prox"); hsb_weapons[1, 0] = Draw_PicFromWad("inv2_laser"); hsb_weapons[1, 1] = Draw_PicFromWad("inv2_mjolnir"); hsb_weapons[1, 2] = Draw_PicFromWad("inv2_gren_prox"); hsb_weapons[1, 3] = Draw_PicFromWad("inv2_prox_gren"); hsb_weapons[1, 4] = Draw_PicFromWad("inv2_prox"); for (int i = 0; i < 5; i++) { string s = "inva" + (i + 1).ToString(); hsb_weapons[2 + i, 0] = Draw_PicFromWad(s + "_laser"); hsb_weapons[2 + i, 1] = Draw_PicFromWad(s + "_mjolnir"); hsb_weapons[2 + i, 2] = Draw_PicFromWad(s + "_gren_prox"); hsb_weapons[2 + i, 3] = Draw_PicFromWad(s + "_prox_gren"); hsb_weapons[2 + i, 4] = Draw_PicFromWad(s + "_prox"); } hsb_items[0] = Draw_PicFromWad("sb_wsuit"); hsb_items[1] = Draw_PicFromWad("sb_eshld"); } if (_GameKind == GameKind.Rogue) { rsb_invbar[0] = Draw_PicFromWad("r_invbar1"); rsb_invbar[1] = Draw_PicFromWad("r_invbar2"); rsb_weapons[0] = Draw_PicFromWad("r_lava"); rsb_weapons[1] = Draw_PicFromWad("r_superlava"); rsb_weapons[2] = Draw_PicFromWad("r_gren"); rsb_weapons[3] = Draw_PicFromWad("r_multirock"); rsb_weapons[4] = Draw_PicFromWad("r_plasma"); rsb_items[0] = Draw_PicFromWad("r_shield1"); rsb_items[1] = Draw_PicFromWad("r_agrav1"); // PGM 01/19/97 - team color border rsb_teambord = Draw_PicFromWad("r_teambord"); // PGM 01/19/97 - team color border rsb_ammo[0] = Draw_PicFromWad("r_ammolava"); rsb_ammo[1] = Draw_PicFromWad("r_ammomulti"); rsb_ammo[2] = Draw_PicFromWad("r_ammoplasma"); } }
public static void Draw_Init() { _ScrapAllocated = new int[q_shared.MAX_SCRAPS][]; for (int i = 0; i < _ScrapAllocated.GetLength(0); i++) { _ScrapAllocated[i] = new int[q_shared.BLOCK_WIDTH]; } _ScrapTexels = new byte[q_shared.MAX_SCRAPS][]; for (int i = 0; i < _ScrapTexels.GetLength(0); i++) { _ScrapTexels[i] = new byte[q_shared.BLOCK_WIDTH * q_shared.BLOCK_HEIGHT * 4]; } for (int i = 0; i < menu_cachepics.Length; i++) { menu_cachepics[i] = new cachepic_t(); } gl_nobind = new cvar_t("gl_nobind", "0"); gl_max_size = new cvar_t("gl_max_size", "1024"); gl_picmip = new cvar_t("gl_picmip", "0"); // 3dfx can only handle 256 wide textures string renderer = GL.GetString(StringName.Renderer); if (renderer.Contains("3dfx") || renderer.Contains("Glide")) { Cvar.Cvar_Set("gl_max_size", "256"); } Cmd_AddCommand("gl_texturemode", Draw_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 = game_engine.W_GetLumpName("conchars"); byte[] draw_chars = game_engine.wad_base; // 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 char_texture = GL_LoadTexture("charset", 128, 128, new ByteArraySegment(draw_chars, offset), false, true); byte[] buf = COM_LoadFile("gfx/conback.lmp"); if (buf == null) { Sys_Error("Couldn't load gfx/conback.lmp"); } dqpicheader_t cbHeader = BytesToStructure <dqpicheader_t>(buf, 0); game_engine.SwapPic(cbHeader); // hack the version number directly into the pic string ver = String.Format("(c# {0,7:F2}) {1,7:F2}", (float)q_shared.CSQUAKE_VERSION, (float)q_shared.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 = GL_LoadTexture("conback", conback.width, conback.height, new ByteArraySegment(buf, ncdataIndex), false, false); conback.width = vid.width; conback.height = vid.height; // save a texture slot for translated picture translate_texture = texture_extension_number++; // save slots for scraps scrap_texnum = texture_extension_number; texture_extension_number += q_shared.MAX_SCRAPS; // // get the other pics we need // draw_disc = Draw_PicFromWad("disc"); draw_backtile = Draw_PicFromWad("backtile"); }
public static int GL_LoadPicTexture(glpic_t pic, ByteArraySegment data) { return(GL_LoadTexture(String.Empty, pic.width, pic.height, data, false, true)); }