diff --git a/engine/client/cl_main.c b/engine/client/cl_main.c index 122e2beb1..df91a28a0 100644 --- a/engine/client/cl_main.c +++ b/engine/client/cl_main.c @@ -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' diff --git a/engine/client/cl_screen.c b/engine/client/cl_screen.c index 3214c0d1f..f5141f909 100644 --- a/engine/client/cl_screen.c +++ b/engine/client/cl_screen.c @@ -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; diff --git a/engine/client/renderer.c b/engine/client/renderer.c index 7bd7c2837..065a14591 100644 --- a/engine/client/renderer.c +++ b/engine/client/renderer.c @@ -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, ¤trendererstate, sizeof(rendererstate_t)); diff --git a/engine/client/sys_linux.c b/engine/client/sys_linux.c index d82df87fe..8aa099ccb 100644 --- a/engine/client/sys_linux.c +++ b/engine/client/sys_linux.c @@ -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}; diff --git a/engine/client/sys_morphos.c b/engine/client/sys_morphos.c index 397e73848..b6368f2a4 100755 --- a/engine/client/sys_morphos.c +++ b/engine/client/sys_morphos.c @@ -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) { diff --git a/engine/client/sys_sdl.c b/engine/client/sys_sdl.c index 4d0bb36cc..8ffa18517 100644 --- a/engine/client/sys_sdl.c +++ b/engine/client/sys_sdl.c @@ -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) { } diff --git a/engine/client/sys_win.c b/engine/client/sys_win.c index 52db681d7..0dad9e699 100644 --- a/engine/client/sys_win.c +++ b/engine/client/sys_win.c @@ -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?) diff --git a/engine/common/sys.h b/engine/common/sys.h index 4c2186361..6e45fbba7 100644 --- a/engine/common/sys.h +++ b/engine/common/sys.h @@ -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 diff --git a/engine/gl/gl_draw.c b/engine/gl/gl_draw.c index eeb700a04..0e97a63fb 100644 --- a/engine/gl/gl_draw.c +++ b/engine/gl/gl_draw.c @@ -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; diff --git a/engine/gl/gl_vidlinuxglx.c b/engine/gl/gl_vidlinuxglx.c index 660ab7fff..1a9496d7a 100644 --- a/engine/gl/gl_vidlinuxglx.c +++ b/engine/gl/gl_vidlinuxglx.c @@ -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));