diff --git a/src/mesa/main/matrix.c b/src/mesa/main/matrix.c index 0f96f94..97bb18e 100644 --- a/src/mesa/main/matrix.c +++ b/src/mesa/main/matrix.c @@ -570,6 +570,8 @@ void _mesa_set_viewport( GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height ) { + GLfloat depthMaxF; + if (MESA_VERBOSE & VERBOSE_API) _mesa_debug(ctx, "glViewport %d %d %d %d\n", x, y, width, height); @@ -589,6 +591,9 @@ _mesa_set_viewport( GLcontext *ctx, GLint x, GLint y, ctx->Viewport.Height = height; ctx->NewState |= _NEW_VIEWPORT; + /* if we don't know the Z buffer's depth at this time, just use 1.0 */ + depthMaxF = ctx->DrawBuffer ? ctx->DrawBuffer->_DepthMaxF : 1.0F; + #if 1 /* XXX remove this someday. Currently the DRI drivers rely on * the WindowMap matrix being up to date in the driver's Viewport @@ -598,7 +603,7 @@ _mesa_set_viewport( GLcontext *ctx, GLint x, GLint y, ctx->Viewport.X, ctx->Viewport.Y, ctx->Viewport.Width, ctx->Viewport.Height, ctx->Viewport.Near, ctx->Viewport.Far, - ctx->DrawBuffer->_DepthMaxF); + depthMaxF); #endif if (ctx->Driver.Viewport) {