From a06ee15a189cce7043b5151867210de24ccc2eb6 Mon Sep 17 00:00:00 2001
From: havoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Date: Thu, 14 Jun 2007 05:37:59 +0000
Subject: [PATCH] fix some bugs in the last commit (perspective was off)

git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@7420 d7cf8633-e32d-0410-b094-e92efae38249
---
 cl_screen.c | 4 ++++
 clvm_cmds.c | 6 ++++++
 2 files changed, 10 insertions(+)

diff --git a/cl_screen.c b/cl_screen.c
index 59809c91..f010ece6 100644
--- a/cl_screen.c
+++ b/cl_screen.c
@@ -1580,6 +1580,7 @@ static void R_Envmap_f (void)
 	r_view.width = size;
 	r_view.height = size;
 	r_view.depth = 1;
+	r_view.useperspective = true;
 
 	r_view.frustum_x = tan(90 * M_PI / 360.0);
 	r_view.frustum_y = tan(90 * M_PI / 360.0);
@@ -1814,6 +1815,7 @@ void SCR_DrawScreen (void)
 		// this it simply assumes the requested fov is the vertical fov
 		// for a 4x3 display, if the ratio is not 4x3 this makes the fov
 		// higher/lower according to the ratio
+		r_view.useperspective = true;
 		r_view.frustum_y = tan(scr_fov.value * M_PI / 360.0) * (3.0/4.0) * cl.viewzoom;
 		r_view.frustum_x = r_view.frustum_y * (float)r_view.width / (float)r_view.height / vid_pixelheight.value;
 
@@ -1834,6 +1836,7 @@ void SCR_DrawScreen (void)
 			r_view.y = 0;
 			r_view.z = 0;
 
+			r_view.useperspective = true;
 			r_view.frustum_y = tan(scr_zoomwindow_fov.value * M_PI / 360.0) * (3.0/4.0) * cl.viewzoom;
 			r_view.frustum_x = r_view.frustum_y * vid_pixelheight.value * (float)r_view.width / (float)r_view.height;
 
@@ -1853,6 +1856,7 @@ void SCR_DrawScreen (void)
 		r_view.x = 0;
 		r_view.y = 0;
 		r_view.z = 0;
+		r_view.useperspective = false;
 	}
 
 	// draw 2D stuff
diff --git a/clvm_cmds.c b/clvm_cmds.c
index b8544075..f84932a6 100644
--- a/clvm_cmds.c
+++ b/clvm_cmds.c
@@ -625,6 +625,12 @@ static void VM_CL_R_ClearScene (void)
 	r_view.width = vid.width;
 	r_view.height = vid.height;
 	r_view.depth = 1;
+	// FIXME: restore frustum_x/frustum_y
+	r_view.useperspective = true;
+	r_view.frustum_y = tan(scr_fov.value * M_PI / 360.0) * (3.0/4.0) * cl.viewzoom;
+	r_view.frustum_x = r_view.frustum_y * (float)r_view.width / (float)r_view.height / vid_pixelheight.value;
+	r_view.frustum_x *= r_refdef.frustumscale_x;
+	r_view.frustum_y *= r_refdef.frustumscale_y;
 	// FIXME: restore cl.csqc_origin
 	// FIXME: restore cl.csqc_angles
 	cl.csqc_vidvars.drawworld = true;
-- 
2.39.5