From: bones_was_here Date: Tue, 7 May 2024 08:29:09 +0000 (+1000) Subject: CLVM: add cvar to support mods wanting low resolution 2D X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=70b6ed368f90863dec4e457b954039d0f26fb040;p=xonotic%2Fdarkplaces.git CLVM: add cvar to support mods wanting low resolution 2D Signed-off-by: bones_was_here --- diff --git a/cl_main.c b/cl_main.c index dd961172..71443f14 100644 --- a/cl_main.c +++ b/cl_main.c @@ -37,6 +37,7 @@ cvar_t csqc_progcrc = {CF_CLIENT | CF_READONLY, "csqc_progcrc","-1","CRC of cspr cvar_t csqc_progsize = {CF_CLIENT | CF_READONLY, "csqc_progsize","-1","file size of csprogs.dat file to load (-1 is none), only used during level changes and then reset to -1"}; cvar_t csqc_usedemoprogs = {CF_CLIENT, "csqc_usedemoprogs","1","use csprogs stored in demos"}; cvar_t csqc_polygons_defaultmaterial_nocullface = {CF_CLIENT, "csqc_polygons_defaultmaterial_nocullface", "0", "use 'cull none' behavior in the default shader for rendering R_PolygonBegin - warning: enabling this is not consistent with FTEQW behavior on this feature"}; +cvar_t csqc_lowres = {CF_CLIENT, "csqc_lowres", "0", "make EXT_CSQC functions CSQC_UpdateView(), setproperty(), getproperty() use the virtual 2D resolution (FTEQW/QSS behaviour) instead of the real resolution (DP behaviour); this mode is always used for the CSQC_SIMPLE (aka hud-only) CSQC_DrawHud() parameters; see cvars vid_conheight and vid_conwidth"}; cvar_t cl_shownet = {CF_CLIENT, "cl_shownet","0","1 = print packet size, 2 = print packet message list"}; cvar_t cl_nolerp = {CF_CLIENT, "cl_nolerp", "0","network update smoothing"}; @@ -3118,6 +3119,7 @@ void CL_Init (void) Cmd_AddCommand(CF_CLIENT, "locs_save", CL_Locs_Save_f, "save .loc file for this map containing currently defined points and boxes"); Cvar_RegisterVariable(&csqc_polygons_defaultmaterial_nocullface); + Cvar_RegisterVariable(&csqc_lowres); Cvar_RegisterVariable (&cl_minfps); Cvar_RegisterVariable (&cl_minfps_fade); diff --git a/clvm_cmds.c b/clvm_cmds.c index 5ba1b3e5..96551b92 100644 --- a/clvm_cmds.c +++ b/clvm_cmds.c @@ -976,9 +976,27 @@ static void VM_CL_R_SetView (prvm_prog_t *prog) VM_Warning(prog, "VM_CL_R_GetView : unknown parm %i\n", c); return; } + if (csqc_lowres.integer) + { + switch(c) + { + case VF_MIN: case VF_MIN_X: case VF_MIN_Y: case VF_SIZE: case VF_SIZE_X: case VF_SIZE_Y: case VF_VIEWPORT: + VectorScale(PRVM_G_VECTOR(OFS_RETURN), vid_conwidth.value / vid.mode.width, PRVM_G_VECTOR(OFS_RETURN)); + } + } return; } + if (csqc_lowres.integer) + { + float scale = vid.mode.width / vid_conwidth.value; + switch(c) + { + case VF_MIN: case VF_MIN_X: case VF_MIN_Y: case VF_SIZE: case VF_SIZE_X: case VF_SIZE_Y: case VF_VIEWPORT: + VectorScale(PRVM_G_VECTOR(OFS_PARM1), scale, PRVM_G_VECTOR(OFS_PARM1)); + VectorScale(PRVM_G_VECTOR(OFS_PARM2), scale, PRVM_G_VECTOR(OFS_PARM2)); + } + } f = PRVM_G_VECTOR(OFS_PARM1); k = PRVM_G_FLOAT(OFS_PARM1); switch(c) diff --git a/csprogs.c b/csprogs.c index ac2fbf1b..b868b4fb 100644 --- a/csprogs.c +++ b/csprogs.c @@ -510,8 +510,16 @@ qbool CL_VM_UpdateView (double frametime) // free memory for resources that are no longer referenced PRVM_GarbageCollection(prog); // pass in width and height and menu/focus state as parameters (EXT_CSQC_1) - PRVM_G_FLOAT(OFS_PARM0) = vid.mode.width; - PRVM_G_FLOAT(OFS_PARM1) = vid.mode.height; + if (csqc_lowres.integer) + { + PRVM_G_FLOAT(OFS_PARM0) = vid_conwidth.value; + PRVM_G_FLOAT(OFS_PARM1) = vid_conheight.value; + } + else + { + PRVM_G_FLOAT(OFS_PARM0) = vid.mode.width; + PRVM_G_FLOAT(OFS_PARM1) = vid.mode.height; + } /* * This should be fine for now but FTEQW uses flags for keydest * and checks that an array called "eyeoffset" is 0 diff --git a/csprogs.h b/csprogs.h index 1900f91c..922c8c52 100644 --- a/csprogs.h +++ b/csprogs.h @@ -97,6 +97,7 @@ extern cvar_t csqc_progname; //[515]: csqc crc check and right csprogs name acco extern cvar_t csqc_progcrc; extern cvar_t csqc_progsize; extern cvar_t csqc_polygons_defaultmaterial_nocullface; +extern cvar_t csqc_lowres; void CL_VM_PreventInformationLeaks(void);