From 188a4db49c4c22429bfa7ae87d4b1a0c35bf0285 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Fri, 3 Nov 2006 13:04:08 +0000 Subject: Fix compiler warnings. Add missing code for translating non-GLuint elements. --- src/mesa/tnl/t_draw.c | 44 +++++++++++++++++++++++++++++--------------- 1 file changed, 29 insertions(+), 15 deletions(-) (limited to 'src/mesa/tnl') diff --git a/src/mesa/tnl/t_draw.c b/src/mesa/tnl/t_draw.c index e0a16e284d..0f9615e7cc 100644 --- a/src/mesa/tnl/t_draw.c +++ b/src/mesa/tnl/t_draw.c @@ -41,13 +41,13 @@ -static GLfloat *get_space(GLcontext *ctx, GLuint bytes) +static GLubyte *get_space(GLcontext *ctx, GLuint bytes) { TNLcontext *tnl = TNL_CONTEXT(ctx); GLubyte *space = _mesa_malloc(bytes); tnl->block[tnl->nr_blocks++] = space; - return (GLfloat *)space; + return space; } @@ -97,7 +97,7 @@ static void _tnl_import_array( GLcontext *ctx, GLuint start, GLuint end, const struct gl_client_array *input, - const char *ptr ) + const GLubyte *ptr ) { TNLcontext *tnl = TNL_CONTEXT(ctx); struct vertex_buffer *VB = &tnl->vb; @@ -108,7 +108,7 @@ static void _tnl_import_array( GLcontext *ctx, if (input->Type != GL_FLOAT) { const GLuint sz = input->Size; - char *buf = get_space(ctx, count * sz * sizeof(GLfloat)); + GLubyte *buf = get_space(ctx, count * sz * sizeof(GLfloat)); GLfloat *fptr = (GLfloat *)buf; switch (input->Type) { @@ -263,6 +263,8 @@ static void bind_indicies( GLcontext *ctx, { TNLcontext *tnl = TNL_CONTEXT(ctx); struct vertex_buffer *VB = &tnl->vb; + GLuint i; + void *ptr; if (!ib) return; @@ -278,18 +280,30 @@ static void bind_indicies( GLcontext *ctx, assert(ib->obj->Pointer); } - VB->Elts = (GLuint *)ADD_POINTERS(ib->obj->Pointer, - ib->ptr); - - VB->Elts += ib->rebase; + ptr = ADD_POINTERS(ib->obj->Pointer, ib->ptr); - switch (ib->type) { - case GL_UNSIGNED_INT: - return; - case GL_UNSIGNED_SHORT: - break; - case GL_UNSIGNED_BYTE: - break; + if (ib->type == GL_UNSIGNED_INT) { + VB->Elts = (GLuint *) ptr; + VB->Elts += ib->rebase; + } + else { + GLuint *elts = (GLuint *)get_space(ctx, ib->count * sizeof(GLuint)); + VB->Elts = elts; + + switch (ib->type) { + case GL_UNSIGNED_SHORT: { + const GLushort *in = ((GLushort *)ptr) + ib->rebase; + for (i = 0; i < ib->count; i++) + *elts++ = *in++; + break; + } + case GL_UNSIGNED_BYTE: { + const GLubyte *in = ((GLubyte *)ptr) + ib->rebase; + for (i = 0; i < ib->count; i++) + *elts++ = *in++; + break; + } + } } } -- cgit v1.2.3