]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
recalc the 2D view if changing view parameters with R_SetView
authordivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 19 Aug 2010 07:21:30 +0000 (07:21 +0000)
committerRudolf Polzer <divVerent@alientrap.org>
Fri, 20 Aug 2010 12:05:55 +0000 (14:05 +0200)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@10397 d7cf8633-e32d-0410-b094-e92efae38249
::stable-branch::merge=15ba263dfc057719e51ffd7ba6ecb0fe7efb400c

client.h
clvm_cmds.c
draw.h
gl_draw.c

index edb4e79bb5c5d45d5d1c10152c2d33389d2cfc6f..d6543754fe1527dbe1f48f437382a4b62d4ae7d1 100644 (file)
--- a/client.h
+++ b/client.h
@@ -1766,7 +1766,7 @@ typedef struct r_refdef_s
        float fog_height_texcoordscale;
        char fogheighttexturename[64]; // detects changes to active fog height texture
 
-       qboolean draw2dstage;
+       int draw2dstage; // 0 = no, 1 = yes, other value = needs setting up again
 
        // true during envmap command capture
        qboolean envmap;
index cfe426c5cd39907340784181c15e3b786ce4ee7c..d11d9e5887ee36c2a0d11c680b9eb23885b3a73b 100644 (file)
@@ -887,22 +887,28 @@ void VM_CL_R_SetView (void)
        case VF_MIN:
                r_refdef.view.x = (int)(f[0]);
                r_refdef.view.y = (int)(f[1]);
+               DrawQ_RecalcView();
                break;
        case VF_MIN_X:
                r_refdef.view.x = (int)(k);
+               DrawQ_RecalcView();
                break;
        case VF_MIN_Y:
                r_refdef.view.y = (int)(k);
+               DrawQ_RecalcView();
                break;
        case VF_SIZE:
                r_refdef.view.width = (int)(f[0]);
                r_refdef.view.height = (int)(f[1]);
+               DrawQ_RecalcView();
                break;
        case VF_SIZE_X:
                r_refdef.view.width = (int)(k);
+               DrawQ_RecalcView();
                break;
        case VF_SIZE_Y:
                r_refdef.view.height = (int)(k);
+               DrawQ_RecalcView();
                break;
        case VF_VIEWPORT:
                r_refdef.view.x = (int)(f[0]);
@@ -910,6 +916,7 @@ void VM_CL_R_SetView (void)
                f = PRVM_G_VECTOR(OFS_PARM2);
                r_refdef.view.width = (int)(f[0]);
                r_refdef.view.height = (int)(f[1]);
+               DrawQ_RecalcView();
                break;
        case VF_FOV:
                r_refdef.view.frustum_x = tan(f[0] * M_PI / 360.0);r_refdef.view.ortho_x = f[0];
diff --git a/draw.h b/draw.h
index 5a8f6137d7b97f97903aeb8d8a81f2f812e3f418..ace96f8cb06425a7d28cdb8e53fad18fc01f9ad3 100644 (file)
--- a/draw.h
+++ b/draw.h
@@ -183,6 +183,7 @@ void DrawQ_LineLoop(drawqueuemesh_t *mesh, int flags);
 // resets r_refdef.draw2dstage
 void DrawQ_Finish(void);
 void DrawQ_ProcessDrawFlag(int flags, qboolean alpha); // sets GL_DepthMask and GL_BlendFunc
+void DrawQ_RecalcView(void); // use this when changing r_refdef.view.* from e.g. csqc
 
 void R_DrawGamma(void);
 
index 40220d1d9cf6acea4d4072926f6a059221bf6d62..f2c4f0192023433f73c83b56c3acdfb48128823f 100644 (file)
--- a/gl_draw.c
+++ b/gl_draw.c
@@ -982,9 +982,9 @@ void GL_Draw_Init (void)
 static void _DrawQ_Setup(void)
 {
        r_viewport_t viewport;
-       if (r_refdef.draw2dstage)
+       if (r_refdef.draw2dstage == 1)
                return;
-       r_refdef.draw2dstage = true;
+       r_refdef.draw2dstage = 1;
        CHECKGLERROR
        R_Viewport_InitOrtho(&viewport, &identitymatrix, r_refdef.view.x, vid.height - r_refdef.view.y - r_refdef.view.height, r_refdef.view.width, r_refdef.view.height, 0, 0, vid_conwidth.integer, vid_conheight.integer, -10, 100, NULL);
        R_SetViewport(&viewport);
@@ -1936,7 +1936,13 @@ void DrawQ_ResetClipArea(void)
 
 void DrawQ_Finish(void)
 {
-       r_refdef.draw2dstage = false;
+       r_refdef.draw2dstage = 0;
+}
+
+void DrawQ_RecalcView(void)
+{
+       if(r_refdef.draw2dstage)
+               r_refdef.draw2dstage = -1; // next draw call will set viewport etc. again
 }
 
 static float blendvertex3f[9] = {-5000, -5000, 10, 10000, -5000, 10, -5000, 10000, 10};