-/* $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
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;
}
_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;
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;
}
_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;
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;
}
_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;
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;
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;
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;
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;
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;
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;
}
_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;
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;
}
+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
-
-
void
_mesa_InterleavedArrays(GLenum format, GLsizei stride, const GLvoid *pointer)
{