]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
1. make the first CSQC rendered view the "main" view, for use e.g. by origin display...
authordivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Tue, 8 Nov 2011 20:49:52 +0000 (20:49 +0000)
committerRudolf Polzer <divverent@xonotic.org>
Tue, 8 Nov 2011 20:57:05 +0000 (21:57 +0100)
2. add an extension DP_CSQC_MAINVIEW to override DP's notion of the "main" view when necessesary

git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@11540 d7cf8633-e32d-0410-b094-e92efae38249
::stable-branch::merge=7938a89abdf37e9452182f64bc9aec0293f493a3

client.h
clvm_cmds.c
csprogs.c
csprogs.h
dpdefs/csprogsdefs.qc
gl_rmain.c
render.h
svvm_cmds.c

index 41656fe4b21f429e5d359946793dce0108597054..5c1d8f27dfcb98de5a003e06166c2c72dbbe7868 100644 (file)
--- a/client.h
+++ b/client.h
@@ -1669,6 +1669,8 @@ typedef struct r_refdef_view_s
        qboolean clear;
        // if true, don't clear or do any post process effects (bloom, etc)
        qboolean isoverlay;
+       // if true, this is the MAIN view (which is, after CSQC, copied into the scene for use e.g. by r_speeds 1, showtex, prydon cursor)
+       qboolean ismain;
 
        // whether to draw r_showtris and such, this is only true for the main
        // view render, all secondary renders (mirrors, portals, cameras,
index 227e9f2b8759a7a34251e15b7fcf05e0319d0fda..cbcc548676a30d3810004b77871376bf5e4fdb10 100644 (file)
@@ -24,6 +24,7 @@ extern cvar_t v_flipped;
 extern cvar_t r_equalize_entities_fullbright;
 
 r_refdef_view_t csqc_original_r_refdef_view;
+r_refdef_view_t csqc_main_r_refdef_view;
 
 sfx_t *S_FindName(const char *name);
 int Sbar_GetSortedPlayerIndex (int index);
@@ -884,6 +885,9 @@ void VM_CL_R_SetView (void)
                case VF_CLEARSCREEN:
                        PRVM_G_FLOAT(OFS_RETURN) = r_refdef.view.isoverlay;
                        break;
+               case VF_MAINVIEW:
+                       PRVM_G_FLOAT(OFS_RETURN) = r_refdef.view.ismain;
+                       break;
                case VF_FOG_DENSITY:
                        PRVM_G_FLOAT(OFS_RETURN) = r_refdef.fog_density;
                        break;
@@ -1031,6 +1035,9 @@ void VM_CL_R_SetView (void)
        case VF_CLEARSCREEN:
                r_refdef.view.isoverlay = !k;
                break;
+       case VF_MAINVIEW:
+               PRVM_G_FLOAT(OFS_RETURN) = r_refdef.view.ismain;
+               break;
        case VF_FOG_DENSITY:
                r_refdef.fog_density = k;
                break;
@@ -3090,6 +3097,17 @@ void VM_CL_R_RenderScene (void)
        vmpolygons_t* polys = vmpolygons + PRVM_GetProgNr();
        VM_SAFEPARMCOUNT(0, VM_CL_R_RenderScene);
 
+       // update the views
+       if(r_refdef.view.ismain)
+       {
+               // set the main view
+               csqc_main_r_refdef_view = r_refdef.view;
+
+               // clear the flags so no other view becomes "main" unless CSQC sets VF_MAINVIEW
+               r_refdef.view.ismain = false;
+               csqc_original_r_refdef_view.ismain = false;
+       }
+
        // we need to update any RENDER_VIEWMODEL entities at this point because
        // csqc supplies its own view matrix
        CL_UpdateViewEntities();
index 8181505b4f403a62e5daa6be6b73212830bd6a3f..089587db94f4e82f17db5accfd7aabd7ae85141b 100644 (file)
--- a/csprogs.c
+++ b/csprogs.c
@@ -465,6 +465,7 @@ qboolean CL_VM_InputEvent (int eventtype, int x, int y)
 }
 
 extern r_refdef_view_t csqc_original_r_refdef_view;
