recalculate state on drawable changes
authorKeith Whitwell <keith@tungstengraphics.com>
Fri, 30 Dec 2005 13:03:08 +0000 (13:03 +0000)
committerKeith Whitwell <keith@tungstengraphics.com>
Fri, 30 Dec 2005 13:03:08 +0000 (13:03 +0000)
src/mesa/drivers/dri/i915/intel_context.c
src/mesa/drivers/dri/i915/intel_state.c

index d39e45d0b33b4497d7890e7fdbf52d65fa5dbeb9..170d1df25d4b2702a2a8356e6ca7180f2a7887e6 100644 (file)
@@ -140,8 +140,14 @@ static void intelBufferSize(GLframebuffer *buffer,
     * to be correct.
     */
    LOCK_HARDWARE(intel);
-   *width = intel->driDrawable->w;
-   *height = intel->driDrawable->h;
+   if (intel->driDrawable) {
+      *width = intel->driDrawable->w;
+      *height = intel->driDrawable->h;
+   }
+   else {
+      *width = 0;
+      *height = 0;
+   }
    UNLOCK_HARDWARE(intel);
 }
 
@@ -528,6 +534,19 @@ void intelWindowMoved( intelContextPtr intel )
         intelSetFrontClipRects( intel );
       }
    }
+
+   /* Set state we know depends on drawable parameters:
+    */
+   {
+      GLcontext *ctx = &intel->ctx;
+
+      ctx->Driver.Scissor( ctx, ctx->Scissor.X, ctx->Scissor.Y,
+                          ctx->Scissor.Width, ctx->Scissor.Height );
+      
+      ctx->Driver.DepthRange( ctx, 
+                             ctx->Viewport.Near,
+                             ctx->Viewport.Far );
+   }
 }
 
 GLboolean intelUnbindContext(__DRIcontextPrivate *driContextPriv)
index 2343d061f527de04d8766fa8d9cb87533e152b7d..a2f2b2073882e0a8440977ad6d72bfa7392fca3a 100644 (file)
@@ -230,6 +230,10 @@ static void intelCalcViewport( GLcontext *ctx )
    intelContextPtr intel = INTEL_CONTEXT(ctx);
    const GLfloat *v = ctx->Viewport._WindowMap.m;
    GLfloat *m = intel->ViewportMatrix.m;
+   GLint h = 0;
+
+   if (intel->driDrawable) 
+      h = intel->driDrawable->h + SUBPIXEL_Y;
 
    /* See also intel_translate_vertex.  SUBPIXEL adjustments can be done
     * via state vars, too.
@@ -237,7 +241,7 @@ static void intelCalcViewport( GLcontext *ctx )
    m[MAT_SX] =   v[MAT_SX];
    m[MAT_TX] =   v[MAT_TX] + SUBPIXEL_X;
    m[MAT_SY] = - v[MAT_SY];
-   m[MAT_TY] = - v[MAT_TY] + intel->driDrawable->h + SUBPIXEL_Y;
+   m[MAT_TY] = - v[MAT_TY] + h;
    m[MAT_SZ] =   v[MAT_SZ] * intel->depth_scale;
    m[MAT_TZ] =   v[MAT_TZ] * intel->depth_scale;
 }