]> de.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)
committerdivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Tue, 8 Nov 2011 20:49:52 +0000 (20:49 +0000)
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

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

index a7555e86a3a4f0623a98a924d73630d219da9928..3ece601ae1689b9e26e10d546083fb25d069e516 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 536aad05e51791c6ef7d601a8fd2e2ff649308e5..1a6204d17bdbb6b2e65914c5df0d2e745872816e 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;
 
 // #1 void(vector ang) makevectors
 static void VM_CL_makevectors (prvm_prog_t *prog)
@@ -875,6 +876,9 @@ static void VM_CL_R_SetView (prvm_prog_t *prog)
                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;
@@ -1022,6 +1026,9 @@ static void VM_CL_R_SetView (prvm_prog_t *prog)
        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;
@@ -3041,6 +3048,17 @@ static void VM_CL_R_RenderScene (prvm_prog_t *prog)
        vmpolygons_t *polys = &prog->vmpolygons;
        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 732b6517c9b7df33f9974e2dc5c6f1a3b781c7bf..e4d1ed09c065124cdfc9f4d2f4a4da5c0c1354a5 100644 (file)
--- a/csprogs.c
+++ b/csprogs.c
@@ -450,6 +450,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)
 {
        prvm_prog_t *prog = CLVM_prog;
@@ -462,7 +463,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];
@@ -478,8 +481,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 95e1c48d29e83d68c8f85d1157025034b2250d95..2aba12b389140b9ad5de7595b191ebdcf324a677 100644 (file)
--- a/csprogs.h
+++ b/csprogs.h
@@ -50,6 +50,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 8e9817ef1e9ff8c521537df4b4fb100ba5fe2bfc..e8b15f35f13e9ed8992d6e6cff2f1a5cd6eb0e48 100644 (file)
@@ -5477,7 +5477,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 d2cccc63ad7b050f6a8269b8d8ae307f7182b07c..e81638ba88feac71a59c9a91da74f977a598f723 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 f6b0d1b697e89f4c637c5f73e7deb9e15d8b7742..3bb77ef654990f94c9e224736a778fa5f9b46412 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 "