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); }
static draw() { for (int kk = 0; kk < MAX_CACHED_PICS; kk++) { menu_cachepics[kk] = new cachepic_t(); } d_polyse_init(); }
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"); }
static draw() { for (int kk = 0; kk < MAX_CACHED_PICS; kk++) menu_cachepics[kk] = new cachepic_t(); d_polyse_init(); }