summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian <brian.paul@tungstengraphics.com>2007-08-20 12:52:33 -0600
committerBrian <brian.paul@tungstengraphics.com>2007-08-20 12:52:33 -0600
commita83b72a67263faf21bf16ff879c9718660684aed (patch)
treebe7bbf85246c10f1cfa3cdad5c0acddf2570c197
parent1dd55a77c87bd4e057d689163efd070a2dfe3454 (diff)
implement DrawElements, still some rough spots
-rw-r--r--src/mesa/state_tracker/st_draw.c37
1 files changed, 35 insertions, 2 deletions
diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c
index db24b24fa7..e82f7cff2b 100644
--- a/src/mesa/state_tracker/st_draw.c
+++ b/src/mesa/state_tracker/st_draw.c
@@ -249,8 +249,41 @@ draw_vbo(GLcontext *ctx,
}
/* do actual drawing */
- for (i = 0; i < nr_prims; i++) {
- pipe->draw_arrays(pipe, prims[i].mode, prims[i].start, prims[i].count);
+ if (ib) {
+ /* indexed primitive */
+ struct gl_buffer_object *bufobj = ib->obj;
+ struct pipe_buffer_handle *bh = NULL;
+ unsigned indexSize;
+
+ if (bufobj && bufobj->Name) {
+ /* elements/indexes are in a real VBO */
+ struct st_buffer_object *stobj = st_buffer_object(bufobj);
+ bh = stobj->buffer;
+ switch (ib->type) {
+ case GL_UNSIGNED_INT:
+ indexSize = 4;
+ break;
+ case GL_UNSIGNED_SHORT:
+ indexSize = 2;
+ break;
+ default:
+ assert(0);
+ }
+ }
+ else {
+ assert(0);
+ }
+
+ for (i = 0; i < nr_prims; i++) {
+ pipe->draw_elements(pipe, bh, indexSize,
+ prims[i].mode, prims[i].start, prims[i].count);
+ }
+ }
+ else {
+ /* non-indexed */
+ for (i = 0; i < nr_prims; i++) {
+ pipe->draw_arrays(pipe, prims[i].mode, prims[i].start, prims[i].count);
+ }
}
}