+extern r_refdef_view_t csqc_main_r_refdef_view;
 qboolean CL_VM_UpdateView (void)
 {
        vec3_t emptyvector;
@@ -476,7 +477,9 @@ qboolean CL_VM_UpdateView (void)
                return false;
        R_TimeReport("pre-UpdateView");
        CSQC_BEGIN
+               r_refdef.view.ismain = true;
                csqc_original_r_refdef_view = r_refdef.view;
+               csqc_main_r_refdef_view = r_refdef.view;
                //VectorCopy(cl.viewangles, oldangles);
                PRVM_clientglobalfloat(time) = cl.time;
                PRVM_clientglobaledict(self) = cl.csqc_server2csqcentitynumber[cl.playerentity];
@@ -492,8 +495,10 @@ qboolean CL_VM_UpdateView (void)
                //VectorCopy(oldangles, cl.viewangles);
                // Dresk : Reset Dmg Globals Here
                CL_VM_UpdateDmgGlobals(0, 0, emptyvector);
-               r_refdef.view = csqc_original_r_refdef_view;
+               r_refdef.view = csqc_main_r_refdef_view;
+               R_RenderView_UpdateViewVectors(); // we have to do this, as we undid the scene render doing this for us
        CSQC_END
+
        R_TimeReport("UpdateView");
        return true;
 }
index a5f478c161ca308b77271219aa132b0f91a8a511..f6fb753ef4d626873be3287d9f620ee23b3f187a 100644 (file)
--- a/csprogs.h
+++ b/csprogs.h
@@ -52,6 +52,8 @@
 #define VF_FOG_HEIGHT          210 //(float)
 #define VF_FOG_FADEDEPTH       211 //(float)
 
+#define VF_MAINVIEW            212 //(float)
+
 #define RF_VIEWMODEL           1       // The entity is never drawn in mirrors. In engines with realtime lighting, it casts no shadows.
 #define RF_EXTERNALMODEL       2       // The entity is appears in mirrors but not in the normal view. It does still cast shadows in engines with realtime lighting.
 #define RF_DEPTHHACK           4       // The entity appears closer to the view than normal, either by scaling it wierdly or by just using a depthrange. This will usually be found in conjunction with RF_VIEWMODEL
index cca16019d9c6fc30bcbb91a0a230f6febca43ce2..8fa52e44af7920fca8fb490b381e1f7c9650946a 100644 (file)
@@ -881,4 +881,15 @@ string(string command, float bindmap) findkeysforcommand = #610;
 //builtin definitions: (CSQC)
 float(string url, float id, string content_type, string delim, float buf, float keyid) crypto_uri_postbuf = #513;
 //description:
-//use -1 as buffer handle to justs end delim as postdata
\ No newline at end of file
+//use -1 as buffer handle to justs end delim as postdata
+
+//DP_CSQC_MAINVIEW
+//idea: divVerent
+//darkplaces implementation: divVerent
+//constant definitions:
+const float VF_MAINVIEW         = 212;
+//use setproperty(VF_MAINVIEW, 1); before calling R_RenderView for the render
+//that shall become the "main" view, which is e.g. used by PRYDON_CLIENTCURSOR 
+//this flag is set for the first scene, and not cleared by R_ClearScene
+//this flag is automatically cleared by R_RenderView
+//so when not using this extension, the first view rendered is the main view
index a4011abd8fa26bc631307fbc02908ad49239065a..a0c1b0e9d7bf0f824fbab28fecc5cd5fd9eb3eb7 100644 (file)
@@ -5521,7 +5521,7 @@ void R_ResetViewRendering3D(int fbo, rtexture_t *depthtexture, rtexture_t *color
 R_RenderView_UpdateViewVectors
 ================
 */
-static void R_RenderView_UpdateViewVectors(void)
+void R_RenderView_UpdateViewVectors(void)
 {
        // break apart the view matrix into vectors for various purposes
        // it is important that this occurs outside the RenderScene function because that can be called from reflection renders, where the vectors come out wrong
index 0ddb2f5755d12f1732cc121124fe004ff517f61d..ccde73d7b3aba23a8daa37b8bd2e1864a9c3d9d2 100644 (file)
--- a/render.h
+++ b/render.h
@@ -126,6 +126,7 @@ extern cvar_t r_dynamic;
 void R_Init(void);
 void R_UpdateVariables(void); // must call after setting up most of r_refdef, but before calling R_RenderView
 void R_RenderView(void); // must set r_refdef and call R_UpdateVariables first
+void R_RenderView_UpdateViewVectors(void); // just updates r_refdef.view.{forward,left,up,origin,right,inverse_matrix}
 
 typedef enum r_refdef_scene_type_s {
        RST_CLIENT,
index ad027b44de315adc63e792d668cb0f95d2e4f05c..741cae3651cf9fea24d297a57fa4d8daf62ed58e 100644 (file)
@@ -24,6 +24,7 @@ const char *vm_sv_extensions =
 "DP_CSQC_ENTITYWORLDOBJECT "
 "DP_CSQC_ENTITYMODELLIGHT "
 "DP_CSQC_ENTITYTRANSPARENTSORTING_OFFSET "
+"DP_CSQC_MAINVIEW "
 "DP_CSQC_MULTIFRAME_INTERPOLATION "
 "DP_CSQC_BOXPARTICLES "
 "DP_CSQC_SPAWNPARTICLE "