fix GL_BACK color material bug
[mesa.git] / src / mesa / drivers / svga / svgamesa32.c
index 204d582cf3d7cc4f27b31ccc64b8bed4363e5596..1fbef3d26d15facbab4db167a9554dda37164fa6 100644 (file)
@@ -1,8 +1,8 @@
-/* $Id: svgamesa32.c,v 1.2 2000/01/22 20:08:36 brianp Exp $ */
+/* $Id: svgamesa32.c,v 1.7 2000/06/14 21:59:07 brianp Exp $ */
 
 /*
  * Mesa 3-D graphics library
- * Version:  3.2
+ * Version:  3.3
  * Copyright (C) 1995-2000  Brian Paul
  *
  * This library is free software; you can redistribute it and/or
  * Additional authors:  Slawomir Szczyrba <steev@hot.pl>  (Mesa 3.2)
  */
 
+#ifdef HAVE_CONFIG_H
+#include "conf.h"
+#endif
 
-#include "svgapix.h"
+#ifdef SVGA
 
-GLint * intBuffer;
+#include "svgapix.h"
+#include "svgamesa32.h"
 
-inline int RGB2BGR32(int c)
+#if 0
+/* this doesn't compile with GCC on RedHat 6.1 */
+static inline int RGB2BGR32(int c)
 {
        asm("rorw  $8, %0\n"     
            "rorl $16, %0\n"     
@@ -41,23 +47,28 @@ inline int RGB2BGR32(int c)
       : "=q"(c):"0"(c));
     return c;
 }
+#else
+static unsigned long RGB2BGR32(unsigned long color)
+{
+   return (color & 0xff00)|(color>>16)|((color & 0xff)<<16);
+}
+#endif
 
-int __svga_drawpixel32(int x, int y, unsigned long c)
+static void __svga_drawpixel32(int x, int y, unsigned long c)
 {
     unsigned long offset;
 
-    intBuffer=(void *)SVGABuffer.BackBuffer;
+    GLint *intBuffer=(void *)SVGABuffer.DrawBuffer;
     y = SVGAInfo->height-y-1;
     offset = y * SVGAInfo->width + x;
     intBuffer[offset]=c;
-    return 0;
 }
 
-unsigned long __svga_getpixel32(int x, int y)
+static unsigned long __svga_getpixel32(int x, int y)
 {
     unsigned long offset;
 
-    intBuffer=(void *)SVGABuffer.BackBuffer;
+    const GLint *intBuffer=(void *)SVGABuffer.ReadBuffer;
     y = SVGAInfo->height-y-1;
     offset = y * SVGAInfo->width + x;
     return intBuffer[offset];
@@ -85,17 +96,37 @@ GLbitfield __clear32( GLcontext *ctx, GLbitfield mask, GLboolean all,
 {
    int i,j;
    
-   if (mask & GL_COLOR_BUFFER_BIT) {
-    if (all) {
-     intBuffer=(void *)SVGABuffer.BackBuffer;
-     for (i=0;i<SVGABuffer.BufferSize / 4;i++) intBuffer[i]=SVGAMesa->clear_truecolor;
-    } else {
-    for (i=x;i<width;i++)    
-     for (j=y;j<height;j++)    
-      __svga_drawpixel32(i,j,SVGAMesa->clear_truecolor);
-    }  
+   if (mask & DD_FRONT_LEFT_BIT) {
+      if (all) {
+         GLint *intBuffer=(void *)SVGABuffer.FrontBuffer;
+         for (i=0;i<SVGABuffer.BufferSize / 4;i++)
+            intBuffer[i]=SVGAMesa->clear_truecolor;
+      }
+      else {
+         GLubyte *tmp = SVGABuffer.DrawBuffer;
+         SVGABuffer.DrawBuffer = SVGABuffer.FrontBuffer;
+         for (i=x;i<width;i++)    
+            for (j=y;j<height;j++)    
+               __svga_drawpixel32(i,j,SVGAMesa->clear_truecolor);
+         SVGABuffer.DrawBuffer = tmp;
+      }
+   }
+   if (mask & DD_BACK_LEFT_BIT) {
+      if (all) {
+         GLint *intBuffer=(void *)SVGABuffer.BackBuffer;
+         for (i=0;i<SVGABuffer.BufferSize / 4;i++)
+            intBuffer[i]=SVGAMesa->clear_truecolor;
+      }
+      else {
+         GLubyte *tmp = SVGABuffer.DrawBuffer;
+         SVGABuffer.DrawBuffer = SVGABuffer.BackBuffer;
+         for (i=x;i<width;i++)    
+            for (j=y;j<height;j++)    
+               __svga_drawpixel32(i,j,SVGAMesa->clear_truecolor);
+         SVGABuffer.DrawBuffer = tmp;
+      }
    }
-   return mask & (~GL_COLOR_BUFFER_BIT);
+   return mask & (~(DD_FRONT_LEFT_BIT | DD_BACK_LEFT_BIT));
 }
 
 void __write_rgba_span32( const GLcontext *ctx, GLuint n, GLint x, GLint y,
@@ -174,3 +205,17 @@ void __read_rgba_pixels32( const GLcontext *ctx,
     *((GLint*)rgba[i]) = RGB2BGR32(__svga_getpixel32( x[i], y[i] ));
    }
 }
+
+
+#else
+
+
+/* silence compiler warning */
+extern void _mesa_svga32_dummy_function(void);
+void _mesa_svga32_dummy_function(void)
+{
+}
+
+
+#endif
+