}
-static void draw_allocate_vertices( struct draw_context *draw,
- GLuint nr_vertices )
+/**
+ * Allocate storage for post-transformation vertices.
+ */
+static void
+draw_allocate_vertices( struct draw_context *draw, GLuint nr_vertices )
{
+ assert(draw->vertex_size > 0);
draw->nr_vertices = nr_vertices;
draw->verts = (GLubyte *) malloc( nr_vertices * draw->vertex_size );
draw_invalidate_vcache( draw );
-static void draw_release_vertices( struct draw_context *draw )
+/**
+ * Free storage which was allocated by draw_allocate_vertices()
+ */
+static void
+draw_release_vertices( struct draw_context *draw )
{
free(draw->verts);
draw->verts = NULL;
}
-/* This is a hack & will all go away.
+/**
+ * This is a hack & will all go away.
*/
void draw_vb(struct draw_context *draw,
struct vertex_buffer *VB )
draw->in_vb = 1;
+ /* tell drawing pipeline we're beginning drawing */
draw->pipeline.first->begin( draw->pipeline.first );
- /* Allocate the vertices:
+ /* Allocate storage for the post-transform vertices:
*/
draw_allocate_vertices( draw, VB->Count );
draw->get_vertex = get_vertex;
for (i = 0; i < VB->PrimitiveCount; i++) {
-
- GLenum mode = VB->Primitive[i].mode;
- GLuint start = VB->Primitive[i].start;
+ const GLenum mode = VB->Primitive[i].mode;
+ const GLuint start = VB->Primitive[i].start;
GLuint length, first, incr;
/* Trim the primitive down to a legal size.
draw_prim( draw, start, length );
}
+ /* draw any left-over buffered prims */
draw_flush(draw);
+
+ /* tell drawing pipeline we're done drawing */
draw->pipeline.first->end( draw->pipeline.first );
+
+ /* free the post-transformed vertices */
draw_release_vertices( draw );
draw->verts = NULL;
draw->in_vb = 0;