// VID_Init (unsigned char *palette) // Called at startup to set up translation tables, takes 256 8 bit RGB values // the palette data will go away after the call, so it must be copied off if // the video driver will need it again public static void Init(byte[] palette) { if (_glZTrick == null) { _glZTrick = new Cvar("gl_ztrick", "1"); _Mode = new Cvar("vid_mode", "0", false); _DefaultMode = new Cvar("_vid_default_mode", "0", true); _DefaultModeWin = new Cvar("_vid_default_mode_win", "3", true); _Wait = new Cvar("vid_wait", "0"); _NoPageFlip = new Cvar("vid_nopageflip", "0", true); _WaitOverride = new Cvar("_vid_wait_override", "0", true); _ConfigX = new Cvar("vid_config_x", "800", true); _ConfigY = new Cvar("vid_config_y", "600", true); _StretchBy2 = new Cvar("vid_stretch_by_2", "1", true); _WindowedMouse = new Cvar("_windowed_mouse", "1", true); } Cmd.Add("vid_nummodes", NumModes_f); Cmd.Add("vid_describecurrentmode", DescribeCurrentMode_f); Cmd.Add("vid_describemode", DescribeMode_f); Cmd.Add("vid_describemodes", DescribeModes_f); DisplayDevice dev = MainForm.DisplayDevice; // Enumerate available modes, skip 8 bpp modes, and group by refresh rates List<mode_t> tmp = new List<mode_t>(dev.AvailableResolutions.Count); foreach (DisplayResolution res in dev.AvailableResolutions) { if (res.BitsPerPixel <= 8) continue; Predicate<mode_t> SameMode = delegate(mode_t m) { return (m.width == res.Width && m.height == res.Height && m.bpp == res.BitsPerPixel); }; if (tmp.Exists(SameMode)) continue; mode_t mode = new mode_t(); mode.width = res.Width; mode.height = res.Height; mode.bpp = res.BitsPerPixel; mode.refreshRate = res.RefreshRate; tmp.Add(mode); } _Modes = tmp.ToArray(); mode_t mode1 = new mode_t(); mode1.width = dev.Width; mode1.height = dev.Height; mode1.bpp = dev.BitsPerPixel; mode1.refreshRate = dev.RefreshRate; mode1.fullScreen = true; int width = dev.Width, height = dev.Height; int i = Common.CheckParm("-width"); if (i > 0 && i < Common.Argc - 1) { width = Common.atoi(Common.Argv(i + 1)); foreach (DisplayResolution res in dev.AvailableResolutions) { if (res.Width == width) { height = res.Height; break; } } } i = Common.CheckParm("-height"); if (i > 0 && i < Common.Argc - 1) height = Common.atoi(Common.Argv(i + 1)); mode1.width = width; mode1.height = height; if (Common.HasParam("-window")) { _Windowed = true; } else { _Windowed = false; if (Common.HasParam("-current")) { mode1.width = dev.Width; mode1.height = dev.Height; } else { int bpp = mode1.bpp; i = Common.CheckParm("-bpp"); if (i > 0 && i < Common.Argc - 1) { bpp = Common.atoi(Common.Argv(i + 1)); } mode1.bpp = bpp; } } _IsInitialized = true; int i2 = Common.CheckParm("-conwidth"); if (i2 > 0) Scr.vid.conwidth = Common.atoi(Common.Argv(i2 + 1)); else Scr.vid.conwidth = 640; Scr.vid.conwidth &= 0xfff8; // make it a multiple of eight if (Scr.vid.conwidth < 320) Scr.vid.conwidth = 320; // pick a conheight that matches with correct aspect Scr.vid.conheight = Scr.vid.conwidth * 3 / 4; i2 = Common.CheckParm("-conheight"); if (i2 > 0) Scr.vid.conheight = Common.atoi(Common.Argv(i2 + 1)); if (Scr.vid.conheight < 200) Scr.vid.conheight = 200; Scr.vid.maxwarpwidth = WARP_WIDTH; Scr.vid.maxwarpheight = WARP_HEIGHT; Scr.vid.colormap = Host.ColorMap; int v = BitConverter.ToInt32(Host.ColorMap, 2048); Scr.vid.fullbright = 256 - Common.LittleLong(v); CheckGamma(palette); SetPalette(palette); mode1.fullScreen = !_Windowed; _DefModeNum = -1; for (i = 0; i < _Modes.Length; i++) { mode_t m = _Modes[i]; if (m.width != mode1.width || m.height != mode1.height) continue; _DefModeNum = i; if (m.bpp == mode1.bpp && m.refreshRate == mode1.refreshRate) break; } if (_DefModeNum == -1) _DefModeNum = 0; SetMode(_DefModeNum, palette); InitOpenGL(); Directory.CreateDirectory(Path.Combine(Common.GameDir, "glquake")); }