fix GL_BACK color material bug
[mesa.git] / src / mesa / drivers / svga / svgamesa8.c
index ed61373559213d98733678849ec6efd568508bba..2578428178f3f88fa05c982a2fe94a5e2b6b6312 100644 (file)
@@ -1,8 +1,8 @@
-/* $Id: svgamesa8.c,v 1.2 2000/01/22 20:08:36 brianp Exp $ */
+/* $Id: svgamesa8.c,v 1.6 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
+
+#ifdef SVGA
+
 
 #include "svgapix.h"
+#include "svgamesa8.h"
 
-int __svga_drawpixel8(int x, int y, unsigned long c)
+static void __svga_drawpixel8(int x, int y, unsigned long c)
 {
     unsigned long offset;
-
     y = SVGAInfo->height-y-1;
     offset = y * SVGAInfo->linewidth + x;
-    SVGABuffer.BackBuffer[offset]=c;
-    
-    return 0;
+    SVGABuffer.DrawBuffer[offset]=c;
 }
 
-unsigned long __svga_getpixel8(int x, int y)
+static unsigned long __svga_getpixel8(int x, int y)
 {
     unsigned long offset;
-
     y = SVGAInfo->height-y-1;
     offset = y * SVGAInfo->linewidth + x;
-    return SVGABuffer.BackBuffer[offset];
+    return SVGABuffer.ReadBuffer[offset];
 }
 
 void __set_index8( GLcontext *ctx, GLuint index )
@@ -65,18 +68,33 @@ GLbitfield __clear8( GLcontext *ctx, GLbitfield mask, GLboolean all,
 {
    int i,j;
    
-   if (mask & GL_COLOR_BUFFER_BIT) {
-   
-    if (all) 
-    { 
-     memset(SVGABuffer.BackBuffer,SVGAMesa->clear_index,SVGABuffer.BufferSize);
-    } else {
-    for (i=x;i<width;i++)    
-     for (j=y;j<height;j++)    
-      __svga_drawpixel8(i,j,SVGAMesa->clear_index);
-    }
-   }    
-   return mask & (~GL_COLOR_BUFFER_BIT);
+   if (mask & DD_FRONT_LEFT_BIT) {
+      if (all) { 
+         memset(SVGABuffer.FrontBuffer, SVGAMesa->clear_index, SVGABuffer.BufferSize);
+      }
+      else {
+         GLubyte *tmp = SVGABuffer.DrawBuffer;
+         SVGABuffer.DrawBuffer = SVGABuffer.FrontBuffer;
+         for (i=x;i<width;i++)
+            for (j=y;j<height;j++)
+               __svga_drawpixel8(i,j,SVGAMesa->clear_index);
+         SVGABuffer.DrawBuffer = tmp;
+      }
+   }
+   if (mask & DD_BACK_LEFT_BIT) {
+      if (all) { 
+         memset(SVGABuffer.BackBuffer, SVGAMesa->clear_index, SVGABuffer.BufferSize);
+      }
+      else {
+         GLubyte *tmp = SVGABuffer.DrawBuffer;
+         SVGABuffer.DrawBuffer = SVGABuffer.BackBuffer;
+         for (i=x;i<width;i++)
+            for (j=y;j<height;j++)
+               __svga_drawpixel8(i,j,SVGAMesa->clear_index);
+         SVGABuffer.DrawBuffer = tmp;
+      }
+   }
+   return mask & (~(DD_FRONT_LEFT_BIT | DD_BACK_LEFT_BIT));
 }
 
 void __write_ci32_span8( const GLcontext *ctx, GLuint n, GLint x, GLint y,
@@ -157,3 +175,15 @@ void __read_ci32_pixels8( const GLcontext *ctx,
    }
 }
 
+
+#else
+
+
+/* silence compiler warning */
+extern void _mesa_svga8_dummy_function(void);
+void _mesa_svga8_dummy_function(void)
+{
+}
+
+
+#endif