vid_width/vid_height/vid_bpp 0 will use default desktop settings, added vid_desktopsettings which uses default width/height/bpp/refresh rate, command line -current maps to vid_desktopsettings 1

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@2208 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
TimeServ 2006-04-15 03:31:23 +00:00
parent 68a5e9d3b3
commit ceafd30644
10 changed files with 112 additions and 8 deletions

View file

@ -3324,6 +3324,9 @@ void Host_Init (quakeparms_t *parms)
if ((i = COM_CheckParm ("-bpp")))
Cvar_Set(Cvar_FindVar("vid_bpp"), com_argv[i+1]);
if (COM_CheckParm ("-current"))
Cvar_Set(Cvar_FindVar("vid_desktopsettings"), "1");
Cvar_ApplyLatches(CVAR_RENDERERLATCH);
//-1 means 'never set'

View file

@ -884,18 +884,22 @@ void SCR_CalcRefdef (void)
sb_lines = 0;
else
#endif
if (size >= 120)
if (size >= 120)
sb_lines = 0; // no status bar at all
else if (size >= 110)
sb_lines = 24; // no inventory
else
sb_lines = 24+16+8;
if (scr_viewsize.value >= 100.0 || scr_chatmode) {
if (scr_viewsize.value >= 100.0 || scr_chatmode)
{
full = true;
size = 100.0;
} else
}
else
size = scr_viewsize.value;
if (cl.intermission)
{
full = true;
@ -917,11 +921,14 @@ void SCR_CalcRefdef (void)
}
r_refdef.vrect.height = vid.height * size;
if (cl_sbar.value==1 || !full) {
if (cl_sbar.value==1 || !full)
{
if (r_refdef.vrect.height > vid.height - sb_lines)
r_refdef.vrect.height = vid.height - sb_lines;
} else if (r_refdef.vrect.height > vid.height)
}
else if (r_refdef.vrect.height > vid.height)
r_refdef.vrect.height = vid.height;
r_refdef.vrect.x = (vid.width - r_refdef.vrect.width)/2;
if (full)
r_refdef.vrect.y = 0;

View file

@ -99,6 +99,7 @@ static cvar_t vid_width = SCVARF("vid_width", "640", CVAR_ARCHIVE|CVAR_RENDERERL
static cvar_t vid_height = SCVARF("vid_height", "480", CVAR_ARCHIVE|CVAR_RENDERERLATCH);
static cvar_t vid_refreshrate = SCVARF("vid_displayfrequency", "0", CVAR_ARCHIVE|CVAR_RENDERERLATCH);
static cvar_t vid_multisample = SCVARF("vid_multisample", "0", CVAR_ARCHIVE|CVAR_RENDERERLATCH);
static cvar_t vid_desktopsettings = SCVARF("vid_desktopsettings", "0", CVAR_ARCHIVE|CVAR_RENDERERLATCH);
#if defined(RGLQUAKE)
cvar_t gl_texturemode = SCVARFC("gl_texturemode", "GL_LINEAR_MIPMAP_NEAREST", CVAR_ARCHIVE|CVAR_RENDERERCALLBACK, GL_Texturemode_Callback);
@ -493,6 +494,8 @@ void Renderer_Init(void)
Cvar_Register (&vid_height, VIDCOMMANDGROUP);
Cvar_Register (&vid_refreshrate, VIDCOMMANDGROUP);
Cvar_Register (&vid_desktopsettings, VIDCOMMANDGROUP);
Cvar_Register (&gl_skyboxname, GRAPHICALNICETIES);
Cvar_Register(&r_dodgytgafiles, "Bug fixes");
@ -1891,6 +1894,7 @@ TRACE(("dbg: R_RestartRenderer_f\n"));
newr.bpp = vid_bpp.value;
newr.fullscreen = vid_fullscreen.value;
newr.rate = vid_refreshrate.value;
Q_strncpyz(newr.glrenderer, gl_driver.string, sizeof(newr.glrenderer));
newr.renderer = -1;
@ -1925,6 +1929,42 @@ TRACE(("dbg: R_RestartRenderer_f\n"));
return;
}
// use desktop settings if set to 0 and not dedicated
if (newr.renderer != QR_NONE)
{
int dbpp, dheight, dwidth, drate;
if (!Sys_GetDesktopParameters(&dwidth, &dheight, &dbpp, &drate))
{
// force default values for systems not supporting desktop parameters
dwidth = 640;
dheight = 480;
if (newr.renderer == QR_SOFTWARE) // hack for software default
dbpp = 8;
else
dbpp = 32;
}
if (vid_desktopsettings.value)
{
newr.width = dwidth;
newr.height = dheight;
newr.bpp = dbpp;
newr.rate = drate;
}
else
{
if (newr.width <= 0 || newr.height <= 0)
{
newr.width = dwidth;
newr.height = dheight;
}
if (newr.bpp <= 0)
newr.bpp = dbpp;
}
}
TRACE(("dbg: R_RestartRenderer_f renderer %i\n", newr.renderer));
memcpy(&oldr, &currentrendererstate, sizeof(rendererstate_t));

