blob: f41ee73c884e3ea666992ea604894010e1d60828 [file] [log] [blame]
jtgafb833d1999-08-19 00:55:39 +00001/*
2 * Mesa 3-D graphics library
Brian Paul095c6692006-04-25 00:21:32 +00003 * Version: 6.5.1
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +00004 *
Michal Krolbb38cad2006-04-11 11:41:11 +00005 * Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +00006 *
jtgafb833d1999-08-19 00:55:39 +00007 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +000013 *
jtgafb833d1999-08-19 00:55:39 +000014 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +000016 *
jtgafb833d1999-08-19 00:55:39 +000017 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
21 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 */
24
Keith Whitwell6dc85572003-07-17 13:43:59 +000025
Brian Paulfbd8f211999-11-11 01:22:25 +000026#include "glheader.h"
Brian Paul148a2842003-09-17 03:40:11 +000027#include "imports.h"
Brian Paul26895aa2004-03-03 15:35:08 +000028#include "bufferobj.h"
jtgafb833d1999-08-19 00:55:39 +000029#include "context.h"
jtgafb833d1999-08-19 00:55:39 +000030#include "enable.h"
31#include "enums.h"
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +000032#include "mtypes.h"
jtgafb833d1999-08-19 00:55:39 +000033#include "varray.h"
Ian Romanickee34e6e2006-06-12 16:26:29 +000034#include "arrayobj.h"
Brianc223c6b2007-07-04 13:15:20 -060035#include "glapi/dispatch.h"
jtgafb833d1999-08-19 00:55:39 +000036
Brian Paulc5b1e812003-10-22 22:59:07 +000037
38/**
Brian Paulf9d88c82006-06-13 17:24:36 +000039 * Update the fields of a vertex array object.
Brian Paulc5b1e812003-10-22 22:59:07 +000040 * We need to do a few special things for arrays that live in
41 * vertex buffer objects.
Brian Paulf9d88c82006-06-13 17:24:36 +000042 *
43 * \param array the array to update
44 * \param dirtyBit which bit to set in ctx->Array.NewState for this array
45 * \param elementSize size of each array element, in bytes
46 * \param size components per element (1, 2, 3 or 4)
47 * \param type datatype of each component (GL_FLOAT, GL_INT, etc)
48 * \param stride stride between elements, in elements
49 * \param normalized are integer types converted to floats in [-1, 1]?
50 * \param ptr the address (or offset inside VBO) of the array data
Brian Paulc5b1e812003-10-22 22:59:07 +000051 */
52static void
53update_array(GLcontext *ctx, struct gl_client_array *array,
Brian Paulf9d88c82006-06-13 17:24:36 +000054 GLbitfield dirtyBit, GLsizei elementSize,
Brian Paulc5b1e812003-10-22 22:59:07 +000055 GLint size, GLenum type,
56 GLsizei stride, GLboolean normalized, const GLvoid *ptr)
57{
58 array->Size = size;
59 array->Type = type;
60 array->Stride = stride;
61 array->StrideB = stride ? stride : elementSize;
62 array->Normalized = normalized;
63 array->Ptr = (const GLubyte *) ptr;
64#if FEATURE_ARB_vertex_buffer_object
65 array->BufferObj->RefCount--;
Brian Paul20202782004-02-11 22:06:05 +000066 if (array->BufferObj->RefCount <= 0) {
Brian Paul293ad982004-09-27 16:19:17 +000067 ASSERT(array->BufferObj->Name);
Brian Paul26895aa2004-03-03 15:35:08 +000068 _mesa_remove_buffer_object( ctx, array->BufferObj );
Brian Paul20202782004-02-11 22:06:05 +000069 (*ctx->Driver.DeleteBuffer)( ctx, array->BufferObj );
70 }
Brian Paulc5b1e812003-10-22 22:59:07 +000071 array->BufferObj = ctx->Array.ArrayBufferObj;
72 array->BufferObj->RefCount++;
73 /* Compute the index of the last array element that's inside the buffer.
74 * Later in glDrawArrays we'll check if start + count > _MaxElement to
75 * be sure we won't go out of bounds.
76 */
77 if (ctx->Array.ArrayBufferObj->Name)
78 array->_MaxElement = ((GLsizeiptrARB) ctx->Array.ArrayBufferObj->Size
Roland Scheideggercda32362007-03-27 21:03:32 +020079 - (GLsizeiptrARB) array->Ptr + array->StrideB
80 - elementSize) / array->StrideB;
Brian Paulc5b1e812003-10-22 22:59:07 +000081 else
82#endif
83 array->_MaxElement = 2 * 1000 * 1000 * 1000; /* just a big number */
84
85 ctx->NewState |= _NEW_ARRAY;
Brian Paulf9d88c82006-06-13 17:24:36 +000086 ctx->Array.NewState |= dirtyBit;
Brian Paulc5b1e812003-10-22 22:59:07 +000087}
88
89
Kendall Bennettc40d1dd2003-10-21 22:22:17 +000090void GLAPIENTRY
Brian Paulfbd8f211999-11-11 01:22:25 +000091_mesa_VertexPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr)
jtgafb833d1999-08-19 00:55:39 +000092{
Brian Paulc5b1e812003-10-22 22:59:07 +000093 GLsizei elementSize;
Brian Paulfbd8f211999-11-11 01:22:25 +000094 GET_CURRENT_CONTEXT(ctx);
Keith Whitwellcab974c2000-12-26 05:09:27 +000095 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +000096
Brian Paul2edd1802002-01-11 17:25:35 +000097 if (size < 2 || size > 4) {
Brian Paul08836342001-03-03 20:33:27 +000098 _mesa_error( ctx, GL_INVALID_VALUE, "glVertexPointer(size)" );
jtgafb833d1999-08-19 00:55:39 +000099 return;
100 }
Brian Paul2edd1802002-01-11 17:25:35 +0000101 if (stride < 0) {
Brian Paul08836342001-03-03 20:33:27 +0000102 _mesa_error( ctx, GL_INVALID_VALUE, "glVertexPointer(stride)" );
jtgafb833d1999-08-19 00:55:39 +0000103 return;
104 }
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +0000105
jtgafb833d1999-08-19 00:55:39 +0000106 if (MESA_VERBOSE&(VERBOSE_VARRAY|VERBOSE_API))
Brian Paul4753d602002-06-15 02:38:15 +0000107 _mesa_debug(ctx, "glVertexPointer( sz %d type %s stride %d )\n", size,
108 _mesa_lookup_enum_by_nr( type ), stride);
jtgafb833d1999-08-19 00:55:39 +0000109
Brian Paul2edd1802002-01-11 17:25:35 +0000110 /* always need to check that <type> is legal */
111 switch (type) {
jtgafb833d1999-08-19 00:55:39 +0000112 case GL_SHORT:
Brian Paulc5b1e812003-10-22 22:59:07 +0000113 elementSize = size * sizeof(GLshort);
jtgafb833d1999-08-19 00:55:39 +0000114 break;
115 case GL_INT:
Brian Paulc5b1e812003-10-22 22:59:07 +0000116 elementSize = size * sizeof(GLint);
jtgafb833d1999-08-19 00:55:39 +0000117 break;
118 case GL_FLOAT:
Brian Paulc5b1e812003-10-22 22:59:07 +0000119 elementSize = size * sizeof(GLfloat);
jtgafb833d1999-08-19 00:55:39 +0000120 break;
121 case GL_DOUBLE:
Brian Paulc5b1e812003-10-22 22:59:07 +0000122 elementSize = size * sizeof(GLdouble);
jtgafb833d1999-08-19 00:55:39 +0000123 break;
124 default:
Brian Paul08836342001-03-03 20:33:27 +0000125 _mesa_error( ctx, GL_INVALID_ENUM, "glVertexPointer(type)" );
jtgafb833d1999-08-19 00:55:39 +0000126 return;
jtgafb833d1999-08-19 00:55:39 +0000127 }
Brian Paul2edd1802002-01-11 17:25:35 +0000128
Ian Romanickee34e6e2006-06-12 16:26:29 +0000129 update_array(ctx, &ctx->Array.ArrayObj->Vertex, _NEW_ARRAY_VERTEX,
Brian Paulc5b1e812003-10-22 22:59:07 +0000130 elementSize, size, type, stride, GL_FALSE, ptr);
Keith Whitwell23caf202000-11-16 21:05:34 +0000131
132 if (ctx->Driver.VertexPointer)
133 ctx->Driver.VertexPointer( ctx, size, type, stride, ptr );
jtgafb833d1999-08-19 00:55:39 +0000134}
135
136
Kendall Bennettc40d1dd2003-10-21 22:22:17 +0000137void GLAPIENTRY
Brian Paulfbd8f211999-11-11 01:22:25 +0000138_mesa_NormalPointer(GLenum type, GLsizei stride, const GLvoid *ptr )
jtgafb833d1999-08-19 00:55:39 +0000139{
Brian Paulc5b1e812003-10-22 22:59:07 +0000140 GLsizei elementSize;
Brian Paulfbd8f211999-11-11 01:22:25 +0000141 GET_CURRENT_CONTEXT(ctx);
Keith Whitwellcab974c2000-12-26 05:09:27 +0000142 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +0000143
Brian Paul2edd1802002-01-11 17:25:35 +0000144 if (stride < 0) {
Brian Paul08836342001-03-03 20:33:27 +0000145 _mesa_error( ctx, GL_INVALID_VALUE, "glNormalPointer(stride)" );
jtgafb833d1999-08-19 00:55:39 +0000146 return;
147 }
148
149 if (MESA_VERBOSE&(VERBOSE_VARRAY|VERBOSE_API))
Brian Paul4753d602002-06-15 02:38:15 +0000150 _mesa_debug(ctx, "glNormalPointer( type %s stride %d )\n",
151 _mesa_lookup_enum_by_nr( type ), stride);
jtgafb833d1999-08-19 00:55:39 +0000152
Brian Paul2edd1802002-01-11 17:25:35 +0000153 switch (type) {
jtgafb833d1999-08-19 00:55:39 +0000154 case GL_BYTE:
Brian Paulc5b1e812003-10-22 22:59:07 +0000155 elementSize = 3 * sizeof(GLbyte);
jtgafb833d1999-08-19 00:55:39 +0000156 break;
157 case GL_SHORT:
Brian Paulc5b1e812003-10-22 22:59:07 +0000158 elementSize = 3 * sizeof(GLshort);
jtgafb833d1999-08-19 00:55:39 +0000159 break;
160 case GL_INT:
Brian Paulc5b1e812003-10-22 22:59:07 +0000161 elementSize = 3 * sizeof(GLint);
jtgafb833d1999-08-19 00:55:39 +0000162 break;
163 case GL_FLOAT:
Brian Paulc5b1e812003-10-22 22:59:07 +0000164 elementSize = 3 * sizeof(GLfloat);
jtgafb833d1999-08-19 00:55:39 +0000165 break;
166 case GL_DOUBLE:
Brian Paulc5b1e812003-10-22 22:59:07 +0000167 elementSize = 3 * sizeof(GLdouble);
jtgafb833d1999-08-19 00:55:39 +0000168 break;
169 default:
Brian Paul08836342001-03-03 20:33:27 +0000170 _mesa_error( ctx, GL_INVALID_ENUM, "glNormalPointer(type)" );
jtgafb833d1999-08-19 00:55:39 +0000171 return;
jtgafb833d1999-08-19 00:55:39 +0000172 }
Brian Paul2edd1802002-01-11 17:25:35 +0000173
Ian Romanickee34e6e2006-06-12 16:26:29 +0000174 update_array(ctx, &ctx->Array.ArrayObj->Normal, _NEW_ARRAY_NORMAL,
Brian Paulad386812006-04-13 15:57:29 +0000175 elementSize, 3, type, stride, GL_TRUE, ptr);
Keith Whitwell23caf202000-11-16 21:05:34 +0000176
177 if (ctx->Driver.NormalPointer)
178 ctx->Driver.NormalPointer( ctx, type, stride, ptr );
jtgafb833d1999-08-19 00:55:39 +0000179}
180
181
Kendall Bennettc40d1dd2003-10-21 22:22:17 +0000182void GLAPIENTRY
Brian Paulfbd8f211999-11-11 01:22:25 +0000183_mesa_ColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr)
jtgafb833d1999-08-19 00:55:39 +0000184{
Brian Paulc5b1e812003-10-22 22:59:07 +0000185 GLsizei elementSize;
Brian Paulfbd8f211999-11-11 01:22:25 +0000186 GET_CURRENT_CONTEXT(ctx);
Keith Whitwellcab974c2000-12-26 05:09:27 +0000187 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
Brian Paulfbd8f211999-11-11 01:22:25 +0000188
Brian Paul2edd1802002-01-11 17:25:35 +0000189 if (size < 3 || size > 4) {
Brian Paul08836342001-03-03 20:33:27 +0000190 _mesa_error( ctx, GL_INVALID_VALUE, "glColorPointer(size)" );
jtgafb833d1999-08-19 00:55:39 +0000191 return;
192 }
Brian Paulc5b1e812003-10-22 22:59:07 +0000193 if (stride < 0) {
Brian Paul08836342001-03-03 20:33:27 +0000194 _mesa_error( ctx, GL_INVALID_VALUE, "glColorPointer(stride)" );
jtgafb833d1999-08-19 00:55:39 +0000195 return;
196 }
197
198 if (MESA_VERBOSE&(VERBOSE_VARRAY|VERBOSE_API))
Brian Paul4753d602002-06-15 02:38:15 +0000199 _mesa_debug(ctx, "glColorPointer( sz %d type %s stride %d )\n", size,
200 _mesa_lookup_enum_by_nr( type ), stride);
jtgafb833d1999-08-19 00:55:39 +0000201
Brian Paul2edd1802002-01-11 17:25:35 +0000202 switch (type) {
jtgafb833d1999-08-19 00:55:39 +0000203 case GL_BYTE:
Brian Paulc5b1e812003-10-22 22:59:07 +0000204 elementSize = size * sizeof(GLbyte);
jtgafb833d1999-08-19 00:55:39 +0000205 break;
206 case GL_UNSIGNED_BYTE:
Brian Paulc5b1e812003-10-22 22:59:07 +0000207 elementSize = size * sizeof(GLubyte);
jtgafb833d1999-08-19 00:55:39 +0000208 break;
209 case GL_SHORT:
Brian Paulc5b1e812003-10-22 22:59:07 +0000210 elementSize = size * sizeof(GLshort);
jtgafb833d1999-08-19 00:55:39 +0000211 break;
212 case GL_UNSIGNED_SHORT:
Brian Paulc5b1e812003-10-22 22:59:07 +0000213 elementSize = size * sizeof(GLushort);
jtgafb833d1999-08-19 00:55:39 +0000214 break;
215 case GL_INT:
Brian Paulc5b1e812003-10-22 22:59:07 +0000216 elementSize = size * sizeof(GLint);
jtgafb833d1999-08-19 00:55:39 +0000217 break;
218 case GL_UNSIGNED_INT:
Brian Paulc5b1e812003-10-22 22:59:07 +0000219 elementSize = size * sizeof(GLuint);
jtgafb833d1999-08-19 00:55:39 +0000220 break;
221 case GL_FLOAT:
Brian Paulc5b1e812003-10-22 22:59:07 +0000222 elementSize = size * sizeof(GLfloat);
jtgafb833d1999-08-19 00:55:39 +0000223 break;
224 case GL_DOUBLE:
Brian Paulc5b1e812003-10-22 22:59:07 +0000225 elementSize = size * sizeof(GLdouble);
jtgafb833d1999-08-19 00:55:39 +0000226 break;
227 default:
Brian Paul08836342001-03-03 20:33:27 +0000228 _mesa_error( ctx, GL_INVALID_ENUM, "glColorPointer(type)" );
jtgafb833d1999-08-19 00:55:39 +0000229 return;
jtgafb833d1999-08-19 00:55:39 +0000230 }
Brian Paul2edd1802002-01-11 17:25:35 +0000231
Ian Romanickee34e6e2006-06-12 16:26:29 +0000232 update_array(ctx, &ctx->Array.ArrayObj->Color, _NEW_ARRAY_COLOR0,
Brian Paulad386812006-04-13 15:57:29 +0000233 elementSize, size, type, stride, GL_TRUE, ptr);
Keith Whitwell23caf202000-11-16 21:05:34 +0000234
235 if (ctx->Driver.ColorPointer)
236 ctx->Driver.ColorPointer( ctx, size, type, stride, ptr );
jtgafb833d1999-08-19 00:55:39 +0000237}
238
239
Kendall Bennettc40d1dd2003-10-21 22:22:17 +0000240void GLAPIENTRY
Keith Whitwellfe5d67d2000-10-27 16:44:40 +0000241_mesa_FogCoordPointerEXT(GLenum type, GLsizei stride, const GLvoid *ptr)
242{
Brian Paulc5b1e812003-10-22 22:59:07 +0000243 GLint elementSize;
Keith Whitwellfe5d67d2000-10-27 16:44:40 +0000244 GET_CURRENT_CONTEXT(ctx);
Keith Whitwellcab974c2000-12-26 05:09:27 +0000245 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +0000246
Brian Paul2edd1802002-01-11 17:25:35 +0000247 if (stride < 0) {
Brian Paul08836342001-03-03 20:33:27 +0000248 _mesa_error( ctx, GL_INVALID_VALUE, "glFogCoordPointer(stride)" );
Keith Whitwellfe5d67d2000-10-27 16:44:40 +0000249 return;
250 }
251
Brian Paul2edd1802002-01-11 17:25:35 +0000252 switch (type) {
Keith Whitwellfe5d67d2000-10-27 16:44:40 +0000253 case GL_FLOAT:
Brian Paulc5b1e812003-10-22 22:59:07 +0000254 elementSize = sizeof(GLfloat);
Keith Whitwellfe5d67d2000-10-27 16:44:40 +0000255 break;
256 case GL_DOUBLE:
Brian Paulc5b1e812003-10-22 22:59:07 +0000257 elementSize = sizeof(GLdouble);
Keith Whitwellfe5d67d2000-10-27 16:44:40 +0000258 break;
259 default:
Brian Paul08836342001-03-03 20:33:27 +0000260 _mesa_error( ctx, GL_INVALID_ENUM, "glFogCoordPointer(type)" );
Keith Whitwellfe5d67d2000-10-27 16:44:40 +0000261 return;
Keith Whitwellfe5d67d2000-10-27 16:44:40 +0000262 }
Brian Paul2edd1802002-01-11 17:25:35 +0000263
Ian Romanickee34e6e2006-06-12 16:26:29 +0000264 update_array(ctx, &ctx->Array.ArrayObj->FogCoord, _NEW_ARRAY_FOGCOORD,
Brian Paulc5b1e812003-10-22 22:59:07 +0000265 elementSize, 1, type, stride, GL_FALSE, ptr);
Keith Whitwell23caf202000-11-16 21:05:34 +0000266
267 if (ctx->Driver.FogCoordPointer)
268 ctx->Driver.FogCoordPointer( ctx, type, stride, ptr );
Keith Whitwellfe5d67d2000-10-27 16:44:40 +0000269}
270
271
Kendall Bennettc40d1dd2003-10-21 22:22:17 +0000272void GLAPIENTRY
Brian Paulfbd8f211999-11-11 01:22:25 +0000273_mesa_IndexPointer(GLenum type, GLsizei stride, const GLvoid *ptr)
jtgafb833d1999-08-19 00:55:39 +0000274{
Brian Paulc5b1e812003-10-22 22:59:07 +0000275 GLsizei elementSize;
Brian Paulfbd8f211999-11-11 01:22:25 +0000276 GET_CURRENT_CONTEXT(ctx);
Keith Whitwellcab974c2000-12-26 05:09:27 +0000277 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +0000278
Brian Paul2edd1802002-01-11 17:25:35 +0000279 if (stride < 0) {
Brian Paul08836342001-03-03 20:33:27 +0000280 _mesa_error( ctx, GL_INVALID_VALUE, "glIndexPointer(stride)" );
jtgafb833d1999-08-19 00:55:39 +0000281 return;
282 }
283
Brian Paul2edd1802002-01-11 17:25:35 +0000284 switch (type) {
jtgafb833d1999-08-19 00:55:39 +0000285 case GL_UNSIGNED_BYTE:
Brian Paulc5b1e812003-10-22 22:59:07 +0000286 elementSize = sizeof(GLubyte);
jtgafb833d1999-08-19 00:55:39 +0000287 break;
288 case GL_SHORT:
Brian Paulc5b1e812003-10-22 22:59:07 +0000289 elementSize = sizeof(GLshort);
jtgafb833d1999-08-19 00:55:39 +0000290 break;
291 case GL_INT:
Brian Paulc5b1e812003-10-22 22:59:07 +0000292 elementSize = sizeof(GLint);
jtgafb833d1999-08-19 00:55:39 +0000293 break;
294 case GL_FLOAT:
Brian Paulc5b1e812003-10-22 22:59:07 +0000295 elementSize = sizeof(GLfloat);
jtgafb833d1999-08-19 00:55:39 +0000296 break;
297 case GL_DOUBLE:
Brian Paulc5b1e812003-10-22 22:59:07 +0000298 elementSize = sizeof(GLdouble);
jtgafb833d1999-08-19 00:55:39 +0000299 break;
300 default:
Brian Paul08836342001-03-03 20:33:27 +0000301 _mesa_error( ctx, GL_INVALID_ENUM, "glIndexPointer(type)" );
jtgafb833d1999-08-19 00:55:39 +0000302 return;
jtgafb833d1999-08-19 00:55:39 +0000303 }
Brian Paul2edd1802002-01-11 17:25:35 +0000304
Ian Romanickee34e6e2006-06-12 16:26:29 +0000305 update_array(ctx, &ctx->Array.ArrayObj->Index, _NEW_ARRAY_INDEX,
Brian Paulc5b1e812003-10-22 22:59:07 +0000306 elementSize, 1, type, stride, GL_FALSE, ptr);
Keith Whitwell23caf202000-11-16 21:05:34 +0000307
308 if (ctx->Driver.IndexPointer)
309 ctx->Driver.IndexPointer( ctx, type, stride, ptr );
jtgafb833d1999-08-19 00:55:39 +0000310}
311
312
Kendall Bennettc40d1dd2003-10-21 22:22:17 +0000313void GLAPIENTRY
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +0000314_mesa_SecondaryColorPointerEXT(GLint size, GLenum type,
Keith Whitwellfe5d67d2000-10-27 16:44:40 +0000315 GLsizei stride, const GLvoid *ptr)
316{
Brian Paulc5b1e812003-10-22 22:59:07 +0000317 GLsizei elementSize;
Keith Whitwellfe5d67d2000-10-27 16:44:40 +0000318 GET_CURRENT_CONTEXT(ctx);
Keith Whitwellcab974c2000-12-26 05:09:27 +0000319 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
Keith Whitwellfe5d67d2000-10-27 16:44:40 +0000320
Keith Whitwellfe5d67d2000-10-27 16:44:40 +0000321 if (size != 3 && size != 4) {
Brian Paul2edd1802002-01-11 17:25:35 +0000322 _mesa_error( ctx, GL_INVALID_VALUE, "glSecondaryColorPointer(size)" );
Keith Whitwellfe5d67d2000-10-27 16:44:40 +0000323 return;
324 }
Brian Paul2edd1802002-01-11 17:25:35 +0000325 if (stride < 0) {
326 _mesa_error( ctx, GL_INVALID_VALUE, "glSecondaryColorPointer(stride)" );
Keith Whitwellfe5d67d2000-10-27 16:44:40 +0000327 return;
328 }
329
330 if (MESA_VERBOSE&(VERBOSE_VARRAY|VERBOSE_API))
Brian Paul4753d602002-06-15 02:38:15 +0000331 _mesa_debug(ctx, "glSecondaryColorPointer( sz %d type %s stride %d )\n",
Brian Pauld09a1d82002-06-13 04:49:17 +0000332 size, _mesa_lookup_enum_by_nr( type ), stride);
Keith Whitwellfe5d67d2000-10-27 16:44:40 +0000333
Brian Paul2edd1802002-01-11 17:25:35 +0000334 switch (type) {
Keith Whitwellfe5d67d2000-10-27 16:44:40 +0000335 case GL_BYTE:
Brian Paulc5b1e812003-10-22 22:59:07 +0000336 elementSize = size * sizeof(GLbyte);
Keith Whitwellfe5d67d2000-10-27 16:44:40 +0000337 break;
338 case GL_UNSIGNED_BYTE:
Brian Paulc5b1e812003-10-22 22:59:07 +0000339 elementSize = size * sizeof(GLubyte);
Keith Whitwellfe5d67d2000-10-27 16:44:40 +0000340 break;
341 case GL_SHORT:
Brian Paulc5b1e812003-10-22 22:59:07 +0000342 elementSize = size * sizeof(GLshort);
Keith Whitwellfe5d67d2000-10-27 16:44:40 +0000343 break;
344 case GL_UNSIGNED_SHORT:
Brian Paulc5b1e812003-10-22 22:59:07 +0000345 elementSize = size * sizeof(GLushort);
Keith Whitwellfe5d67d2000-10-27 16:44:40 +0000346 break;
347 case GL_INT:
Brian Paulc5b1e812003-10-22 22:59:07 +0000348 elementSize = size * sizeof(GLint);
Keith Whitwellfe5d67d2000-10-27 16:44:40 +0000349 break;
350 case GL_UNSIGNED_INT:
Brian Paulc5b1e812003-10-22 22:59:07 +0000351 elementSize = size * sizeof(GLuint);
Keith Whitwellfe5d67d2000-10-27 16:44:40 +0000352 break;
353 case GL_FLOAT:
Brian Paulc5b1e812003-10-22 22:59:07 +0000354 elementSize = size * sizeof(GLfloat);
Keith Whitwellfe5d67d2000-10-27 16:44:40 +0000355 break;
356 case GL_DOUBLE:
Brian Paulc5b1e812003-10-22 22:59:07 +0000357 elementSize = size * sizeof(GLdouble);
Keith Whitwellfe5d67d2000-10-27 16:44:40 +0000358 break;
359 default:
Brian Paul08836342001-03-03 20:33:27 +0000360 _mesa_error( ctx, GL_INVALID_ENUM, "glSecondaryColorPointer(type)" );
Keith Whitwellfe5d67d2000-10-27 16:44:40 +0000361 return;
Keith Whitwellfe5d67d2000-10-27 16:44:40 +0000362 }
Brian Paul2edd1802002-01-11 17:25:35 +0000363
Ian Romanickee34e6e2006-06-12 16:26:29 +0000364 update_array(ctx, &ctx->Array.ArrayObj->SecondaryColor, _NEW_ARRAY_COLOR1,
Brian Paulad386812006-04-13 15:57:29 +0000365 elementSize, size, type, stride, GL_TRUE, ptr);
Keith Whitwell23caf202000-11-16 21:05:34 +0000366
367 if (ctx->Driver.SecondaryColorPointer)
368 ctx->Driver.SecondaryColorPointer( ctx, size, type, stride, ptr );
Keith Whitwellfe5d67d2000-10-27 16:44:40 +0000369}
370
371
Kendall Bennettc40d1dd2003-10-21 22:22:17 +0000372void GLAPIENTRY
Brian Paul2edd1802002-01-11 17:25:35 +0000373_mesa_TexCoordPointer(GLint size, GLenum type, GLsizei stride,
374 const GLvoid *ptr)
jtgafb833d1999-08-19 00:55:39 +0000375{
Brian Paulc5b1e812003-10-22 22:59:07 +0000376 GLint elementSize;
Brian Paulfbd8f211999-11-11 01:22:25 +0000377 GET_CURRENT_CONTEXT(ctx);
Brian Paulc5b1e812003-10-22 22:59:07 +0000378 const GLuint unit = ctx->Array.ActiveTexture;
Keith Whitwellcab974c2000-12-26 05:09:27 +0000379 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
jtgafb833d1999-08-19 00:55:39 +0000380
Brian Paul2edd1802002-01-11 17:25:35 +0000381 if (size < 1 || size > 4) {
Brian Paul08836342001-03-03 20:33:27 +0000382 _mesa_error( ctx, GL_INVALID_VALUE, "glTexCoordPointer(size)" );
jtgafb833d1999-08-19 00:55:39 +0000383 return;
384 }
Brian Paul2edd1802002-01-11 17:25:35 +0000385 if (stride < 0) {
Brian Paul08836342001-03-03 20:33:27 +0000386 _mesa_error( ctx, GL_INVALID_VALUE, "glTexCoordPointer(stride)" );
jtgafb833d1999-08-19 00:55:39 +0000387 return;
388 }
389
390 if (MESA_VERBOSE&(VERBOSE_VARRAY|VERBOSE_API))
Brian Paul4753d602002-06-15 02:38:15 +0000391 _mesa_debug(ctx, "glTexCoordPointer(unit %u sz %d type %s stride %d)\n",
Brian Paulc5b1e812003-10-22 22:59:07 +0000392 unit, size, _mesa_lookup_enum_by_nr( type ), stride);
jtgafb833d1999-08-19 00:55:39 +0000393
Brian Paul2edd1802002-01-11 17:25:35 +0000394 /* always need to check that <type> is legal */
395 switch (type) {
jtgafb833d1999-08-19 00:55:39 +0000396 case GL_SHORT:
Brian Paulc5b1e812003-10-22 22:59:07 +0000397 elementSize = size * sizeof(GLshort);
jtgafb833d1999-08-19 00:55:39 +0000398 break;
399 case GL_INT:
Brian Paulc5b1e812003-10-22 22:59:07 +0000400 elementSize = size * sizeof(GLint);
jtgafb833d1999-08-19 00:55:39 +0000401 break;
402 case GL_FLOAT:
Brian Paulc5b1e812003-10-22 22:59:07 +0000403 elementSize = size * sizeof(GLfloat);
jtgafb833d1999-08-19 00:55:39 +0000404 break;
405 case GL_DOUBLE:
Brian Paulc5b1e812003-10-22 22:59:07 +0000406 elementSize = size * sizeof(GLdouble);
jtgafb833d1999-08-19 00:55:39 +0000407 break;
408 default:
Brian Paul08836342001-03-03 20:33:27 +0000409 _mesa_error( ctx, GL_INVALID_ENUM, "glTexCoordPointer(type)" );
jtgafb833d1999-08-19 00:55:39 +0000410 return;
jtgafb833d1999-08-19 00:55:39 +0000411 }
Brian Paul2edd1802002-01-11 17:25:35 +0000412
Brian Paulf9d88c82006-06-13 17:24:36 +0000413 update_array(ctx, &ctx->Array.ArrayObj->TexCoord[unit],
414 _NEW_ARRAY_TEXCOORD(unit),
Brian Paulc5b1e812003-10-22 22:59:07 +0000415 elementSize, size, type, stride, GL_FALSE, ptr);
Keith Whitwell23caf202000-11-16 21:05:34 +0000416
417 if (ctx->Driver.TexCoordPointer)
418 ctx->Driver.TexCoordPointer( ctx, size, type, stride, ptr );
jtgafb833d1999-08-19 00:55:39 +0000419}
420
421
Kendall Bennettc40d1dd2003-10-21 22:22:17 +0000422void GLAPIENTRY
Brian Paulc5b1e812003-10-22 22:59:07 +0000423_mesa_EdgeFlagPointer(GLsizei stride, const GLvoid *ptr)
jtgafb833d1999-08-19 00:55:39 +0000424{
Brian Paulfbd8f211999-11-11 01:22:25 +0000425 GET_CURRENT_CONTEXT(ctx);
Keith Whitwellcab974c2000-12-26 05:09:27 +0000426 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
jtgafb833d1999-08-19 00:55:39 +0000427
Brian Paulc5b1e812003-10-22 22:59:07 +0000428 if (stride < 0) {
Brian Paul08836342001-03-03 20:33:27 +0000429 _mesa_error( ctx, GL_INVALID_VALUE, "glEdgeFlagPointer(stride)" );
jtgafb833d1999-08-19 00:55:39 +0000430 return;
431 }
Brian Paulc5b1e812003-10-22 22:59:07 +0000432
Ian Romanickee34e6e2006-06-12 16:26:29 +0000433 update_array(ctx, &ctx->Array.ArrayObj->EdgeFlag, _NEW_ARRAY_EDGEFLAG,
Brian Paulc78e8952006-09-04 14:07:04 +0000434 sizeof(GLboolean), 1, GL_UNSIGNED_BYTE, stride, GL_FALSE, ptr);
Keith Whitwell23caf202000-11-16 21:05:34 +0000435
436 if (ctx->Driver.EdgeFlagPointer)
437 ctx->Driver.EdgeFlagPointer( ctx, stride, ptr );
jtgafb833d1999-08-19 00:55:39 +0000438}
439
440
Brian Paul148a2842003-09-17 03:40:11 +0000441#if FEATURE_NV_vertex_program
Kendall Bennettc40d1dd2003-10-21 22:22:17 +0000442void GLAPIENTRY
Brian Paul92f97852003-05-01 22:44:02 +0000443_mesa_VertexAttribPointerNV(GLuint index, GLint size, GLenum type,
444 GLsizei stride, const GLvoid *ptr)
Brian Paul2edd1802002-01-11 17:25:35 +0000445{
Markus Amsler29fbf722008-03-09 17:53:22 -0600446 GLboolean normalized = GL_FALSE;
Brian Paulc5b1e812003-10-22 22:59:07 +0000447 GLsizei elementSize;
Brian Paul2edd1802002-01-11 17:25:35 +0000448 GET_CURRENT_CONTEXT(ctx);
449 ASSERT_OUTSIDE_BEGIN_END(ctx);
jtgafb833d1999-08-19 00:55:39 +0000450
Michal Krolbb38cad2006-04-11 11:41:11 +0000451 if (index >= MAX_VERTEX_PROGRAM_ATTRIBS) {
Brian Paul2edd1802002-01-11 17:25:35 +0000452 _mesa_error(ctx, GL_INVALID_VALUE, "glVertexAttribPointerNV(index)");
453 return;
454 }
455
456 if (size < 1 || size > 4) {
457 _mesa_error(ctx, GL_INVALID_VALUE, "glVertexAttribPointerNV(size)");
458 return;
459 }
460
461 if (stride < 0) {
462 _mesa_error(ctx, GL_INVALID_VALUE, "glVertexAttribPointerNV(stride)");
463 return;
464 }
465
466 if (type == GL_UNSIGNED_BYTE && size != 4) {
467 _mesa_error(ctx, GL_INVALID_VALUE, "glVertexAttribPointerNV(size!=4)");
468 return;
469 }
470
471 /* check for valid 'type' and compute StrideB right away */
472 switch (type) {
473 case GL_UNSIGNED_BYTE:
Markus Amsler29fbf722008-03-09 17:53:22 -0600474 normalized = GL_TRUE;
Brian Paulc5b1e812003-10-22 22:59:07 +0000475 elementSize = size * sizeof(GLubyte);
Brian Paul2edd1802002-01-11 17:25:35 +0000476 break;
477 case GL_SHORT:
Brian Paulc5b1e812003-10-22 22:59:07 +0000478 elementSize = size * sizeof(GLshort);
Brian Paul2edd1802002-01-11 17:25:35 +0000479 break;
480 case GL_FLOAT:
Brian Paulc5b1e812003-10-22 22:59:07 +0000481 elementSize = size * sizeof(GLfloat);
Brian Paul2edd1802002-01-11 17:25:35 +0000482 break;
483 case GL_DOUBLE:
Brian Paulc5b1e812003-10-22 22:59:07 +0000484 elementSize = size * sizeof(GLdouble);
Brian Paul2edd1802002-01-11 17:25:35 +0000485 break;
486 default:
487 _mesa_error( ctx, GL_INVALID_ENUM, "glVertexAttribPointerNV(type)" );
488 return;
489 }
490
Brian Paulf9d88c82006-06-13 17:24:36 +0000491 update_array(ctx, &ctx->Array.ArrayObj->VertexAttrib[index],
492 _NEW_ARRAY_ATTRIB(index),
Brian Paul095c6692006-04-25 00:21:32 +0000493 elementSize, size, type, stride, normalized, ptr);
Brian Paul2edd1802002-01-11 17:25:35 +0000494
Brian Paulb7752722002-04-21 18:49:18 +0000495 if (ctx->Driver.VertexAttribPointer)
Brian Paul2edd1802002-01-11 17:25:35 +0000496 ctx->Driver.VertexAttribPointer( ctx, index, size, type, stride, ptr );
Brian Paul2edd1802002-01-11 17:25:35 +0000497}
Brian Paul148a2842003-09-17 03:40:11 +0000498#endif
jtgafb833d1999-08-19 00:55:39 +0000499
Brian Paul1f0e2132000-06-12 15:30:51 +0000500
Brian Paul148a2842003-09-17 03:40:11 +0000501#if FEATURE_ARB_vertex_program
Kendall Bennettc40d1dd2003-10-21 22:22:17 +0000502void GLAPIENTRY
Brian Paul92f97852003-05-01 22:44:02 +0000503_mesa_VertexAttribPointerARB(GLuint index, GLint size, GLenum type,
504 GLboolean normalized,
505 GLsizei stride, const GLvoid *ptr)
506{
Brian Paulc5b1e812003-10-22 22:59:07 +0000507 GLsizei elementSize;
Brian Paul92f97852003-05-01 22:44:02 +0000508 GET_CURRENT_CONTEXT(ctx);
509 ASSERT_OUTSIDE_BEGIN_END(ctx);
510
Brian Paul05051032005-11-01 04:36:33 +0000511 if (index >= ctx->Const.VertexProgram.MaxAttribs) {
Brian Paul92f97852003-05-01 22:44:02 +0000512 _mesa_error(ctx, GL_INVALID_VALUE, "glVertexAttribPointerARB(index)");
513 return;
514 }
515
516 if (size < 1 || size > 4) {
517 _mesa_error(ctx, GL_INVALID_VALUE, "glVertexAttribPointerARB(size)");
518 return;
519 }
520
521 if (stride < 0) {
522 _mesa_error(ctx, GL_INVALID_VALUE, "glVertexAttribPointerARB(stride)");
523 return;
524 }
525
526 if (type == GL_UNSIGNED_BYTE && size != 4) {
527 _mesa_error(ctx, GL_INVALID_VALUE, "glVertexAttribPointerARB(size!=4)");
528 return;
529 }
530
531 /* check for valid 'type' and compute StrideB right away */
Brian Paul196a90b2003-06-11 18:47:51 +0000532 /* NOTE: more types are supported here than in the NV extension */
Brian Paul92f97852003-05-01 22:44:02 +0000533 switch (type) {
Brian Paul196a90b2003-06-11 18:47:51 +0000534 case GL_BYTE:
Brian Paulc5b1e812003-10-22 22:59:07 +0000535 elementSize = size * sizeof(GLbyte);
Brian Paul196a90b2003-06-11 18:47:51 +0000536 break;
Brian Paul92f97852003-05-01 22:44:02 +0000537 case GL_UNSIGNED_BYTE:
Brian Paulc5b1e812003-10-22 22:59:07 +0000538 elementSize = size * sizeof(GLubyte);
Brian Paul92f97852003-05-01 22:44:02 +0000539 break;
540 case GL_SHORT:
Brian Paulc5b1e812003-10-22 22:59:07 +0000541 elementSize = size * sizeof(GLshort);
Brian Paul92f97852003-05-01 22:44:02 +0000542 break;
Brian Paul196a90b2003-06-11 18:47:51 +0000543 case GL_UNSIGNED_SHORT:
Brian Paulc5b1e812003-10-22 22:59:07 +0000544 elementSize = size * sizeof(GLushort);
Brian Paul196a90b2003-06-11 18:47:51 +0000545 break;
546 case GL_INT:
Brian Paulc5b1e812003-10-22 22:59:07 +0000547 elementSize = size * sizeof(GLint);
Brian Paul196a90b2003-06-11 18:47:51 +0000548 break;
549 case GL_UNSIGNED_INT:
Brian Paulc5b1e812003-10-22 22:59:07 +0000550 elementSize = size * sizeof(GLuint);
Brian Paul196a90b2003-06-11 18:47:51 +0000551 break;
Brian Paul92f97852003-05-01 22:44:02 +0000552 case GL_FLOAT:
Brian Paulc5b1e812003-10-22 22:59:07 +0000553 elementSize = size * sizeof(GLfloat);
Brian Paul92f97852003-05-01 22:44:02 +0000554 break;
555 case GL_DOUBLE:
Brian Paulc5b1e812003-10-22 22:59:07 +0000556 elementSize = size * sizeof(GLdouble);
Brian Paul92f97852003-05-01 22:44:02 +0000557 break;
558 default:
559 _mesa_error( ctx, GL_INVALID_ENUM, "glVertexAttribPointerARB(type)" );
560 return;
561 }
562
Brian Paulf9d88c82006-06-13 17:24:36 +0000563 update_array(ctx, &ctx->Array.ArrayObj->VertexAttrib[index],
564 _NEW_ARRAY_ATTRIB(index),
Brian Paulc5b1e812003-10-22 22:59:07 +0000565 elementSize, size, type, stride, normalized, ptr);
Brian Paul92f97852003-05-01 22:44:02 +0000566
Brian Paul92f97852003-05-01 22:44:02 +0000567 if (ctx->Driver.VertexAttribPointer)
Brian Paulf9d88c82006-06-13 17:24:36 +0000568 ctx->Driver.VertexAttribPointer(ctx, index, size, type, stride, ptr);
Brian Paul92f97852003-05-01 22:44:02 +0000569}
Brian Paul148a2842003-09-17 03:40:11 +0000570#endif
Brian Paul92f97852003-05-01 22:44:02 +0000571
572
Kendall Bennettc40d1dd2003-10-21 22:22:17 +0000573void GLAPIENTRY
Brian Paul1f0e2132000-06-12 15:30:51 +0000574_mesa_VertexPointerEXT(GLint size, GLenum type, GLsizei stride,
575 GLsizei count, const GLvoid *ptr)
576{
577 (void) count;
578 _mesa_VertexPointer(size, type, stride, ptr);
579}
580
581
Kendall Bennettc40d1dd2003-10-21 22:22:17 +0000582void GLAPIENTRY
Brian Paul1f0e2132000-06-12 15:30:51 +0000583_mesa_NormalPointerEXT(GLenum type, GLsizei stride, GLsizei count,
584 const GLvoid *ptr)
585{
586 (void) count;
587 _mesa_NormalPointer(type, stride, ptr);
588}
589
590
Kendall Bennettc40d1dd2003-10-21 22:22:17 +0000591void GLAPIENTRY
Brian Paul1f0e2132000-06-12 15:30:51 +0000592_mesa_ColorPointerEXT(GLint size, GLenum type, GLsizei stride, GLsizei count,
593 const GLvoid *ptr)
594{
595 (void) count;
596 _mesa_ColorPointer(size, type, stride, ptr);
597}
598
599
Kendall Bennettc40d1dd2003-10-21 22:22:17 +0000600void GLAPIENTRY
Brian Paul1f0e2132000-06-12 15:30:51 +0000601_mesa_IndexPointerEXT(GLenum type, GLsizei stride, GLsizei count,
602 const GLvoid *ptr)
603{
604 (void) count;
605 _mesa_IndexPointer(type, stride, ptr);
606}
607
608
Kendall Bennettc40d1dd2003-10-21 22:22:17 +0000609void GLAPIENTRY
Brian Paul1f0e2132000-06-12 15:30:51 +0000610_mesa_TexCoordPointerEXT(GLint size, GLenum type, GLsizei stride,
611 GLsizei count, const GLvoid *ptr)
612{
613 (void) count;
614 _mesa_TexCoordPointer(size, type, stride, ptr);
615}
616
617
Kendall Bennettc40d1dd2003-10-21 22:22:17 +0000618void GLAPIENTRY
Brian Paul1f0e2132000-06-12 15:30:51 +0000619_mesa_EdgeFlagPointerEXT(GLsizei stride, GLsizei count, const GLboolean *ptr)
620{
621 (void) count;
622 _mesa_EdgeFlagPointer(stride, ptr);
623}
624
625
Kendall Bennettc40d1dd2003-10-21 22:22:17 +0000626void GLAPIENTRY
Brian Paulfbd8f211999-11-11 01:22:25 +0000627_mesa_InterleavedArrays(GLenum format, GLsizei stride, const GLvoid *pointer)
jtgafb833d1999-08-19 00:55:39 +0000628{
Brian Paulfbd8f211999-11-11 01:22:25 +0000629 GET_CURRENT_CONTEXT(ctx);
jtgafb833d1999-08-19 00:55:39 +0000630 GLboolean tflag, cflag, nflag; /* enable/disable flags */
631 GLint tcomps, ccomps, vcomps; /* components per texcoord, color, vertex */
Keith Whitwellf4b02d12001-01-05 05:31:42 +0000632 GLenum ctype = 0; /* color type */
633 GLint coffset = 0, noffset = 0, voffset;/* color, normal, vertex offsets */
Brian Paul4a3110f2003-12-12 18:40:02 +0000634 const GLint toffset = 0; /* always zero */
jtgafb833d1999-08-19 00:55:39 +0000635 GLint defstride; /* default stride */
636 GLint c, f;
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +0000637
Keith Whitwellcab974c2000-12-26 05:09:27 +0000638 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
639
jtgafb833d1999-08-19 00:55:39 +0000640 f = sizeof(GLfloat);
Brian Paulc5b1e812003-10-22 22:59:07 +0000641 c = f * ((4 * sizeof(GLubyte) + (f - 1)) / f);
jtgafb833d1999-08-19 00:55:39 +0000642
Brian Paulc5b1e812003-10-22 22:59:07 +0000643 if (stride < 0) {
Brian Paul08836342001-03-03 20:33:27 +0000644 _mesa_error( ctx, GL_INVALID_VALUE, "glInterleavedArrays(stride)" );
jtgafb833d1999-08-19 00:55:39 +0000645 return;
646 }
647
648 switch (format) {
649 case GL_V2F:
650 tflag = GL_FALSE; cflag = GL_FALSE; nflag = GL_FALSE;
651 tcomps = 0; ccomps = 0; vcomps = 2;
652 voffset = 0;
653 defstride = 2*f;
654 break;
655 case GL_V3F:
656 tflag = GL_FALSE; cflag = GL_FALSE; nflag = GL_FALSE;
657 tcomps = 0; ccomps = 0; vcomps = 3;
658 voffset = 0;
659 defstride = 3*f;
660 break;
661 case GL_C4UB_V2F:
662 tflag = GL_FALSE; cflag = GL_TRUE; nflag = GL_FALSE;
663 tcomps = 0; ccomps = 4; vcomps = 2;
664 ctype = GL_UNSIGNED_BYTE;
665 coffset = 0;
666 voffset = c;
667 defstride = c + 2*f;
668 break;
669 case GL_C4UB_V3F:
670 tflag = GL_FALSE; cflag = GL_TRUE; nflag = GL_FALSE;
671 tcomps = 0; ccomps = 4; vcomps = 3;
672 ctype = GL_UNSIGNED_BYTE;
673 coffset = 0;
674 voffset = c;
675 defstride = c + 3*f;
676 break;
677 case GL_C3F_V3F:
678 tflag = GL_FALSE; cflag = GL_TRUE; nflag = GL_FALSE;
679 tcomps = 0; ccomps = 3; vcomps = 3;
680 ctype = GL_FLOAT;
681 coffset = 0;
682 voffset = 3*f;
683 defstride = 6*f;
684 break;
685 case GL_N3F_V3F:
686 tflag = GL_FALSE; cflag = GL_FALSE; nflag = GL_TRUE;
687 tcomps = 0; ccomps = 0; vcomps = 3;
688 noffset = 0;
689 voffset = 3*f;
690 defstride = 6*f;
691 break;
692 case GL_C4F_N3F_V3F:
693 tflag = GL_FALSE; cflag = GL_TRUE; nflag = GL_TRUE;
694 tcomps = 0; ccomps = 4; vcomps = 3;
695 ctype = GL_FLOAT;
696 coffset = 0;
697 noffset = 4*f;
698 voffset = 7*f;
699 defstride = 10*f;
700 break;
701 case GL_T2F_V3F:
702 tflag = GL_TRUE; cflag = GL_FALSE; nflag = GL_FALSE;
703 tcomps = 2; ccomps = 0; vcomps = 3;
704 voffset = 2*f;
705 defstride = 5*f;
706 break;
707 case GL_T4F_V4F:
708 tflag = GL_TRUE; cflag = GL_FALSE; nflag = GL_FALSE;
709 tcomps = 4; ccomps = 0; vcomps = 4;
710 voffset = 4*f;
711 defstride = 8*f;
712 break;
713 case GL_T2F_C4UB_V3F:
714 tflag = GL_TRUE; cflag = GL_TRUE; nflag = GL_FALSE;
715 tcomps = 2; ccomps = 4; vcomps = 3;
716 ctype = GL_UNSIGNED_BYTE;
717 coffset = 2*f;
718 voffset = c+2*f;
719 defstride = c+5*f;
720 break;
721 case GL_T2F_C3F_V3F:
722 tflag = GL_TRUE; cflag = GL_TRUE; nflag = GL_FALSE;
723 tcomps = 2; ccomps = 3; vcomps = 3;
724 ctype = GL_FLOAT;
725 coffset = 2*f;
726 voffset = 5*f;
727 defstride = 8*f;
728 break;
729 case GL_T2F_N3F_V3F:
730 tflag = GL_TRUE; cflag = GL_FALSE; nflag = GL_TRUE;
731 tcomps = 2; ccomps = 0; vcomps = 3;
732 noffset = 2*f;
733 voffset = 5*f;
734 defstride = 8*f;
735 break;
736 case GL_T2F_C4F_N3F_V3F:
737 tflag = GL_TRUE; cflag = GL_TRUE; nflag = GL_TRUE;
738 tcomps = 2; ccomps = 4; vcomps = 3;
739 ctype = GL_FLOAT;
740 coffset = 2*f;
741 noffset = 6*f;
742 voffset = 9*f;
743 defstride = 12*f;
744 break;
745 case GL_T4F_C4F_N3F_V4F:
746 tflag = GL_TRUE; cflag = GL_TRUE; nflag = GL_TRUE;
747 tcomps = 4; ccomps = 4; vcomps = 4;
748 ctype = GL_FLOAT;
749 coffset = 4*f;
750 noffset = 8*f;
751 voffset = 11*f;
752 defstride = 15*f;
753 break;
754 default:
Brian Paul08836342001-03-03 20:33:27 +0000755 _mesa_error( ctx, GL_INVALID_ENUM, "glInterleavedArrays(format)" );
jtgafb833d1999-08-19 00:55:39 +0000756 return;
757 }
758
759 if (stride==0) {
760 stride = defstride;
761 }
762
Brian Paulfbd8f211999-11-11 01:22:25 +0000763 _mesa_DisableClientState( GL_EDGE_FLAG_ARRAY );
764 _mesa_DisableClientState( GL_INDEX_ARRAY );
Brian Paul095c6692006-04-25 00:21:32 +0000765 /* XXX also disable secondary color and generic arrays? */
jtgafb833d1999-08-19 00:55:39 +0000766
767 /* Texcoords */
jtgafb833d1999-08-19 00:55:39 +0000768 if (tflag) {
Brian Paul4a3110f2003-12-12 18:40:02 +0000769 _mesa_EnableClientState( GL_TEXTURE_COORD_ARRAY );
770 _mesa_TexCoordPointer( tcomps, GL_FLOAT, stride,
Brian Paulab928e52004-03-10 16:17:35 +0000771 (GLubyte *) pointer + toffset );
jtgafb833d1999-08-19 00:55:39 +0000772 }
773 else {
Brian Paulab928e52004-03-10 16:17:35 +0000774 _mesa_DisableClientState( GL_TEXTURE_COORD_ARRAY );
jtgafb833d1999-08-19 00:55:39 +0000775 }
jtgafb833d1999-08-19 00:55:39 +0000776
777 /* Color */
778 if (cflag) {
Brian Paulfbd8f211999-11-11 01:22:25 +0000779 _mesa_EnableClientState( GL_COLOR_ARRAY );
Keith Whitwellcab974c2000-12-26 05:09:27 +0000780 _mesa_ColorPointer( ccomps, ctype, stride,
Brian Paul4a3110f2003-12-12 18:40:02 +0000781 (GLubyte *) pointer + coffset );
jtgafb833d1999-08-19 00:55:39 +0000782 }
783 else {
Brian Paulfbd8f211999-11-11 01:22:25 +0000784 _mesa_DisableClientState( GL_COLOR_ARRAY );
jtgafb833d1999-08-19 00:55:39 +0000785 }
786
787
788 /* Normals */
789 if (nflag) {
Brian Paulfbd8f211999-11-11 01:22:25 +0000790 _mesa_EnableClientState( GL_NORMAL_ARRAY );
Brian Paul4a3110f2003-12-12 18:40:02 +0000791 _mesa_NormalPointer( GL_FLOAT, stride, (GLubyte *) pointer + noffset );
jtgafb833d1999-08-19 00:55:39 +0000792 }
793 else {
Brian Paulfbd8f211999-11-11 01:22:25 +0000794 _mesa_DisableClientState( GL_NORMAL_ARRAY );
jtgafb833d1999-08-19 00:55:39 +0000795 }
796
Brian Paul4a3110f2003-12-12 18:40:02 +0000797 /* Vertices */
Brian Paulfbd8f211999-11-11 01:22:25 +0000798 _mesa_EnableClientState( GL_VERTEX_ARRAY );
Keith Whitwellcab974c2000-12-26 05:09:27 +0000799 _mesa_VertexPointer( vcomps, GL_FLOAT, stride,
800 (GLubyte *) pointer + voffset );
jtgafb833d1999-08-19 00:55:39 +0000801}
802
803
Kendall Bennettc40d1dd2003-10-21 22:22:17 +0000804void GLAPIENTRY
Keith Whitwellad2ac212000-11-24 10:25:05 +0000805_mesa_LockArraysEXT(GLint first, GLsizei count)
806{
807 GET_CURRENT_CONTEXT(ctx);
Keith Whitwellcab974c2000-12-26 05:09:27 +0000808 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
Keith Whitwellad2ac212000-11-24 10:25:05 +0000809
810 if (MESA_VERBOSE & VERBOSE_API)
Brian Paul4753d602002-06-15 02:38:15 +0000811 _mesa_debug(ctx, "glLockArrays %d %d\n", first, count);
Keith Whitwellad2ac212000-11-24 10:25:05 +0000812
Eric Anholt5857e982008-02-02 02:54:13 -0800813 if (first < 0) {
814 _mesa_error( ctx, GL_INVALID_VALUE, "glLockArraysEXT(first)" );
815 return;
Gareth Hughes22144ab2001-03-12 00:48:37 +0000816 }
Eric Anholt5857e982008-02-02 02:54:13 -0800817 if (count <= 0) {
818 _mesa_error( ctx, GL_INVALID_VALUE, "glLockArraysEXT(count)" );
819 return;
Keith Whitwellad2ac212000-11-24 10:25:05 +0000820 }
Eric Anholt5857e982008-02-02 02:54:13 -0800821 if (ctx->Array.LockCount != 0) {
822 _mesa_error( ctx, GL_INVALID_OPERATION, "glLockArraysEXT(reentry)" );
823 return;
824 }
825
826 ctx->Array.LockFirst = first;
827 ctx->Array.LockCount = count;
Keith Whitwellad2ac212000-11-24 10:25:05 +0000828
829 ctx->NewState |= _NEW_ARRAY;
Keith Whitwellcab974c2000-12-26 05:09:27 +0000830 ctx->Array.NewState |= _NEW_ARRAY_ALL;
Keith Whitwellad2ac212000-11-24 10:25:05 +0000831
832 if (ctx->Driver.LockArraysEXT)
833 ctx->Driver.LockArraysEXT( ctx, first, count );
834}
835
836
Kendall Bennettc40d1dd2003-10-21 22:22:17 +0000837void GLAPIENTRY
Keith Whitwellad2ac212000-11-24 10:25:05 +0000838_mesa_UnlockArraysEXT( void )
839{
840 GET_CURRENT_CONTEXT(ctx);
Keith Whitwellcab974c2000-12-26 05:09:27 +0000841 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
Keith Whitwellad2ac212000-11-24 10:25:05 +0000842
843 if (MESA_VERBOSE & VERBOSE_API)
Brian Paul4753d602002-06-15 02:38:15 +0000844 _mesa_debug(ctx, "glUnlockArrays\n");
Keith Whitwellad2ac212000-11-24 10:25:05 +0000845
Eric Anholt5857e982008-02-02 02:54:13 -0800846 if (ctx->Array.LockCount == 0) {
847 _mesa_error( ctx, GL_INVALID_OPERATION, "glUnlockArraysEXT(reexit)" );
848 return;
849 }
850
Keith Whitwellad2ac212000-11-24 10:25:05 +0000851 ctx->Array.LockFirst = 0;
852 ctx->Array.LockCount = 0;
853 ctx->NewState |= _NEW_ARRAY;
Keith Whitwellcab974c2000-12-26 05:09:27 +0000854 ctx->Array.NewState |= _NEW_ARRAY_ALL;
Keith Whitwellad2ac212000-11-24 10:25:05 +0000855
856 if (ctx->Driver.UnlockArraysEXT)
857 ctx->Driver.UnlockArraysEXT( ctx );
858}
Brian Paul2525bc72002-06-30 15:47:00 +0000859
860
Brian Paul2525bc72002-06-30 15:47:00 +0000861/* GL_EXT_multi_draw_arrays */
862/* Somebody forgot to spec the first and count parameters as const! <sigh> */
Kendall Bennettc40d1dd2003-10-21 22:22:17 +0000863void GLAPIENTRY
Brian Paul2525bc72002-06-30 15:47:00 +0000864_mesa_MultiDrawArraysEXT( GLenum mode, GLint *first,
865 GLsizei *count, GLsizei primcount )
866{
867 GET_CURRENT_CONTEXT(ctx);
868 GLint i;
869
870 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
871
872 for (i = 0; i < primcount; i++) {
873 if (count[i] > 0) {
Ian Romanick9bdfee32005-07-18 12:31:24 +0000874 CALL_DrawArrays(ctx->Exec, (mode, first[i], count[i]));
Brian Paul2525bc72002-06-30 15:47:00 +0000875 }
876 }
877}
878
879
880/* GL_EXT_multi_draw_arrays */
Kendall Bennettc40d1dd2003-10-21 22:22:17 +0000881void GLAPIENTRY
Brian Paul2525bc72002-06-30 15:47:00 +0000882_mesa_MultiDrawElementsEXT( GLenum mode, const GLsizei *count, GLenum type,
883 const GLvoid **indices, GLsizei primcount )
884{
885 GET_CURRENT_CONTEXT(ctx);
886 GLint i;
887
888 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
889
890 for (i = 0; i < primcount; i++) {
891 if (count[i] > 0) {
Ian Romanick9bdfee32005-07-18 12:31:24 +0000892 CALL_DrawElements(ctx->Exec, (mode, count[i], type, indices[i]));
Brian Paul2525bc72002-06-30 15:47:00 +0000893 }
894 }
895}
Keith Whitwell6dc85572003-07-17 13:43:59 +0000896
897
Ian Romanick3baefe62003-08-22 23:28:03 +0000898/* GL_IBM_multimode_draw_arrays */
Kendall Bennettc40d1dd2003-10-21 22:22:17 +0000899void GLAPIENTRY
Ian Romanick3baefe62003-08-22 23:28:03 +0000900_mesa_MultiModeDrawArraysIBM( const GLenum * mode, const GLint * first,
901 const GLsizei * count,
902 GLsizei primcount, GLint modestride )
903{
904 GET_CURRENT_CONTEXT(ctx);
905 GLint i;
906
907 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
908
909 for ( i = 0 ; i < primcount ; i++ ) {
910 if ( count[i] > 0 ) {
Brian Paul03e29a52003-12-04 03:16:27 +0000911 GLenum m = *((GLenum *) ((GLubyte *) mode + i * modestride));
Ian Romanick9bdfee32005-07-18 12:31:24 +0000912 CALL_DrawArrays(ctx->Exec, ( m, first[i], count[i] ));
Ian Romanick3baefe62003-08-22 23:28:03 +0000913 }
914 }
915}
916
917
918/* GL_IBM_multimode_draw_arrays */
Kendall Bennettc40d1dd2003-10-21 22:22:17 +0000919void GLAPIENTRY
Ian Romanick3baefe62003-08-22 23:28:03 +0000920_mesa_MultiModeDrawElementsIBM( const GLenum * mode, const GLsizei * count,
921 GLenum type, const GLvoid * const * indices,
922 GLsizei primcount, GLint modestride )
923{
924 GET_CURRENT_CONTEXT(ctx);
925 GLint i;
926
927 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
928
Brian Pauld2afb392003-09-17 18:15:13 +0000929 /* XXX not sure about ARB_vertex_buffer_object handling here */
930
Ian Romanick3baefe62003-08-22 23:28:03 +0000931 for ( i = 0 ; i < primcount ; i++ ) {
932 if ( count[i] > 0 ) {
Brian Paul03e29a52003-12-04 03:16:27 +0000933 GLenum m = *((GLenum *) ((GLubyte *) mode + i * modestride));
Ian Romanick9bdfee32005-07-18 12:31:24 +0000934 CALL_DrawElements(ctx->Exec, ( m, count[i], type, indices[i] ));
Ian Romanick3baefe62003-08-22 23:28:03 +0000935 }
936 }
937}
938
939
Brian Paul095c6692006-04-25 00:21:32 +0000940/**
941 * Initialize vertex array state for given context.
942 */
Kendall Bennettc40d1dd2003-10-21 22:22:17 +0000943void
Brian Paul095c6692006-04-25 00:21:32 +0000944_mesa_init_varray(GLcontext *ctx)
Keith Whitwell6dc85572003-07-17 13:43:59 +0000945{
Ian Romanickee34e6e2006-06-12 16:26:29 +0000946 ctx->Array.DefaultArrayObj = _mesa_new_array_object(ctx, 0);
947 ctx->Array.ArrayObj = ctx->Array.DefaultArrayObj;
Brian Paul095c6692006-04-25 00:21:32 +0000948
949 ctx->Array.ActiveTexture = 0; /* GL_ARB_multitexture */
Keith Whitwell6dc85572003-07-17 13:43:59 +0000950}