From 1f12a07380e8cd4165d94c33661f1ada31f22222 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 8 Feb 2001 15:57:01 +0000 Subject: [PATCH] fixed bugs in _mesa_clear_depth_buffer(), bug #131366 --- src/mesa/swrast/s_depth.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/mesa/swrast/s_depth.c b/src/mesa/swrast/s_depth.c index 92a5a12de1a..c5e1b45d101 100644 --- a/src/mesa/swrast/s_depth.c +++ b/src/mesa/swrast/s_depth.c @@ -1,4 +1,4 @@ -/* $Id: s_depth.c,v 1.4 2001/01/23 23:39:37 brianp Exp $ */ +/* $Id: s_depth.c,v 1.5 2001/02/08 15:57:01 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -1539,29 +1539,31 @@ _mesa_clear_depth_buffer( GLcontext *ctx ) if (ctx->Visual.depthBits <= 16) { const GLushort clearValue = (GLushort) (ctx->Depth.Clear * ctx->DepthMax); const GLint rows = ctx->DrawBuffer->_Ymax - ctx->DrawBuffer->_Ymin; - const GLint width = ctx->DrawBuffer->Width; + const GLint cols = ctx->DrawBuffer->_Xmax - ctx->DrawBuffer->_Xmin; + const GLint rowStride = ctx->DrawBuffer->Width; GLushort *dRow = (GLushort *) ctx->DrawBuffer->DepthBuffer - + ctx->DrawBuffer->_Ymin * width + ctx->DrawBuffer->_Xmin; + + ctx->DrawBuffer->_Ymin * rowStride + ctx->DrawBuffer->_Xmin; GLint i, j; for (i = 0; i < rows; i++) { - for (j = 0; j < width; j++) { + for (j = 0; j < cols; j++) { dRow[j] = clearValue; } - dRow += width; + dRow += rowStride; } } else { const GLuint clearValue = (GLuint) (ctx->Depth.Clear * ctx->DepthMax); const GLint rows = ctx->DrawBuffer->_Ymax - ctx->DrawBuffer->_Ymin; - const GLint width = ctx->DrawBuffer->Width; + const GLint cols = ctx->DrawBuffer->_Xmax - ctx->DrawBuffer->_Xmin; + const GLint rowStride = ctx->DrawBuffer->Width; GLuint *dRow = (GLuint *) ctx->DrawBuffer->DepthBuffer - + ctx->DrawBuffer->_Ymin * width + ctx->DrawBuffer->_Xmin; + + ctx->DrawBuffer->_Ymin * rowStride + ctx->DrawBuffer->_Xmin; GLint i, j; for (i = 0; i < rows; i++) { - for (j = 0; j < width; j++) { + for (j = 0; j < cols; j++) { dRow[j] = clearValue; } - dRow += width; + dRow += rowStride; } } } -- 2.30.2