diff options
author | Brian <[email protected]> | 2007-10-24 14:40:09 -0600 |
---|---|---|
committer | Brian <[email protected]> | 2007-10-24 14:40:09 -0600 |
commit | 7636aac54bb357ce907ae6cc2c41f32957faecf3 (patch) | |
tree | a4aebd346f243a63bc1ed86c7dc3150820a74107 /src/mesa/state_tracker/st_draw.c | |
parent | 40a0b053f78acd0a08f6876518b8e9301480431f (diff) |
Fix glDrawElements + VBO rendering when ptr/offset is not zero.
When an index VBO is bound, glDrawElement's indices pointer is really an
offset into the element buffer. Add that offset to the prims[i].start
value before calling pipe->draw_elements().
Fixes vbo.c conform test.
Diffstat (limited to 'src/mesa/state_tracker/st_draw.c')
-rw-r--r-- | src/mesa/state_tracker/st_draw.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index fbf7713f58d..d7d9a1d203b 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -197,7 +197,7 @@ st_draw_vbo(GLcontext *ctx, /* indexed primitive */ struct gl_buffer_object *bufobj = ib->obj; struct pipe_buffer_handle *indexBuf = NULL; - unsigned indexSize, i; + unsigned indexSize, indexOffset, i; switch (ib->type) { case GL_UNSIGNED_INT: @@ -218,18 +218,21 @@ st_draw_vbo(GLcontext *ctx, /* elements/indexes are in a real VBO */ struct st_buffer_object *stobj = st_buffer_object(bufobj); winsys->buffer_reference(winsys, &indexBuf, stobj->buffer); + indexOffset = (unsigned) ib->ptr / indexSize; } else { /* element/indicies are in user space memory */ indexBuf = winsys->user_buffer_create(winsys, (void *) ib->ptr, ib->count * indexSize); + indexOffset = 0; } /* draw */ for (i = 0; i < nr_prims; i++) { pipe->draw_elements(pipe, indexBuf, indexSize, - prims[i].mode, prims[i].start, prims[i].count); + prims[i].mode, + prims[i].start + indexOffset, prims[i].count); } winsys->buffer_reference(winsys, &indexBuf, NULL); |