fix for (some of?) the vertex array problems
[mesa.git] / src / mesa / main / attrib.c
index 527cd2d8bb7fe66f1c3e9a3f224eb22951935b9c..e346538eead0bbb0cc0bb09345ad04b89551ddb8 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: attrib.c,v 1.2 1999/09/16 11:54:56 keithw Exp $ */
+/* $Id: attrib.c,v 1.10 1999/11/08 15:28:08 brianp Exp $ */
 
 /*
  * Mesa 3-D graphics library
 
 
 
-
+#include <stdlib.h>
 
 #ifdef PC_HEADER
 #include "all.h"
 #else
-#include <stdlib.h>
+#ifndef XFree86Server
 #include <stdio.h>
-#include <string.h>
+#else
+#include "GL/xf86glx.h"
+#endif
 #include "attrib.h"
 #include "context.h"
+#include "glmisc.h"
 #include "enable.h"
 #include "enums.h"
 #include "macros.h"
-#include "misc.h"
 #include "simple_list.h"
 #include "texstate.h"
 #include "types.h"
-#ifdef XFree86Server
-#undef MISC_H
-#include "GL/xf86glx.h"
-#endif
 #endif
 
 
-#define MALLOC_STRUCT(T)  (struct T *) malloc( sizeof(struct T) )
-
 
 
 /*
@@ -60,9 +56,7 @@
  */
 static struct gl_attrib_node *new_attrib_node( GLbitfield kind )
 {
-   struct gl_attrib_node *an;
-
-   an = (struct gl_attrib_node *) malloc( sizeof(struct gl_attrib_node) );
+   struct gl_attrib_node *an = MALLOC_STRUCT(gl_attrib_node);
    if (an) {
       an->kind = kind;
    }
@@ -322,7 +316,7 @@ void gl_PushAttrib( GLcontext* ctx, GLbitfield mask )
 
    if (mask & GL_POLYGON_STIPPLE_BIT) {
       GLuint *stipple;
-      stipple = (GLuint *) malloc( 32*sizeof(GLuint) );
+      stipple = (GLuint *) MALLOC( 32*sizeof(GLuint) );
       MEMCPY( stipple, ctx->PolygonStipple, 32*sizeof(GLuint) );
       newnode = new_attrib_node( GL_POLYGON_STIPPLE_BIT );
       newnode->data = stipple;
@@ -492,6 +486,7 @@ void gl_PopAttrib( GLcontext* ctx )
                }
                TEST_AND_UPDATE(ctx->Light.ColorMaterialEnabled, enable->ColorMaterial, GL_COLOR_MATERIAL);
                TEST_AND_UPDATE(ctx->Polygon.CullFlag, enable->CullFace, GL_CULL_FACE);
+               TEST_AND_UPDATE(ctx->Depth.Test, enable->DepthTest, GL_DEPTH_TEST);
                TEST_AND_UPDATE(ctx->Color.DitherFlag, enable->Dither, GL_DITHER);
                TEST_AND_UPDATE(ctx->Fog.Enabled, enable->Fog, GL_FOG);
                TEST_AND_UPDATE(ctx->Light.Enabled, enable->Lighting, GL_LIGHTING);
@@ -586,10 +581,10 @@ void gl_PopAttrib( GLcontext* ctx )
             break;
          case GL_FOG_BIT:
             {
-               GLboolean anyChange = (memcmp( &ctx->Fog, attr->data, sizeof(struct gl_fog_attrib) ) != 0);
+               GLboolean anyChange = (GLboolean) (memcmp( &ctx->Fog, attr->data, sizeof(struct gl_fog_attrib) ) != 0);
                MEMCPY( &ctx->Fog, attr->data, sizeof(struct gl_fog_attrib) );
                if (anyChange && ctx->Driver.Fogfv) {
-                  const GLfloat mode = ctx->Fog.Mode;
+                  const GLfloat mode = (GLfloat) ctx->Fog.Mode;
                   const GLfloat density = ctx->Fog.Density;
                   const GLfloat start = ctx->Fog.Start;
                   const GLfloat end = ctx->Fog.End;
@@ -700,9 +695,9 @@ void gl_PopAttrib( GLcontext* ctx )
                (*ctx->Driver.ClearStencil)( ctx, ctx->Stencil.Clear );
             if (ctx->Driver.Enable)
                (*ctx->Driver.Enable)( ctx, GL_STENCIL_TEST, ctx->Stencil.Enabled );
-/*         ctx->TriangleCaps &= ~DD_STENCIL; */
-/*         if (ctx->Stencil.Enabled) */
-/*            ctx->TriangleCaps |= DD_STENCIL; */
+           ctx->TriangleCaps &= ~DD_STENCIL;
+           if (ctx->Stencil.Enabled)
+              ctx->TriangleCaps |= DD_STENCIL;
 
             break;
          case GL_TRANSFORM_BIT:
@@ -757,8 +752,8 @@ void gl_PopAttrib( GLcontext* ctx )
       }
 
       next = attr->next;
-      free( (void *) attr->data );
-      free( (void *) attr );
+      FREE( attr->data );
+      FREE( attr );
       attr = next;
    }
 
@@ -854,8 +849,8 @@ void gl_PopClientAttrib( GLcontext *ctx )
       }
 
       next = attr->next;
-      free( (void *) attr->data );
-      free( (void *) attr );
+      FREE( attr->data );
+      FREE( attr );
       attr = next;
    }