]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
CLVM: add cvar to support mods wanting low resolution 2D
authorbones_was_here <bones_was_here@xonotic.au>
Tue, 7 May 2024 08:29:09 +0000 (18:29 +1000)
committerbones_was_here <bones_was_here@xonotic.au>
Thu, 9 May 2024 03:07:38 +0000 (13:07 +1000)
Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
cl_main.c
clvm_cmds.c
csprogs.c
csprogs.h

index dd9611720d9105a0159ee92445b27c9c36d8740a..71443f14c0d69ba19c30252bb74aa2ab76980fb0 100644 (file)
--- 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);
index 5ba1b3e53564fbb8fb40c52aa3bfde7351b5fa20..96551b920f5cdb98becf83af75bb26c89d2dda05 100644 (file)
@@ -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)
index ac2fbf1ba062063b2da56541053575529be59f20..b868b4fb744188f284ac368cd2e4f4e55283f8af 100644 (file)
--- 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
index 1900f91c3711c82805bf65fcabab4cc8cef4c5bc..922c8c5252e24561034c61d3d5229b98dd9854ed 100644 (file)
--- 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);