From 4e856077b798c70e14c2d0bb5ea27be9cc87e5c8 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Mon, 19 Mar 2001 22:45:52 +0000 Subject: [PATCH] fix for gl_ztrick bug (Ove Kaaven) --- src/mesa/main/matrix.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/mesa/main/matrix.c b/src/mesa/main/matrix.c index 466911c987d..a2b7af02ba2 100644 --- a/src/mesa/main/matrix.c +++ b/src/mesa/main/matrix.c @@ -1,4 +1,4 @@ -/* $Id: matrix.c,v 1.33 2001/03/03 20:33:27 brianp Exp $ */ +/* $Id: matrix.c,v 1.34 2001/03/19 22:45:52 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -449,6 +449,9 @@ void _mesa_set_viewport( GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height ) { + const GLfloat n = ctx->Viewport.Near; + const GLfloat f = ctx->Viewport.Far; + if (width < 0 || height < 0) { _mesa_error( ctx, GL_INVALID_VALUE, "glViewport" ); return; @@ -474,8 +477,8 @@ _mesa_set_viewport( GLcontext *ctx, GLint x, GLint y, ctx->Viewport._WindowMap.m[MAT_TX] = ctx->Viewport._WindowMap.m[MAT_SX] + x; ctx->Viewport._WindowMap.m[MAT_SY] = (GLfloat) height / 2.0F; ctx->Viewport._WindowMap.m[MAT_TY] = ctx->Viewport._WindowMap.m[MAT_SY] + y; - ctx->Viewport._WindowMap.m[MAT_SZ] = 0.5 * ctx->DepthMaxF; - ctx->Viewport._WindowMap.m[MAT_TZ] = 0.5 * ctx->DepthMaxF; + ctx->Viewport._WindowMap.m[MAT_SZ] = ctx->DepthMaxF * ((f - n) / 2.0); + ctx->Viewport._WindowMap.m[MAT_TZ] = ctx->DepthMaxF * ((f - n) / 2.0 + n); ctx->Viewport._WindowMap.flags = MAT_FLAG_GENERAL_SCALE|MAT_FLAG_TRANSLATION; ctx->Viewport._WindowMap.type = MATRIX_3D_NO_ROT; ctx->NewState |= _NEW_VIEWPORT; -- 2.30.2