From d404f9aaa347ec6506ecff1de63ff55673e91881 Mon Sep 17 00:00:00 2001 From: divverent Date: Wed, 24 Nov 2010 20:58:27 +0000 Subject: [PATCH] move r_stereo adjustments into R_RenderView so that it executes AFTER CSQC may have adjusted the view. Makes redblue stereo work even in steel storm. git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@10626 d7cf8633-e32d-0410-b094-e92efae38249 --- cl_screen.c | 10 ---------- gl_rmain.c | 15 +++++++++++++++ screen.h | 5 +++++ 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/cl_screen.c b/cl_screen.c index 70f4db8a..514f514b 100644 --- a/cl_screen.c +++ b/cl_screen.c @@ -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(); diff --git a/gl_rmain.c b/gl_rmain.c index e9aa5060..356dd378 100644 --- a/gl_rmain.c +++ b/gl_rmain.c @@ -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 } diff --git a/screen.h b/screen.h index 05befb2c..7574d40d 100644 --- 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 -- 2.39.2