fix GL_BACK color material bug
[mesa.git] / src / mesa / main / matrix.c
index c8f25c0cd5a9db96d0164594c039ad273a9e8410..5eb5bb43f0c5daead20be807c423778bf10c4253 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: matrix.c,v 1.16 2000/03/03 17:47:39 brianp Exp $ */
+/* $Id: matrix.c,v 1.17 2000/04/08 18:57:45 brianp Exp $ */
 
 /*
  * Mesa 3-D graphics library
@@ -931,6 +931,10 @@ do {                                                                       \
         mat = &ctx->TextureMatrix[ctx->Texture.CurrentTransformUnit];  \
         flags |= NEW_TEXTURE_MATRIX;                                   \
         break;                                                         \
+      case GL_COLOR:                                                   \
+        mat = &ctx->ColorMatrix;                                       \
+        flags |= NEW_COLOR_MATRIX;                                     \
+        break;                                                         \
       default:                                                         \
          gl_problem(ctx, where);                                       \
    }                                                                   \
@@ -1037,6 +1041,7 @@ _mesa_MatrixMode( GLenum mode )
       case GL_MODELVIEW:
       case GL_PROJECTION:
       case GL_TEXTURE:
+      case GL_COLOR:
          ctx->Transform.MatrixMode = mode;
          break;
       default:
@@ -1090,6 +1095,14 @@ _mesa_PushMatrix( void )
                            &ctx->TextureMatrix[t] );
          }
          break;
+      case GL_COLOR:
+         if (ctx->ColorStackDepth >= MAX_COLOR_STACK_DEPTH - 1) {
+            gl_error( ctx,  GL_STACK_OVERFLOW, "glPushMatrix");
+            return;
+         }
+         gl_matrix_copy( &ctx->ColorStack[ctx->ColorStackDepth++],
+                         &ctx->ColorMatrix );
+         break;
       default:
          gl_problem(ctx, "Bad matrix mode in gl_PushMatrix");
    }
@@ -1147,6 +1160,14 @@ _mesa_PopMatrix( void )
                           &ctx->TextureStack[t][--ctx->TextureStackDepth[t]]);
          }
          break;
+      case GL_COLOR:
+         if (ctx->ColorStackDepth==0) {
+            gl_error( ctx,  GL_STACK_UNDERFLOW, "glPopMatrix");
+            return;
+         }
+         gl_matrix_copy(&ctx->ColorMatrix,
+                        &ctx->ColorStack[--ctx->ColorStackDepth]);
+         break;
       default:
          gl_problem(ctx, "Bad matrix mode in gl_PopMatrix");
    }