summaryrefslogtreecommitdiffstats
path: root/src/mesa/main/state.c
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2006-03-29 03:59:34 +0000
committerBrian Paul <[email protected]>2006-03-29 03:59:34 +0000
commit519a2e7cb7b8f026bd5fe711cdf12a20df1c46ae (patch)
tree3a5ace19786c23d217f9ed64fdad20e2726f3e53 /src/mesa/main/state.c
parentb687531f693548afc6d7cf7b5c6fb76926cc0dc9 (diff)
Move the computation of the viewport matrix into a new update_viewport_matrix()
function since the matrix depends on the viewport params and the framebuffer's depth buffer resolution. Fixes some renderbuffer / depth range issues. This simplifies the _mesa_set_viewport() and _mesa_DepthRange() functions too.
Diffstat (limited to 'src/mesa/main/state.c')
-rw-r--r--src/mesa/main/state.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c
index 994aaff7b00..7e452bdfd7f 100644
--- a/src/mesa/main/state.c
+++ b/src/mesa/main/state.c
@@ -945,6 +945,26 @@ update_program(GLcontext *ctx)
}
+static void
+update_viewport_matrix(GLcontext *ctx)
+{
+ const GLfloat depthMax = ctx->DrawBuffer->_DepthMaxF;
+
+ ASSERT(depthMax > 0);
+
+ /* Compute scale and bias values. This is really driver-specific
+ * and should be maintained elsewhere if at all.
+ * NOTE: RasterPos uses this.
+ */
+ _math_matrix_viewport(&ctx->Viewport._WindowMap,
+ ctx->Viewport.X, ctx->Viewport.Y,
+ ctx->Viewport.Width, ctx->Viewport.Height,
+ ctx->Viewport.Near, ctx->Viewport.Far,
+ depthMax);
+}
+
+
+
/**
* If __GLcontextRec::NewState is non-zero then this function \b must be called
* before rendering any primitive. Basically, function pointers and
@@ -1002,6 +1022,9 @@ _mesa_update_state( GLcontext *ctx )
if (new_state & (_NEW_ARRAY | _NEW_PROGRAM))
update_arrays( ctx );
+ if (new_state & (_NEW_BUFFERS | _NEW_VIEWPORT))
+ update_viewport_matrix(ctx);
+
if (ctx->_MaintainTexEnvProgram) {
if (new_state & (_NEW_TEXTURE | _DD_NEW_SEPARATE_SPECULAR | _NEW_FOG))
_mesa_UpdateTexEnvProgram(ctx);