summaryrefslogtreecommitdiffstats
path: root/src/mesa
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2002-01-11 17:25:35 +0000
committerBrian Paul <[email protected]>2002-01-11 17:25:35 +0000
commit2edd1807f85a5118dcd0c20156a2d68f5c23d145 (patch)
treebfde7ca52a845023619bc09c84ae5c72f98ef3c0 /src/mesa
parent9927f1978da8530416f699d084dda099720e43e6 (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')
-rw-r--r--src/mesa/main/mtypes.h4
-rw-r--r--src/mesa/main/varray.c220
-rw-r--r--src/mesa/main/varray.h13
3 files changed, 153 insertions, 84 deletions
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index dcf9d4bcf2c..977b4bbf735 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -1,4 +1,4 @@
-/* $Id: mtypes.h,v 1.60 2002/01/06 20:39:19 brianp Exp $ */
+/* $Id: mtypes.h,v 1.61 2002/01/11 17:25:35 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -1034,7 +1034,7 @@ struct gl_client_array {
GLsizei StrideB; /* actual stride in bytes */
void *Ptr;
GLuint Flags;
- GLboolean Enabled;
+ GLuint Enabled; /* one of the _NEW_ARRAY_ bits */
};
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)
{
diff --git a/src/mesa/main/varray.h b/src/mesa/main/varray.h
index a99c0ab863e..b2f18667cd1 100644
--- a/src/mesa/main/varray.h
+++ b/src/mesa/main/varray.h
@@ -1,10 +1,10 @@
-/* $Id: varray.h,v 1.12 2001/03/12 00:48:39 gareth Exp $ */
+/* $Id: varray.h,v 1.13 2002/01/11 17:25:35 brianp Exp $ */
/*
* Mesa 3-D graphics library
- * Version: 3.5
+ * Version: 4.1
*
- * Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2002 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -96,14 +96,19 @@ _mesa_EdgeFlagPointerEXT(GLsizei stride, GLsizei count, const GLboolean *ptr);
extern void
_mesa_FogCoordPointerEXT(GLenum type, GLsizei stride, const GLvoid *ptr);
+
extern void
_mesa_SecondaryColorPointerEXT(GLint size, GLenum type,
GLsizei stride, const GLvoid *ptr);
extern void
-_mesa_InterleavedArrays(GLenum format, GLsizei stride, const GLvoid *pointer);
+_mesa_VertexAttribPointerNV(GLuint index, GLint size, GLenum type,
+ GLsizei stride, const GLvoid *pointer);
+
+extern void
+_mesa_InterleavedArrays(GLenum format, GLsizei stride, const GLvoid *pointer);
#endif