move r_stereo adjustments into R_RenderView so that it executes AFTER CSQC may have...
authordivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 24 Nov 2010 20:58:27 +0000 (20:58 +0000)
committerdivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 24 Nov 2010 20:58:27 +0000 (20:58 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@10626 d7cf8633-e32d-0410-b094-e92efae38249

cl_screen.c
gl_rmain.c
screen.h

index 70f4db8..514f514 100644 (file)
@@ -2238,11 +2238,6 @@ void CL_UpdateScreen(void)
 
        if (R_Stereo_Active())
        {
-               matrix4x4_t originalmatrix = r_refdef.view.matrix;
-               matrix4x4_t offsetmatrix;
-               Matrix4x4_CreateFromQuakeEntity(&offsetmatrix, 0, r_stereo_separation.value * 0.5f, 0, 0, r_stereo_angle.value * 0.5f, 0, 1);
-               Matrix4x4_Concat(&r_refdef.view.matrix, &originalmatrix, &offsetmatrix);
-
                r_stereo_side = 0;
 
                if (r_stereo_redblue.integer || r_stereo_redgreen.integer || r_stereo_redcyan.integer)
@@ -2257,9 +2252,6 @@ void CL_UpdateScreen(void)
 
                SCR_DrawScreen();
 
-               Matrix4x4_CreateFromQuakeEntity(&offsetmatrix, 0, r_stereo_separation.value * -0.5f, 0, 0, r_stereo_angle.value * -0.5f, 0, 1);
-               Matrix4x4_Concat(&r_refdef.view.matrix, &originalmatrix, &offsetmatrix);
-
                r_stereo_side = 1;
 
                if (r_stereo_redblue.integer || r_stereo_redgreen.integer || r_stereo_redcyan.integer)
@@ -2273,8 +2265,6 @@ void CL_UpdateScreen(void)
                        qglDrawBuffer(GL_BACK_LEFT);
 
                SCR_DrawScreen();
-
-               r_refdef.view.matrix = originalmatrix;
        }
        else
                SCR_DrawScreen();
index e9aa506..356dd37 100644 (file)
@@ -9636,6 +9636,7 @@ R_RenderView
 */
 void R_RenderView(void)
 {
+       matrix4x4_t originalmatrix = r_refdef.view.matrix, offsetmatrix;
        if (r_timereport_active)
                R_TimeReport("start");
        r_textureframe++; // used only by R_GetCurrentTexture
@@ -9650,6 +9651,13 @@ void R_RenderView(void)
        R_AnimCache_ClearCache();
        R_FrameData_NewFrame();
 
+       /* adjust for stereo display */
+       if(R_Stereo_Active())
+       {
+               Matrix4x4_CreateFromQuakeEntity(&offsetmatrix, 0, r_stereo_separation.value * (0.5f - r_stereo_side), 0, 0, r_stereo_angle.value * (0.5f - r_stereo_side), 0, 1);
+               Matrix4x4_Concat(&r_refdef.view.matrix, &originalmatrix, &offsetmatrix);
+       }
+
        if (r_refdef.view.isoverlay)
        {
                // TODO: FIXME: move this into its own backend function maybe? [2/5/2008 Andreas]
@@ -9663,12 +9671,17 @@ void R_RenderView(void)
 
                R_RenderScene();
 
+               r_refdef.view.matrix = originalmatrix;
+
                CHECKGLERROR
                return;
        }
 
        if (!r_refdef.scene.entities || r_refdef.view.width * r_refdef.view.height == 0 || !r_renderview.integer || cl_videoplaying/* || !r_refdef.scene.worldmodel*/)
+       {
+               r_refdef.view.matrix = originalmatrix;
                return; //Host_Error ("R_RenderView: NULL worldmodel");
+       }
 
        r_refdef.view.colorscale = r_hdr_scenebrightness.value;
 
@@ -9721,6 +9734,8 @@ void R_RenderView(void)
        GL_Scissor(0, 0, vid.width, vid.height);
        GL_ScissorTest(false);
 
+       r_refdef.view.matrix = originalmatrix;
+
        CHECKGLERROR
 }
 
index 05befb2..7574d40 100644 (file)
--- a/screen.h
+++ b/screen.h
@@ -66,5 +66,10 @@ extern cvar_t r_letterbox;
 extern cvar_t scr_refresh;
 extern cvar_t scr_stipple;
 
+extern cvar_t r_stereo_separation;
+extern cvar_t r_stereo_angle;
+qboolean R_Stereo_Active(void);
+extern int r_stereo_side;
+
 #endif