diff options
author | Brian Paul <[email protected]> | 2002-01-11 17:25:35 +0000 |
---|---|---|
committer | Brian Paul <[email protected]> | 2002-01-11 17:25:35 +0000 |
commit | 2edd1807f85a5118dcd0c20156a2d68f5c23d145 (patch) | |
tree | bfde7ca52a845023619bc09c84ae5c72f98ef3c0 /src/mesa/main/varray.c | |
parent | 9927f1978da8530416f699d084dda099720e43e6 (diff) |
Moved _mesa_VertexAttribPointerNV into varray.c.
Removed dead placeholder functions from vpstate.[ch].
Changed gl_client_array's Enabled field to GLuint so it can actually
hold the flags we're storing in it!
Always do the switch (type) code in the vertex array functions to that
<type> gets error checked!
Diffstat (limited to 'src/mesa/main/varray.c')
-rw-r--r-- | src/mesa/main/varray.c | 220 |
1 files changed, 142 insertions, 78 deletions
diff --git a/src/mesa/main/varray.c b/src/mesa/main/varray.c index 31b0b9b223d..20e5845a7b0 100644 --- a/src/mesa/main/varray.c +++ b/src/mesa/main/varray.c @@ -1,4 +1,4 @@ -/* $Id: varray.c,v 1.40 2002/01/05 20:51:12 brianp Exp $ */ +/* $Id: varray.c,v 1.41 2002/01/11 17:25:35 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -50,11 +50,11 @@ _mesa_VertexPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr) GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - if (size<2 || size>4) { + if (size < 2 || size > 4) { _mesa_error( ctx, GL_INVALID_VALUE, "glVertexPointer(size)" ); return; } - if (stride<0) { + if (stride < 0) { _mesa_error( ctx, GL_INVALID_VALUE, "glVertexPointer(stride)" ); return; } @@ -64,26 +64,28 @@ _mesa_VertexPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr) _mesa_lookup_enum_by_nr( type ), stride); - ctx->Array.Vertex.StrideB = stride; - if (!stride) { - switch (type) { + /* always need to check that <type> is legal */ + switch (type) { case GL_SHORT: - ctx->Array.Vertex.StrideB = size*sizeof(GLshort); + ctx->Array.Vertex.StrideB = size * sizeof(GLshort); break; case GL_INT: - ctx->Array.Vertex.StrideB = size*sizeof(GLint); + ctx->Array.Vertex.StrideB = size * sizeof(GLint); break; case GL_FLOAT: - ctx->Array.Vertex.StrideB = size*sizeof(GLfloat); + ctx->Array.Vertex.StrideB = size * sizeof(GLfloat); break; case GL_DOUBLE: - ctx->Array.Vertex.StrideB = size*sizeof(GLdouble); + ctx->Array.Vertex.StrideB = size * sizeof(GLdouble); break; default: _mesa_error( ctx, GL_INVALID_ENUM, "glVertexPointer(type)" ); return; - } } + + if (stride) + ctx->Array.Vertex.StrideB = stride; + ctx->Array.Vertex.Size = size; ctx->Array.Vertex.Type = type; ctx->Array.Vertex.Stride = stride; @@ -104,7 +106,7 @@ _mesa_NormalPointer(GLenum type, GLsizei stride, const GLvoid *ptr ) GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - if (stride<0) { + if (stride < 0) { _mesa_error( ctx, GL_INVALID_VALUE, "glNormalPointer(stride)" ); return; } @@ -114,29 +116,29 @@ _mesa_NormalPointer(GLenum type, GLsizei stride, const GLvoid *ptr ) _mesa_lookup_enum_by_nr( type ), stride); - ctx->Array.Normal.StrideB = stride; - if (!stride) { - switch (type) { + switch (type) { case GL_BYTE: - ctx->Array.Normal.StrideB = 3*sizeof(GLbyte); + ctx->Array.Normal.StrideB = 3 * sizeof(GLbyte); break; case GL_SHORT: - ctx->Array.Normal.StrideB = 3*sizeof(GLshort); + ctx->Array.Normal.StrideB = 3 * sizeof(GLshort); break; case GL_INT: - ctx->Array.Normal.StrideB = 3*sizeof(GLint); + ctx->Array.Normal.StrideB = 3 * sizeof(GLint); break; case GL_FLOAT: - ctx->Array.Normal.StrideB = 3*sizeof(GLfloat); + ctx->Array.Normal.StrideB = 3 * sizeof(GLfloat); break; case GL_DOUBLE: - ctx->Array.Normal.StrideB = 3*sizeof(GLdouble); + ctx->Array.Normal.StrideB = 3 * sizeof(GLdouble); break; default: _mesa_error( ctx, GL_INVALID_ENUM, "glNormalPointer(type)" ); return; - } } + if (stride) + ctx->Array.Normal.StrideB = stride; + ctx->Array.Normal.Size = 3; ctx->Array.Normal.Type = type; ctx->Array.Normal.Stride = stride; @@ -156,7 +158,7 @@ _mesa_ColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr) GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - if (size<3 || size>4) { + if (size < 3 || size > 4) { _mesa_error( ctx, GL_INVALID_VALUE, "glColorPointer(size)" ); return; } @@ -170,38 +172,39 @@ _mesa_ColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr) _mesa_lookup_enum_by_nr( type ), stride); - ctx->Array.Color.StrideB = stride; - if (!stride) { - switch (type) { + switch (type) { case GL_BYTE: - ctx->Array.Color.StrideB = size*sizeof(GLbyte); + ctx->Array.Color.StrideB = size * sizeof(GLbyte); break; case GL_UNSIGNED_BYTE: - ctx->Array.Color.StrideB = size*sizeof(GLubyte); + ctx->Array.Color.StrideB = size * sizeof(GLubyte); break; case GL_SHORT: - ctx->Array.Color.StrideB = size*sizeof(GLshort); + ctx->Array.Color.StrideB = size * sizeof(GLshort); break; case GL_UNSIGNED_SHORT: - ctx->Array.Color.StrideB = size*sizeof(GLushort); + ctx->Array.Color.StrideB = size * sizeof(GLushort); break; case GL_INT: - ctx->Array.Color.StrideB = size*sizeof(GLint); + ctx->Array.Color.StrideB = size * sizeof(GLint); break; case GL_UNSIGNED_INT: - ctx->Array.Color.StrideB = size*sizeof(GLuint); + ctx->Array.Color.StrideB = size * sizeof(GLuint); break; case GL_FLOAT: - ctx->Array.Color.StrideB = size*sizeof(GLfloat); + ctx->Array.Color.StrideB = size * sizeof(GLfloat); break; case GL_DOUBLE: - ctx->Array.Color.StrideB = size*sizeof(GLdouble); + ctx->Array.Color.StrideB = size * sizeof(GLdouble); break; default: _mesa_error( ctx, GL_INVALID_ENUM, "glColorPointer(type)" ); return; - } } + + if (stride) + ctx->Array.Color.StrideB = stride; + ctx->Array.Color.Size = size; ctx->Array.Color.Type = type; ctx->Array.Color.Stride = stride; @@ -221,14 +224,12 @@ _mesa_FogCoordPointerEXT(GLenum type, GLsizei stride, const GLvoid *ptr) GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - if (stride<0) { + if (stride < 0) { _mesa_error( ctx, GL_INVALID_VALUE, "glFogCoordPointer(stride)" ); return; } - ctx->Array.FogCoord.StrideB = stride; - if (!stride) { - switch (type) { + switch (type) { case GL_FLOAT: ctx->Array.FogCoord.StrideB = sizeof(GLfloat); break; @@ -238,8 +239,11 @@ _mesa_FogCoordPointerEXT(GLenum type, GLsizei stride, const GLvoid *ptr) default: _mesa_error( ctx, GL_INVALID_ENUM, "glFogCoordPointer(type)" ); return; - } } + + if (stride) + ctx->Array.FogCoord.StrideB = stride; + ctx->Array.FogCoord.Size = 1; ctx->Array.FogCoord.Type = type; ctx->Array.FogCoord.Stride = stride; @@ -258,14 +262,12 @@ _mesa_IndexPointer(GLenum type, GLsizei stride, const GLvoid *ptr) GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - if (stride<0) { + if (stride < 0) { _mesa_error( ctx, GL_INVALID_VALUE, "glIndexPointer(stride)" ); return; } - ctx->Array.Index.StrideB = stride; - if (!stride) { - switch (type) { + switch (type) { case GL_UNSIGNED_BYTE: ctx->Array.Index.StrideB = sizeof(GLubyte); break; @@ -284,8 +286,11 @@ _mesa_IndexPointer(GLenum type, GLsizei stride, const GLvoid *ptr) default: _mesa_error( ctx, GL_INVALID_ENUM, "glIndexPointer(type)" ); return; - } } + + if (stride) + ctx->Array.Index.StrideB = stride; + ctx->Array.Index.Size = 1; ctx->Array.Index.Type = type; ctx->Array.Index.Stride = stride; @@ -306,51 +311,53 @@ _mesa_SecondaryColorPointerEXT(GLint size, GLenum type, ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); if (size != 3 && size != 4) { - _mesa_error( ctx, GL_INVALID_VALUE, "glColorPointer(size)" ); + _mesa_error( ctx, GL_INVALID_VALUE, "glSecondaryColorPointer(size)" ); return; } - if (stride<0) { - _mesa_error( ctx, GL_INVALID_VALUE, "glColorPointer(stride)" ); + if (stride < 0) { + _mesa_error( ctx, GL_INVALID_VALUE, "glSecondaryColorPointer(stride)" ); return; } if (MESA_VERBOSE&(VERBOSE_VARRAY|VERBOSE_API)) - fprintf(stderr, "glColorPointer( sz %d type %s stride %d )\n", size, + fprintf(stderr, + "glSecondaryColorPointer( sz %d type %s stride %d )\n", size, _mesa_lookup_enum_by_nr( type ), stride); - ctx->Array.SecondaryColor.StrideB = stride; - if (!stride) { - switch (type) { + switch (type) { case GL_BYTE: - ctx->Array.SecondaryColor.StrideB = size*sizeof(GLbyte); + ctx->Array.SecondaryColor.StrideB = size * sizeof(GLbyte); break; case GL_UNSIGNED_BYTE: - ctx->Array.SecondaryColor.StrideB = size*sizeof(GLubyte); + ctx->Array.SecondaryColor.StrideB = size * sizeof(GLubyte); break; case GL_SHORT: - ctx->Array.SecondaryColor.StrideB = size*sizeof(GLshort); + ctx->Array.SecondaryColor.StrideB = size * sizeof(GLshort); break; case GL_UNSIGNED_SHORT: - ctx->Array.SecondaryColor.StrideB = size*sizeof(GLushort); + ctx->Array.SecondaryColor.StrideB = size * sizeof(GLushort); break; case GL_INT: - ctx->Array.SecondaryColor.StrideB = size*sizeof(GLint); + ctx->Array.SecondaryColor.StrideB = size * sizeof(GLint); break; case GL_UNSIGNED_INT: - ctx->Array.SecondaryColor.StrideB = size*sizeof(GLuint); + ctx->Array.SecondaryColor.StrideB = size * sizeof(GLuint); break; case GL_FLOAT: - ctx->Array.SecondaryColor.StrideB = size*sizeof(GLfloat); + ctx->Array.SecondaryColor.StrideB = size * sizeof(GLfloat); break; case GL_DOUBLE: - ctx->Array.SecondaryColor.StrideB = size*sizeof(GLdouble); + ctx->Array.SecondaryColor.StrideB = size * sizeof(GLdouble); break; default: _mesa_error( ctx, GL_INVALID_ENUM, "glSecondaryColorPointer(type)" ); return; - } } + + if (stride) + ctx->Array.SecondaryColor.StrideB = stride; + ctx->Array.SecondaryColor.Size = 3; /* hardwire */ ctx->Array.SecondaryColor.Type = type; ctx->Array.SecondaryColor.Stride = stride; @@ -365,17 +372,18 @@ _mesa_SecondaryColorPointerEXT(GLint size, GLenum type, void -_mesa_TexCoordPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr) +_mesa_TexCoordPointer(GLint size, GLenum type, GLsizei stride, + const GLvoid *ptr) { GET_CURRENT_CONTEXT(ctx); GLuint texUnit = ctx->Array.ActiveTexture; ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - if (size<1 || size>4) { + if (size < 1 || size > 4) { _mesa_error( ctx, GL_INVALID_VALUE, "glTexCoordPointer(size)" ); return; } - if (stride<0) { + if (stride < 0) { _mesa_error( ctx, GL_INVALID_VALUE, "glTexCoordPointer(stride)" ); return; } @@ -387,26 +395,28 @@ _mesa_TexCoordPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr _mesa_lookup_enum_by_nr( type ), stride); - ctx->Array.TexCoord[texUnit].StrideB = stride; - if (!stride) { - switch (type) { + /* always need to check that <type> is legal */ + switch (type) { case GL_SHORT: - ctx->Array.TexCoord[texUnit].StrideB = size*sizeof(GLshort); + ctx->Array.TexCoord[texUnit].StrideB = size * sizeof(GLshort); break; case GL_INT: - ctx->Array.TexCoord[texUnit].StrideB = size*sizeof(GLint); + ctx->Array.TexCoord[texUnit].StrideB = size * sizeof(GLint); break; case GL_FLOAT: - ctx->Array.TexCoord[texUnit].StrideB = size*sizeof(GLfloat); + ctx->Array.TexCoord[texUnit].StrideB = size * sizeof(GLfloat); break; case GL_DOUBLE: - ctx->Array.TexCoord[texUnit].StrideB = size*sizeof(GLdouble); + ctx->Array.TexCoord[texUnit].StrideB = size * sizeof(GLdouble); break; default: _mesa_error( ctx, GL_INVALID_ENUM, "glTexCoordPointer(type)" ); return; - } } + + if (stride) + ctx->Array.TexCoord[texUnit].StrideB = stride; + ctx->Array.TexCoord[texUnit].Size = size; ctx->Array.TexCoord[texUnit].Type = type; ctx->Array.TexCoord[texUnit].Stride = stride; @@ -414,17 +424,13 @@ _mesa_TexCoordPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr ctx->NewState |= _NEW_ARRAY; ctx->Array.NewState |= _NEW_ARRAY_VERTEX; -/* fprintf(stderr, "%s ptr %p\n", __FUNCTION__, ptr); */ - if (ctx->Driver.TexCoordPointer) ctx->Driver.TexCoordPointer( ctx, size, type, stride, ptr ); } - - void -_mesa_EdgeFlagPointer(GLsizei stride, const void *vptr) +_mesa_EdgeFlagPointer(GLsizei stride, const GLvoid *vptr) { GET_CURRENT_CONTEXT(ctx); const GLboolean *ptr = (GLboolean *)vptr; @@ -445,7 +451,67 @@ _mesa_EdgeFlagPointer(GLsizei stride, const void *vptr) } +void _mesa_VertexAttribPointerNV(GLuint index, GLint size, GLenum type, + GLsizei stride, const GLvoid *pointer) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + if (index >= VP_NUM_PROG_REGS) { + _mesa_error(ctx, GL_INVALID_VALUE, "glVertexAttribPointerNV(index)"); + return; + } + + if (size < 1 || size > 4) { + _mesa_error(ctx, GL_INVALID_VALUE, "glVertexAttribPointerNV(size)"); + return; + } + + if (stride < 0) { + _mesa_error(ctx, GL_INVALID_VALUE, "glVertexAttribPointerNV(stride)"); + return; + } + + if (type == GL_UNSIGNED_BYTE && size != 4) { + _mesa_error(ctx, GL_INVALID_VALUE, "glVertexAttribPointerNV(size!=4)"); + return; + } + + /* check for valid 'type' and compute StrideB right away */ + switch (type) { + case GL_UNSIGNED_BYTE: + ctx->Array.Normal.StrideB = size * sizeof(GLubyte); + break; + case GL_SHORT: + ctx->Array.Normal.StrideB = size * sizeof(GLshort); + break; + case GL_FLOAT: + ctx->Array.Normal.StrideB = size * sizeof(GLfloat); + break; + case GL_DOUBLE: + ctx->Array.Normal.StrideB = size * sizeof(GLdouble); + break; + default: + _mesa_error( ctx, GL_INVALID_ENUM, "glVertexAttribPointerNV(type)" ); + return; + } + + if (stride) + ctx->Array.VertexAttrib[index].StrideB = stride; + + ctx->Array.VertexAttrib[index].Stride = stride; + ctx->Array.VertexAttrib[index].Size = size; + ctx->Array.VertexAttrib[index].Type = type; + + /* XXX need new flags here??? */ + ctx->NewState |= _NEW_ARRAY; + ctx->Array.NewState |= _NEW_ARRAY_VERTEX; + + /* XXX + if (ctx->Driver.VertexAttribdPointer) + ctx->Driver.VertexAttribPointer( ctx, index, size, type, stride, ptr ); + */ +} void @@ -503,8 +569,6 @@ _mesa_EdgeFlagPointerEXT(GLsizei stride, GLsizei count, const GLboolean *ptr) - - void _mesa_InterleavedArrays(GLenum format, GLsizei stride, const GLvoid *pointer) { |