/** * Flush existing vertex buffer and allocate a new one. */ static void vbuf_flush_vertices( struct vbuf_stage *vbuf ) { if(vbuf->vertices) { vbuf->render->unmap_vertices( vbuf->render, 0, vbuf->nr_vertices - 1 ); if (vbuf->nr_indices) { vbuf->render->draw(vbuf->render, vbuf->indices, vbuf->nr_indices ); vbuf->nr_indices = 0; } /* Reset temporary vertices ids */ if(vbuf->nr_vertices) draw_reset_vertex_ids( vbuf->stage.draw ); /* Free the vertex buffer */ vbuf->render->release_vertices( vbuf->render ); vbuf->max_vertices = vbuf->nr_vertices = 0; vbuf->vertex_ptr = vbuf->vertices = NULL; } }
/** * Flush existing vertex buffer and allocate a new one. */ static void vbuf_flush_vertices( struct vbuf_stage *vbuf ) { if(vbuf->vertices) { vbuf->render->unmap_vertices( vbuf->render, 0, vbuf->nr_vertices - 1 ); if (vbuf->nr_indices) { vbuf->render->draw_elements(vbuf->render, vbuf->indices, vbuf->nr_indices ); vbuf->nr_indices = 0; } /* Reset temporary vertices ids */ if(vbuf->nr_vertices) draw_reset_vertex_ids( vbuf->stage.draw ); /* Free the vertex buffer */ vbuf->render->release_vertices( vbuf->render ); vbuf->max_vertices = vbuf->nr_vertices = 0; vbuf->vertex_ptr = vbuf->vertices = NULL; } /* Reset point/line/tri function pointers. * If (for example) we transition from points to tris and back to points * again, we need to call the vbuf_first_point() function again to flush * the triangles before drawing more points. This can happen when drawing * with front polygon mode = filled and back polygon mode = line or point. */ vbuf->stage.point = vbuf_first_point; vbuf->stage.line = vbuf_first_line; vbuf->stage.tri = vbuf_first_tri; }