/* ================= VID_DescribeModes_f ================= */ void VID_DescribeModes_f (void) { int i, nummodes; char *pinfo, *pheader; vmode_t *pv; qboolean na; na = false; nummodes = VID_NumModes (); for (i=0 ; i<nummodes ; i++) { pv = VID_GetModePtr (i); pinfo = VID_ModeInfo (i, &pheader); if (pheader) Con_Printf ("\n%s\n", pheader); if (VGA_CheckAdequateMem (pv->width, pv->height, pv->rowbytes, (pv->numpages == 1) || vid_nopageflip->value)) { Con_Printf ("%2d: %s\n", i, pinfo); } else { Con_Printf ("**: %s\n", pinfo); na = true; } } if (na) { Con_Printf ("\n[**: not enough system RAM for mode]\n"); } }
/* ================= VID_GetModeDescription ================= */ char *VID_GetModeDescription (int mode) { char *pinfo, *pheader; vmode_t *pv; pv = VID_GetModePtr (mode); pinfo = VID_ModeInfo (mode, &pheader); if (VGA_CheckAdequateMem (pv->width, pv->height, pv->rowbytes, (pv->numpages == 1) || vid_nopageflip->value)) { return pinfo; } else { return NULL; } }
// vid_modelist // static void VID_Command_ModeList_f(void) { int i, numodes; const char *pinfo; vmode_t *pv; numodes = VID_NumModes(); for (i = NUMSPECIALMODES; i < numodes; i++) { pv = VID_GetModePtr(i); pinfo = VID_GetModeName(i); if (pv->bytesperpixel == 1) CONS_Printf("%d: %s\n", i, pinfo); else CONS_Printf("%d: %s (hicolor)\n", i, pinfo); } }
/* ================ VID_ModeInfo ================ */ char *VID_ModeInfo (int modenum, char **ppheader) { static char *badmodestr = "Bad mode number"; vmode_t *pv; pv = VID_GetModePtr (modenum); if (!pv) { if (ppheader) *ppheader = NULL; return badmodestr; } else { if (ppheader) *ppheader = pv->header; return pv->name; } }
// vid_modeinfo <modenum> // static void VID_Command_ModeInfo_f(void) { vmode_t *pv; int modenum; if (COM_Argc() != 2) modenum = vid.modenum; // describe the current mode else modenum = atoi(COM_Argv(1)); // the given mode number if (modenum > VID_NumModes() || modenum < NUMSPECIALMODES) // don't accept the windowed modes { CONS_Printf("%s", M_GetText("No such video mode\n")); return; } pv = VID_GetModePtr(modenum); CONS_Printf("%s\n", VID_GetModeName(modenum)); CONS_Printf(M_GetText("width: %d\nheight: %d\n"), pv->width, pv->height); if (rendermode == render_soft) CONS_Printf(M_GetText("bytes per scanline: %d\nbytes per pixel: %d\nnumpages: %d\n"), pv->rowbytes, pv->bytesperpixel, pv->numpages); }
/* ================ VID_SetMode ================ */ int VID_SetMode (int modenum, unsigned char *palette) { int stat; vmode_t *pnewmode, *poldmode; if ((modenum >= numvidmodes) || (modenum < 0)) { Cvar_SetValue (vid_mode, (float)vid_modenum); nomodecheck = true; Con_Printf ("No such video mode: %d\n", modenum); nomodecheck = false; if (pcurrentmode == NULL) { modenum = 0; // mode hasn't been set yet, so initialize to base // mode since they gave us an invalid initial mode } else { return 0; } } pnewmode = VID_GetModePtr (modenum); if (pnewmode == pcurrentmode) return 1; // already in the desired mode // initialize the new mode poldmode = pcurrentmode; pcurrentmode = pnewmode; vid.width = pcurrentmode->width; vid.height = pcurrentmode->height; if (!yeahimconsoled){ vid.vconheight = pcurrentmode->width; vid.vconwidth = pcurrentmode->height;} SCR_StretchRefresh(); SCR_CvarCheck(); vid.aspect = pcurrentmode->aspect; vid.rowbytes = pcurrentmode->rowbytes; stat = (*pcurrentmode->setmode) (&vid, pcurrentmode); if (stat < 1) { if (stat == 0) { // real, hard failure that requires resetting the mode if (!VID_SetMode (vid_modenum, palette)) // restore prior mode Sys_Error ("VID_SetMode: Unable to set any mode, probably " "because there's not enough memory available"); Con_Printf ("Failed to set mode %d\n", modenum); return 0; } else if (stat == -1) { // not enough memory; just put things back the way they were pcurrentmode = poldmode; vid.width = pcurrentmode->width; vid.height = pcurrentmode->height; if (!yeahimconsoled){ vid.vconheight = pcurrentmode->width; vid.vconwidth = pcurrentmode->height;} vid.aspect = pcurrentmode->aspect; vid.rowbytes = pcurrentmode->rowbytes; return 0; } else { Sys_Error ("VID_SetMode: invalid setmode return code %d"); } } (*pcurrentmode->setpalette) (&vid, pcurrentmode, palette); vid_modenum = modenum; Cvar_SetValue (vid_mode, (float)vid_modenum); nomodecheck = true; Con_Printf ("%s\n", VID_ModeInfo (vid_modenum, NULL)); nomodecheck = false; vid.recalc_refdef = 1; return 1; }
// ======================================================================== // Sets a video mode // ======================================================================== INT32 VID_SetMode(INT32 modenum) { int vstat; vmode_t *pnewmode; if (dedicated) return 0; DEBPRINT(va("VID_SetMode(%d)\n", modenum)); // if mode 0 (windowed) we must not be fullscreen already, // if other mode, check it is not mode 0 and existing if ((modenum >= NUMSPECIALMODES) || bAppFullScreen) { if (modenum > numvidmodes || modenum < NUMSPECIALMODES) { if (!pcurrentmode) modenum = 0; // revert to the default base vid mode else I_Error("Unknown video mode: %d\n", modenum); } } pnewmode = VID_GetModePtr(modenum); // dont switch to the same display mode if (pnewmode == pcurrentmode) return 1; // initialize the new mode pcurrentmode = pnewmode; // initialize vidbuffer size for setmode vid.width = pcurrentmode->width; vid.height = pcurrentmode->height; vid.rowbytes = pcurrentmode->rowbytes; vid.bpp = pcurrentmode->bytesperpixel; if (modenum) // if not 320x200 windowed mode, it's actually a hack { if (rendermode == render_opengl) { // don't accept depth < 16 for OpenGL mode (too much ugly) if (cv_scr_depth.value < 16) CV_SetValue(&cv_scr_depth, 16); vid.bpp = cv_scr_depth.value/8; vid.u.windowed = (bWinParm || !cv_fullscreen.value); pcurrentmode->bytesperpixel = vid.bpp; pcurrentmode->windowed = vid.u.windowed; } } vstat = (*pcurrentmode->setmode)(&vid, pcurrentmode); if (vstat == -1) I_Error("Not enough mem for VID_SetMode\n"); else if (vstat == -2) I_Error("Couldn't set video mode because it failed the test\n"); else if (vstat == -3) I_Error("Couldn't set video mode because it failed the change?\n"); else if (!vstat) I_Error("Couldn't set video mode %d (%dx%d %d bits)\n", modenum, vid.width, vid.height, (vid.bpp*8));// hardware could not setup mode else CONS_Printf(M_GetText("Mode changed to %d (%s)\n"), modenum, pcurrentmode->name); vid.modenum = modenum; // tell game engine to recalc all tables and realloc buffers based on new values vid.recalc = 1; if (modenum < NUMSPECIALMODES) { // we are in startup windowed mode bAppFullScreen = FALSE; bDIBMode = TRUE; } else { // we switch to fullscreen bAppFullScreen = TRUE; bDIBMode = FALSE; #ifdef HWRENDER if (rendermode != render_soft) { // purge all patch graphics stored in software format //Z_FreeTags (PU_PURGELEVEL, PU_PURGELEVEL+100); HWR_Startup(); } #endif } I_RestartSysMouse(); return 1; }
// // return the name of a video mode // const char *VID_GetModeName(INT32 modenum) { return (VID_GetModePtr(modenum))->name; }