vbo: return VP_NONE from get_program_mode() if running fixed-func vertex program
[mesa.git] / src / mesa / vbo / vbo_context.c
index 274d23248f1508a590a245353f09084dfb7001be..f193a4bf1e093f2daf747e7cf309241fe2ae7cfe 100644 (file)
 #include "main/imports.h"
 #include "main/mtypes.h"
 #include "main/api_arrayelt.h"
+#include "main/bufferobj.h"
+#include "math/m_eval.h"
 #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 +43,7 @@ extern void _tnl_draw_prims( GLcontext *ctx,
                             const struct _mesa_index_buffer *ib,
                             GLuint min_index,
                             GLuint max_index );
+#endif
 
 
 
@@ -78,7 +82,8 @@ static void init_legacy_currval(GLcontext *ctx)
       cl->Type = GL_FLOAT;
       cl->Format = GL_RGBA;
       cl->Ptr = (const void *)ctx->Current.Attrib[i];
-      cl->BufferObj = ctx->Array.NullBufferObj;
+      _mesa_reference_buffer_object(ctx, &cl->BufferObj,
+                                    ctx->Shared->NullBufferObj);
    }
 }
 
@@ -103,7 +108,8 @@ static void init_generic_currval(GLcontext *ctx)
       cl->Stride = 0;
       cl->StrideB = 0;
       cl->Enabled = 1;
-      cl->BufferObj = ctx->Array.NullBufferObj;
+      _mesa_reference_buffer_object(ctx, &cl->BufferObj,
+                                    ctx->Shared->NullBufferObj);
    }
 }
 
@@ -147,7 +153,7 @@ static void init_mat_currval(GLcontext *ctx)
       cl->Stride = 0;
       cl->StrideB = 0;
       cl->Enabled = 1;
-      cl->BufferObj = ctx->Array.NullBufferObj;
+      cl->BufferObj = ctx->Shared->NullBufferObj;
    }
 }
 
@@ -215,7 +221,9 @@ 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
@@ -226,6 +234,8 @@ GLboolean _vbo_CreateContext( GLcontext *ctx )
    vbo_save_init( ctx );
 #endif
 
+   _math_init_eval();
+
    return GL_TRUE;
 }
 
@@ -243,10 +253,20 @@ void _vbo_DestroyContext( GLcontext *ctx )
       ctx->aelt_context = NULL;
    }
 
-   vbo_exec_destroy(ctx);
+   if (vbo_context(ctx)) {
+      vbo_exec_destroy(ctx);
 #if FEATURE_dlist
-   vbo_save_destroy(ctx);
+      vbo_save_destroy(ctx);
 #endif
-   FREE(vbo_context(ctx));
-   ctx->swtnl_im = NULL;
+      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;
+}
+