From e3398d6d0804cacfeca760a45db71ed26c25cbd7 Mon Sep 17 00:00:00 2001 From: havoc Date: Thu, 20 May 2004 23:05:55 +0000 Subject: [PATCH] GL_TransformToScreen now properly calculates out[2], thanks to Vic for pointing out the flaw git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@4206 d7cf8633-e32d-0410-b094-e92efae38249 --- gl_backend.c | 2 +- gl_rmain.c | 4 ++++ render.h | 2 ++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/gl_backend.c b/gl_backend.c index 889aa0ef..c5cd70ae 100644 --- a/gl_backend.c +++ b/gl_backend.c @@ -696,7 +696,7 @@ void GL_TransformToScreen(const vec4_t in, vec4_t out) iw = 1.0f / out[3]; out[0] = r_view_x + (out[0] * iw + 1.0f) * r_view_width * 0.5f; out[1] = r_view_y + (out[1] * iw + 1.0f) * r_view_height * 0.5f; - out[2] = out[2] * iw; + out[2] = r_view_z + (out[2] * iw + 1.0f) * r_view_depth * 0.5f; } // called at beginning of frame diff --git a/gl_rmain.c b/gl_rmain.c index bf8e978b..53f42433 100644 --- a/gl_rmain.c +++ b/gl_rmain.c @@ -50,8 +50,10 @@ vec3_t r_viewright; vec3_t r_viewup; int r_view_x; int r_view_y; +int r_view_z; int r_view_width; int r_view_height; +int r_view_depth; float r_view_fov_x; float r_view_fov_y; matrix4x4_t r_view_matrix; @@ -617,8 +619,10 @@ void R_RenderView(void) r_view_width = bound(0, r_refdef.width, vid.realwidth); r_view_height = bound(0, r_refdef.height, vid.realheight); + r_view_depth = 1; r_view_x = bound(0, r_refdef.x, vid.realwidth - r_refdef.width); r_view_y = bound(0, r_refdef.y, vid.realheight - r_refdef.height); + r_view_z = 0; r_view_fov_x = bound(1, r_refdef.fov_x, 170); r_view_fov_y = bound(1, r_refdef.fov_y, 170); r_view_matrix = r_refdef.viewentitymatrix; diff --git a/render.h b/render.h index 339333ae..88299139 100644 --- a/render.h +++ b/render.h @@ -100,8 +100,10 @@ extern vec3_t r_viewright; extern vec3_t r_viewup; extern int r_view_x; extern int r_view_y; +extern int r_view_z; extern int r_view_width; extern int r_view_height; +extern int r_view_depth; extern float r_view_fov_x; extern float r_view_fov_y; extern matrix4x4_t r_view_matrix; -- 2.39.2