From 03e29a5f77c13b7b888bd8443cb2752850e47d6a Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 4 Dec 2003 03:16:27 +0000 Subject: Fix some problems with glDrawElements and vertex buffer objects. --- src/mesa/tnl/t_array_api.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'src/mesa/tnl/t_array_api.c') diff --git a/src/mesa/tnl/t_array_api.c b/src/mesa/tnl/t_array_api.c index 2b10a9d1c2..802133dc2d 100644 --- a/src/mesa/tnl/t_array_api.c +++ b/src/mesa/tnl/t_array_api.c @@ -309,7 +309,10 @@ _tnl_DrawRangeElements(GLenum mode, "DrawRangeElements with empty vertex elements buffer!"); return; } - indices = (GLvoid *) ctx->Array.ElementArrayBufferObj->Data; + /* actual address is the sum of pointers */ + indices = (const GLvoid *) + ADD_POINTERS(ctx->Array.ElementArrayBufferObj->Data, + (const GLubyte *) indices); } /* Check arguments, etc. @@ -376,20 +379,17 @@ _tnl_DrawElements(GLenum mode, GLsizei count, GLenum type, if (MESA_VERBOSE & VERBOSE_API) _mesa_debug(NULL, "_tnl_DrawElements %d\n", count); - if (ctx->Array.ElementArrayBufferObj->Name) { - /* use indices in the buffer object */ - if (!ctx->Array.ElementArrayBufferObj->Data) { - _mesa_warning(ctx, "DrawElements with empty vertex elements buffer!"); - return; - } - indices = (const GLvoid *) ctx->Array.ElementArrayBufferObj->Data; - } - - /* Check arguments, etc. - */ + /* Check arguments, etc. */ if (!_mesa_validate_DrawElements( ctx, mode, count, type, indices )) return; + if (ctx->Array.ElementArrayBufferObj->Name) { + /* actual address is the sum of pointers */ + indices = (const GLvoid *) + ADD_POINTERS(ctx->Array.ElementArrayBufferObj->Data, + (const GLubyte *) indices); + } + ui_indices = (GLuint *)_ac_import_elements( ctx, GL_UNSIGNED_INT, count, type, indices ); -- cgit v1.2.3