push/pop color table state (Eric Plante)
[mesa.git] / src / mesa / swrast / s_alphabuf.c
index 2eab878a23af128c570d7f9d6bcfb0a7394e5a58..0c82055721c6f49c34895c64164cede6ebf72da7 100644 (file)
@@ -1,8 +1,8 @@
-/* $Id: s_alphabuf.c,v 1.12 2002/10/04 19:10:12 brianp Exp $ */
+/* $Id: s_alphabuf.c,v 1.16 2002/11/26 02:58:43 brianp Exp $ */
 
 /*
  * Mesa 3-D graphics library
- * Version:  4.1
+ * Version:  5.0.1
  *
  * Copyright (C) 1999-2002  Brian Paul   All Rights Reserved.
  *
 
 
 #include "glheader.h"
+#include "colormac.h"
 #include "context.h"
-#include "mem.h"
+#include "imports.h"
 
+#include "s_context.h"
 #include "s_alphabuf.h"
 
 
@@ -102,9 +104,11 @@ _mesa_alloc_alpha_buffers( GLframebuffer *buffer )
 void
 _mesa_clear_alpha_buffers( GLcontext *ctx )
 {
-   const GLchan aclear = ctx->Color.ClearColor[3];
+   GLchan aclear;
    GLuint bufferBit;
 
+   CLAMPED_FLOAT_TO_CHAN(aclear, ctx->Color.ClearColor[3]);
+
    ASSERT(ctx->DrawBuffer->UseSoftwareAlphaBuffers);
    ASSERT(ctx->Color.ColorMask[ACOMP]);
 
@@ -171,22 +175,24 @@ _mesa_clear_alpha_buffers( GLcontext *ctx )
 static INLINE
 GLchan *get_alpha_buffer( GLcontext *ctx )
 {
-   switch (ctx->Color._DriverDrawBuffer) {
-   case GL_FRONT_LEFT:
+   SWcontext *swrast = SWRAST_CONTEXT(ctx);
+
+   switch (swrast->CurrentBuffer) {
+   case FRONT_LEFT_BIT:
       return (GLchan *) ctx->DrawBuffer->FrontLeftAlpha;
       break;
-   case GL_BACK_LEFT:
+   case BACK_LEFT_BIT:
       return (GLchan *) ctx->DrawBuffer->BackLeftAlpha;
       break;
-   case GL_FRONT_RIGHT:
+   case FRONT_RIGHT_BIT:
       return (GLchan *) ctx->DrawBuffer->FrontRightAlpha;
       break;
-   case GL_BACK_RIGHT:
+   case BACK_RIGHT_BIT:
       return (GLchan *) ctx->DrawBuffer->BackRightAlpha;
       break;
    default:
-      _mesa_problem(ctx, "Bad DriverDrawBuffer in _mesa_write_alpha_span()");
-      return (GLchan *) ctx->DrawBuffer->FrontLeftAlpha; /* aribitrary */
+      _mesa_problem(ctx, "Bad CurrentBuffer in get_alpha_buffer()");
+      return (GLchan *) ctx->DrawBuffer->FrontLeftAlpha;
    }
 }