Merge commit 'origin/gallium-0.1' into gallium-0.2
[mesa.git] / src / mesa / vbo / vbo_context.c
index ad4556c500b1274a022c5fb48b7cfe7dc0862c6a..bbf745b0c629bf1f25b5b1350ffd755545851d3e 100644 (file)
@@ -31,6 +31,7 @@
 #include "vbo.h"
 #include "vbo_context.h"
 
+#if 0
 /* Reach out and grab this to use as the default:
  */
 extern void _tnl_draw_prims( GLcontext *ctx,
@@ -40,6 +41,7 @@ extern void _tnl_draw_prims( GLcontext *ctx,
                             const struct _mesa_index_buffer *ib,
                             GLuint min_index,
                             GLuint max_index );
+#endif
 
 
 
@@ -112,6 +114,8 @@ static void init_mat_currval(GLcontext *ctx)
    struct gl_client_array *arrays = vbo->mat_currval;
    GLuint i;
 
+   ASSERT(NR_MAT_ATTRIBS == MAT_ATTRIB_MAX);
+
    memset(arrays, 0, sizeof(*arrays) * NR_MAT_ATTRIBS);
 
    /* Set up a constant (StrideB == 0) array for each current
@@ -137,11 +141,7 @@ static void init_mat_currval(GLcontext *ctx)
         break;
       }
 
-      if (i < MAT_ATTRIB_MAX)
-        cl->Ptr = (const void *)ctx->Light.Material.Attrib[i];
-      else 
-        cl->Ptr = (const void *)ctx->Current.Attrib[VERT_ATTRIB_GENERIC0 + i];
-
+      cl->Ptr = (const void *)ctx->Light.Material.Attrib[i];
       cl->Type = GL_FLOAT;
       cl->Stride = 0;
       cl->StrideB = 0;
@@ -214,16 +214,19 @@ GLboolean _vbo_CreateContext( GLcontext *ctx )
 
    /* By default: 
     */
+#if 0 /* dead - see vbo_set_draw_func() */
    vbo->draw_prims = _tnl_draw_prims;
+#endif
 
    /* Hook our functions into exec and compile dispatch tables.  These
     * will pretty much be permanently installed, which means that the
     * vtxfmt mechanism can be removed now.
     */
    vbo_exec_init( ctx );
+#if FEATURE_dlist
    vbo_save_init( ctx );
+#endif
 
-   
    return GL_TRUE;
 }
 
@@ -241,7 +244,20 @@ void _vbo_DestroyContext( GLcontext *ctx )
       ctx->aelt_context = NULL;
    }
 
-   vbo_exec_destroy(ctx);
-   FREE(vbo_context(ctx));
-   ctx->swtnl_im = NULL;
+   if (vbo_context(ctx)) {
+      vbo_exec_destroy(ctx);
+#if FEATURE_dlist
+      vbo_save_destroy(ctx);
+#endif
+      FREE(vbo_context(ctx));
+      ctx->swtnl_im = NULL;
+   }
+}
+
+
+void vbo_set_draw_func(GLcontext *ctx, vbo_draw_func func)
+{
+   struct vbo_context *vbo = vbo_context(ctx);
+   vbo->draw_prims = func;
 }
+