New vbo_set_draw_func() to keep vbo context opaque to state tracker and tnl module.
authorBrian <brian.paul@tungstengraphics.com>
Sat, 8 Dec 2007 00:24:42 +0000 (17:24 -0700)
committerBen Skeggs <skeggsb@gmail.com>
Sun, 9 Dec 2007 01:05:27 +0000 (12:05 +1100)
src/mesa/state_tracker/st_cb_feedback.c
src/mesa/state_tracker/st_draw.c
src/mesa/tnl/t_context.c
src/mesa/vbo/vbo.h
src/mesa/vbo/vbo_context.c

index a9fd2579a2250f973d270954b513b0708e45f467..ea775b9452d7c8f32688f86b7136e54333bca6df 100644 (file)
@@ -43,7 +43,6 @@
 #include "main/macros.h"
 
 #include "vbo/vbo.h"
-#include "vbo/vbo_context.h"
 
 #include "st_context.h"
 #include "st_atom.h"
@@ -281,26 +280,25 @@ static void
 st_RenderMode(GLcontext *ctx, GLenum newMode )
 {
    struct st_context *st = ctx->st;
-   struct vbo_context *vbo = (struct vbo_context *) ctx->swtnl_im;
    struct draw_context *draw = st->draw;
 
    if (newMode == GL_RENDER) {
       /* restore normal VBO draw function */
-      vbo->draw_prims = st_draw_vbo;
+      vbo_set_draw_func(ctx, st_draw_vbo);
    }
    else if (newMode == GL_SELECT) {
       if (!st->selection_stage)
          st->selection_stage = draw_glselect_stage(ctx, draw);
       draw_set_rasterize_stage(draw, st->selection_stage);
       /* Plug in new vbo draw function */
-      vbo->draw_prims = st_feedback_draw_vbo;
+      vbo_set_draw_func(ctx, st_feedback_draw_vbo);
    }
    else {
       if (!st->feedback_stage)
          st->feedback_stage = draw_glfeedback_stage(ctx, draw);
       draw_set_rasterize_stage(draw, st->feedback_stage);
       /* Plug in new vbo draw function */
-      vbo->draw_prims = st_feedback_draw_vbo;
+      vbo_set_draw_func(ctx, st_feedback_draw_vbo);
       /* need to generate/use a vertex program that emits pos/color/tex */
       st->dirty.st |= ST_NEW_VERTEX_PROGRAM;
    }
index b4c0d0cdd623dd2642ef9d640f3f0df19f1c3519..32dcd73c46c8b74d1f837b8251c992a527a32f66 100644 (file)
@@ -34,7 +34,6 @@
 #include "main/image.h"
 
 #include "vbo/vbo.h"
-#include "vbo/vbo_context.h"
 
 #include "st_atom.h"
 #include "st_cache.h"
@@ -519,14 +518,11 @@ st_feedback_draw_vbo(GLcontext *ctx,
 void st_init_draw( struct st_context *st )
 {
    GLcontext *ctx = st->ctx;
-   struct vbo_context *vbo = (struct vbo_context *) ctx->swtnl_im;
 
    /* actually, not used here, but elsewhere */
    create_default_attribs_buffer(st);
 
-   assert(vbo);
-   assert(vbo->draw_prims);
-   vbo->draw_prims = st_draw_vbo;
+   vbo_set_draw_func(ctx, st_draw_vbo);
 }
 
 
index b87452d2eb4b0903b856fabe561db102323fc9b7..0ace5c2d6f182f9994cf2189d2c10b48cafc1b4f 100644 (file)
@@ -78,6 +78,9 @@ _tnl_CreateContext( GLcontext *ctx )
 
    tnl->nr_blocks = 0;
 
+   /* plug in the VBO drawing function */
+   vbo_set_draw_func(ctx, _tnl_draw_prims);
+
    return GL_TRUE;
 }
 
index 4c51b44cdade1797823aff4959b16c3fed11e15b..79d33d09c16c475a06fd0da8cb2f05cfa8462a5b 100644 (file)
@@ -117,4 +117,7 @@ void vbo_rebase_prims( GLcontext *ctx,
 void vbo_use_buffer_objects(GLcontext *ctx);
 
 
+void vbo_set_draw_func(GLcontext *ctx, vbo_draw_func func);
+
+
 #endif
index ad4556c500b1274a022c5fb48b7cfe7dc0862c6a..60d0b76ab622f0d5ccfa703b04d02c7ec5af11ad 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
 
 
 
@@ -214,7 +216,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
@@ -245,3 +249,11 @@ void _vbo_DestroyContext( GLcontext *ctx )
    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;
+}
+