added missing \'s
[mesa.git] / src / mesa / swrast / s_alphabuf.c
index 11b782e787949f60457701b2d35f90d1383c0a15..8c324a4588a2fc6538abfb899d008f6cb19c2c9b 100644 (file)
@@ -1,20 +1,21 @@
+/* $Id: s_alphabuf.c,v 1.7 2001/05/11 18:58:32 brianp Exp $ */
 
 /*
  * Mesa 3-D graphics library
  * Version:  3.5
- * 
- * Copyright (C) 1999-2000  Brian Paul   All Rights Reserved.
- * 
+ *
+ * Copyright (C) 1999-2001  Brian Paul   All Rights Reserved.
+ *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
  * to deal in the Software without restriction, including without limitation
  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  * and/or sell copies of the Software, and to permit persons to whom the
  * Software is furnished to do so, subject to the following conditions:
- * 
+ *
  * The above copyright notice and this permission notice shall be included
  * in all copies or substantial portions of the Software.
- * 
+ *
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
@@ -52,7 +53,7 @@
  * Input: ctx - the context
  *
  */
-static void 
+static void
 alloc_alpha_buffers( GLcontext *ctx, GLframebuffer *buf )
 {
    GLint bytes = buf->Width * buf->Height * sizeof(GLchan);
@@ -65,41 +66,41 @@ alloc_alpha_buffers( GLcontext *ctx, GLframebuffer *buf )
    buf->FrontLeftAlpha = (GLchan *) MALLOC( bytes );
    if (!buf->FrontLeftAlpha) {
       /* out of memory */
-      gl_error( ctx, GL_OUT_OF_MEMORY,
+      _mesa_error( ctx, GL_OUT_OF_MEMORY,
                 "Couldn't allocate front-left alpha buffer" );
    }
 
-   if (ctx->Visual.DBflag) {
+   if (ctx->Visual.doubleBufferMode) {
       if (buf->BackLeftAlpha) {
          FREE( buf->BackLeftAlpha );
       }
       buf->BackLeftAlpha = (GLchan *) MALLOC( bytes );
       if (!buf->BackLeftAlpha) {
          /* out of memory */
-         gl_error( ctx, GL_OUT_OF_MEMORY,
+         _mesa_error( ctx, GL_OUT_OF_MEMORY,
                       "Couldn't allocate back-left alpha buffer" );
       }
    }
 
-   if (ctx->Visual.StereoFlag) {
+   if (ctx->Visual.stereoMode) {
       if (buf->FrontRightAlpha) {
          FREE( buf->FrontRightAlpha );
       }
       buf->FrontRightAlpha = (GLchan *) MALLOC( bytes );
       if (!buf->FrontRightAlpha) {
          /* out of memory */
-         gl_error( ctx, GL_OUT_OF_MEMORY,
+         _mesa_error( ctx, GL_OUT_OF_MEMORY,
                    "Couldn't allocate front-right alpha buffer" );
       }
 
-      if (ctx->Visual.DBflag) {
+      if (ctx->Visual.doubleBufferMode) {
          if (buf->BackRightAlpha) {
             FREE( buf->BackRightAlpha );
          }
          buf->BackRightAlpha = (GLchan *) MALLOC( bytes );
          if (!buf->BackRightAlpha) {
             /* out of memory */
-            gl_error( ctx, GL_OUT_OF_MEMORY,
+            _mesa_error( ctx, GL_OUT_OF_MEMORY,
                       "Couldn't allocate back-right alpha buffer" );
          }
       }
@@ -135,7 +136,7 @@ _mesa_alloc_alpha_buffers( GLcontext *ctx )
 void
 _mesa_clear_alpha_buffers( GLcontext *ctx )
 {
-   const GLchan aclear = (GLint) (ctx->Color.ClearColor[3] * CHAN_MAXF);
+   const GLchan aclear = ctx->Color.ClearColor[3];
    GLuint bufferBit;
 
    ASSERT(ctx->DrawBuffer->UseSoftwareAlphaBuffers);
@@ -163,6 +164,7 @@ _mesa_clear_alpha_buffers( GLcontext *ctx )
             GLint j;
             GLint rowLen = ctx->DrawBuffer->_Xmax - ctx->DrawBuffer->_Xmin + 1;
             GLint rows = ctx->DrawBuffer->_Ymax - ctx->DrawBuffer->_Ymin + 1;
+            GLint width = ctx->DrawBuffer->Width;
             GLchan *aptr = buffer
                           + ctx->DrawBuffer->_Ymin * ctx->DrawBuffer->Width
                           + ctx->DrawBuffer->_Xmin;
@@ -174,13 +176,19 @@ _mesa_clear_alpha_buffers( GLcontext *ctx )
 #else
 #error unexpected CHAN_BITS value
 #endif
-               aptr += rowLen;
+               aptr += width;
             }
          }
          else {
             /* clear whole buffer */
-            GLuint bytes = ctx->DrawBuffer->Width * ctx->DrawBuffer->Height;
-            MEMSET( buffer, aclear, bytes );
+            GLuint pixels = ctx->DrawBuffer->Width * ctx->DrawBuffer->Height;
+#if CHAN_BITS == 8
+            MEMSET(buffer, aclear, pixels);
+#elif CHAN_BITS == 16
+            MEMSET16(buffer, aclear, pixels);
+#else
+#error unexpected CHAN_BITS value
+#endif
          }
       }
    }
@@ -308,6 +316,3 @@ _mesa_read_alpha_pixels( GLcontext *ctx,
       }
    }
 }
-
-
-