void SCR_CheckDefaultMode(void) { INT32 scr_forcex, scr_forcey; // resolution asked from the cmd-line if (dedicated) return; // 0 means not set at the cmd-line scr_forcex = scr_forcey = 0; if (M_CheckParm("-width") && M_IsNextParm()) scr_forcex = atoi(M_GetNextParm()); if (M_CheckParm("-height") && M_IsNextParm()) scr_forcey = atoi(M_GetNextParm()); if (scr_forcex && scr_forcey) { CONS_Printf(M_GetText("Using resolution: %d x %d\n"), scr_forcex, scr_forcey); // returns -1 if not found, thus will be 0 (no mode change) if not found setmodeneeded = VID_GetModeForSize(scr_forcex, scr_forcey) + 1; } else { CONS_Printf(M_GetText("Default resolution: %d x %d (%d bits)\n"), cv_scr_width.value, cv_scr_height.value, cv_scr_depth.value); // see note above setmodeneeded = VID_GetModeForSize(cv_scr_width.value, cv_scr_height.value) + 1; } }
// return a video mode number from the dimensions // returns any available video mode if the mode was not found INT32 VID_GetModeForSize(INT32 w, INT32 h) { vmode_t *pv = pvidmodes; int modenum; // skip windowed modes for (modenum = 0; pv && modenum < NUMSPECIALMODES; modenum++) pv = pv->pnext; // try fullscreen modes for (modenum = NUMSPECIALMODES; pv; pv = pv->pnext, modenum++) if (pv->width == (unsigned)w && pv->height == (unsigned)h) return modenum; // didn't find full-screen mode; try windowed for (pv = pvidmodes, modenum = 0; pv && modenum < NUMSPECIALMODES; pv = pv->pnext, modenum++) if (pv->width == (unsigned)w && pv->height == (unsigned)h) return modenum; // if not found, return the first mode available, // preferably a full screen mode (all modes after the 'specialmodes') if (numvidmodes > NUMSPECIALMODES) { // Try default video mode first if (w != cv_scr_width.value || h != cv_scr_height.value) return VID_GetModeForSize(cv_scr_width.value, cv_scr_height.value); return NUMSPECIALMODES; // use first full screen mode } return 0; // no fullscreen mode, use windowed mode }
// Change fullscreen on/off according to cv_fullscreen void SCR_ChangeFullscreen(void) { #ifdef DIRECTFULLSCREEN // allow_fullscreen is set by VID_PrepareModeList // it is used to prevent switching to fullscreen during startup if (!allow_fullscreen) return; if (graphics_started) { VID_PrepareModeList(); setmodeneeded = VID_GetModeForSize(vid.width, vid.height) + 1; } return; #endif }