View file

@ -477,8 +477,30 @@ void Sys_ServerActivity(void)
{
}
//FIXME: this is hacky. Unlike other OSes where the GUI is part of the OS, X is seperate
//from the OS. This will cause problems with framebuffer-only setups.
qboolean Sys_GetDesktopParameters(int *width, int *height, int *bpp, int *refreshrate)
{
Display *xtemp;
int scr;
XPixmapFormatValues xpfv;
xtemp = XOpenDisplay(NULL);
if (!xtemp)
return false;
scr = DefaultScreen(xtemp);
*width = DisplayWidth(xtemp, scr);
*height = DisplayHeight(xtemp, scr);
*bpp = DefaultDepth(xtemp, scr);
*refreshrate = 0;
XCloseDisplay(xtemp);
return true;
}
#define SYS_CLIPBOARD_SIZE 256
static char clipboard_buffer[SYS_CLIPBOARD_SIZE] = {0};

View file

@ -274,6 +274,11 @@ void Sys_ServerActivity(void)
{
}
qboolean Sys_GetDesktopParameters(int *width, int *height, int *bpp, int *refreshrate)
{
return false;
}
/* x86 crap */
void Sys_HighFPPrecision (void)
{

View file

@ -299,6 +299,11 @@ int main(int argc, char **argv)
return 0;
}
qboolean Sys_GetDesktopParameters(int *width, int *height, int *bpp, int *refreshrate)
{
return false;
}
void Sys_HighFPPrecision(void)
{
}

View file

@ -1256,8 +1256,27 @@ int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLin
return TRUE;
}
qboolean Sys_GetDesktopParameters(int *width, int *height, int *bpp, int *refreshrate)
{
HDC hdc;
int rate;
hdc = GetDC(NULL);
*width = GetDeviceCaps(hdc, HORZRES);
*height = GetDeviceCaps(hdc, VERTRES);
*bpp = GetDeviceCaps(hdc, BITSPIXEL);
rate = GetDeviceCaps(hdc, VREFRESH);
if (rate == 1)
rate = 0;
*refreshrate = rate;
ReleaseDC(NULL, hdc);
return true;
}
#ifdef NOASM //these couldn't be found... (it is a masm thing, right?)

View file

@ -85,6 +85,8 @@ void VARGS Sys_SetFPCW (void);
int Sys_EnumerateFiles (char *gpath, char *match, int (*func)(char *, int, void *), void *parm);
qboolean Sys_GetDesktopParameters(int *width, int *height, int *bpp, int *refreshrate);
#ifdef _WIN32
int StartLocalServer(int close);
#endif

View file

@ -658,7 +658,7 @@ void GL_Texturemode_Callback (struct cvar_s *var, char *oldvalue)
if (!Q_strcasecmp (modes[i].altname, var->string ) )
break;
}
if (i == 6)
if (i == sizeof(modes)/sizeof(modes[0]))
{
Con_Printf ("bad gl_texturemode name\n");
return;

View file

@ -754,7 +754,8 @@ qboolean GLVID_Init (rendererstate_t *info, unsigned char *palette)
vid_dpy = XOpenDisplay(NULL);
if (!vid_dpy)
{
Sys_Error("Error couldn't open the X display\n");
Con_Printf(S_ERROR "Error: couldn't open the X display\n");
return false;
}
scrnum = DefaultScreen(vid_dpy);
@ -857,7 +858,7 @@ qboolean GLVID_Init (rendererstate_t *info, unsigned char *palette)
XF86VidModeSetViewPort(vid_dpy, scrnum, 0, 0);
}
#endif
XStoreName(vid_dpy, vid_window, "GLX QuakeWorld Cient");
XStoreName(vid_dpy, vid_window, "FTE QuakeWorld");
//hide the cursor.
XDefineCursor(vid_dpy, vid_window, CreateNullCursor(vid_dpy, vid_window));