summaryrefslogtreecommitdiff
path: root/src/mesa/tnl/t_draw.c
diff options
context:
space:
mode:
authorKeith Whitwell <keith@tungstengraphics.com>2006-11-03 13:04:08 +0000
committerKeith Whitwell <keith@tungstengraphics.com>2006-11-03 13:04:08 +0000
commit188a4db49c4c22429bfa7ae87d4b1a0c35bf0285 (patch)
treeef0df62edecad944ecbf6691591244596d7ada0b /src/mesa/tnl/t_draw.c
parentc3da1501b81a31e92f485ee9fbd99e60cc3a4337 (diff)
Fix compiler warnings.
Add missing code for translating non-GLuint elements.
Diffstat (limited to 'src/mesa/tnl/t_draw.c')
-rw-r--r--src/mesa/tnl/t_draw.c44
1 files changed, 29 insertions, 15 deletions
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;
+ }
+ }
}
}