blob: 818ed792e3bc9f18a1f6c67e6fea5ee16e468893 [file] [log] [blame]
jtgafb833d1999-08-19 00:55:39 +00001/*
2 * Mesa 3-D graphics library
Brian Paul39d75242009-05-14 16:25:32 -06003 * Version: 7.6
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +00004 *
Brian Paul37c74af2008-09-04 14:58:02 -06005 * Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
Brian Paul39d75242009-05-14 16:25:32 -06006 * Copyright (C) 2009 VMware, Inc. All Rights Reserved.
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +00007 *
jtgafb833d1999-08-19 00:55:39 +00008 * Permission is hereby granted, free of charge, to any person obtaining a
9 * copy of this software and associated documentation files (the "Software"),
10 * to deal in the Software without restriction, including without limitation
11 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
12 * and/or sell copies of the Software, and to permit persons to whom the
13 * Software is furnished to do so, subject to the following conditions:
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +000014 *
jtgafb833d1999-08-19 00:55:39 +000015 * The above copyright notice and this permission notice shall be included
16 * in all copies or substantial portions of the Software.
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +000017 *
jtgafb833d1999-08-19 00:55:39 +000018 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
22 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 */
25
Keith Whitwell6dc85572003-07-17 13:43:59 +000026
Brian Paulfbd8f211999-11-11 01:22:25 +000027#include "glheader.h"
Brian Paul148a2842003-09-17 03:40:11 +000028#include "imports.h"
Brian Paul26895aa2004-03-03 15:35:08 +000029#include "bufferobj.h"
jtgafb833d1999-08-19 00:55:39 +000030#include "context.h"
jtgafb833d1999-08-19 00:55:39 +000031#include "enable.h"
32#include "enums.h"
Brian Paul12cf98f2009-06-19 17:58:47 -060033#include "hash.h"
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +000034#include "mtypes.h"
jtgafb833d1999-08-19 00:55:39 +000035#include "varray.h"
Ian Romanickee34e6e2006-06-12 16:26:29 +000036#include "arrayobj.h"
Brianc223c6b2007-07-04 13:15:20 -060037#include "glapi/dispatch.h"
jtgafb833d1999-08-19 00:55:39 +000038
Brian Paulc5b1e812003-10-22 22:59:07 +000039
40/**
Brian Paul54a5ffb2009-05-21 16:05:11 -060041 * Set the fields of a vertex array.
Brian Paule2b72492009-06-22 16:56:35 -060042 * Also do an error check for GL_ARB_vertex_array_object: check that
43 * all arrays reside in VBOs when using a vertex array object.
Brian Paulf9d88c82006-06-13 17:24:36 +000044 *
45 * \param array the array to update
46 * \param dirtyBit which bit to set in ctx->Array.NewState for this array
47 * \param elementSize size of each array element, in bytes
48 * \param size components per element (1, 2, 3 or 4)
49 * \param type datatype of each component (GL_FLOAT, GL_INT, etc)
Brian Paul54a5ffb2009-05-21 16:05:11 -060050 * \param format either GL_RGBA or GL_BGRA
Brian Paulf9d88c82006-06-13 17:24:36 +000051 * \param stride stride between elements, in elements
52 * \param normalized are integer types converted to floats in [-1, 1]?
53 * \param ptr the address (or offset inside VBO) of the array data
Brian Paulc5b1e812003-10-22 22:59:07 +000054 */
Brian Paulf549f4c2009-11-12 23:04:26 -070055static void
Brian Paulc5b1e812003-10-22 22:59:07 +000056update_array(GLcontext *ctx, struct gl_client_array *array,
Brian Paulf9d88c82006-06-13 17:24:36 +000057 GLbitfield dirtyBit, GLsizei elementSize,
Brian Paul76d27a62009-01-23 11:24:31 -070058 GLint size, GLenum type, GLenum format,
Brian Paulc5b1e812003-10-22 22:59:07 +000059 GLsizei stride, GLboolean normalized, const GLvoid *ptr)
60{
Brian Paul76d27a62009-01-23 11:24:31 -070061 ASSERT(format == GL_RGBA || format == GL_BGRA);
Brian Paule2b72492009-06-22 16:56:35 -060062
63 if (ctx->Array.ArrayObj->VBOonly &&
64 ctx->Array.ArrayBufferObj->Name == 0) {
65 /* GL_ARB_vertex_array_object requires that all arrays reside in VBOs.
66 * Generate GL_INVALID_OPERATION if that's not true.
67 */
68 _mesa_error(ctx, GL_INVALID_OPERATION,
69 "glVertex/Normal/EtcPointer(non-VBO array)");
Brian Paulf549f4c2009-11-12 23:04:26 -070070 return;
Brian Paule2b72492009-06-22 16:56:35 -060071 }
72
Brian Paulc5b1e812003-10-22 22:59:07 +000073 array->Size = size;
74 array->Type = type;
Brian Paul76d27a62009-01-23 11:24:31 -070075 array->Format = format;
Brian Paulc5b1e812003-10-22 22:59:07 +000076 array->Stride = stride;
77 array->StrideB = stride ? stride : elementSize;
78 array->Normalized = normalized;
79 array->Ptr = (const GLubyte *) ptr;
Brian Paul0077c872009-05-06 13:00:35 -060080 array->_ElementSize = elementSize;
81
Brian Paul37c74af2008-09-04 14:58:02 -060082 _mesa_reference_buffer_object(ctx, &array->BufferObj,
83 ctx->Array.ArrayBufferObj);
84
Brian Paulc5b1e812003-10-22 22:59:07 +000085 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;
Dave Airliecfe884e2010-01-18 16:29:31 +1000124 case GL_HALF_FLOAT:
125 elementSize = size * sizeof(GLhalfARB);
126 break;
Brian Paul394c1d12008-06-20 11:32:22 -0600127#if FEATURE_fixedpt
128 case GL_FIXED:
129 elementSize = size * sizeof(GLfixed);
130 break;
131#endif
Brian Pauld17485f2008-06-20 11:49:25 -0600132#if FEATURE_vertex_array_byte
133 case GL_BYTE:
134 elementSize = size * sizeof(GLbyte);
135 break;
136#endif
jtgafb833d1999-08-19 00:55:39 +0000137 default:
Brian Paul2b82bc92009-08-04 14:53:24 -0600138 _mesa_error( ctx, GL_INVALID_ENUM, "glVertexPointer(type=%s)",
139 _mesa_lookup_enum_by_nr(type));
jtgafb833d1999-08-19 00:55:39 +0000140 return;
jtgafb833d1999-08-19 00:55:39 +0000141 }
Brian Paul2edd1802002-01-11 17:25:35 +0000142
Brian Paulf549f4c2009-11-12 23:04:26 -0700143 update_array(ctx, &ctx->Array.ArrayObj->Vertex, _NEW_ARRAY_VERTEX,
144 elementSize, size, type, GL_RGBA, stride, GL_FALSE, ptr);
jtgafb833d1999-08-19 00:55:39 +0000145}
146
147
Kendall Bennettc40d1dd2003-10-21 22:22:17 +0000148void GLAPIENTRY
Brian Paulfbd8f211999-11-11 01:22:25 +0000149_mesa_NormalPointer(GLenum type, GLsizei stride, const GLvoid *ptr )
jtgafb833d1999-08-19 00:55:39 +0000150{
Brian Paulc5b1e812003-10-22 22:59:07 +0000151 GLsizei elementSize;
Brian Paulfbd8f211999-11-11 01:22:25 +0000152 GET_CURRENT_CONTEXT(ctx);
Keith Whitwellcab974c2000-12-26 05:09:27 +0000153 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +0000154
Brian Paul2edd1802002-01-11 17:25:35 +0000155 if (stride < 0) {
Brian Paul08836342001-03-03 20:33:27 +0000156 _mesa_error( ctx, GL_INVALID_VALUE, "glNormalPointer(stride)" );
jtgafb833d1999-08-19 00:55:39 +0000157 return;
158 }
159
160 if (MESA_VERBOSE&(VERBOSE_VARRAY|VERBOSE_API))
Brian Paul4753d602002-06-15 02:38:15 +0000161 _mesa_debug(ctx, "glNormalPointer( type %s stride %d )\n",
162 _mesa_lookup_enum_by_nr( type ), stride);
jtgafb833d1999-08-19 00:55:39 +0000163
Brian Paul2edd1802002-01-11 17:25:35 +0000164 switch (type) {
jtgafb833d1999-08-19 00:55:39 +0000165 case GL_BYTE:
Brian Paulc5b1e812003-10-22 22:59:07 +0000166 elementSize = 3 * sizeof(GLbyte);
jtgafb833d1999-08-19 00:55:39 +0000167 break;
168 case GL_SHORT:
Brian Paulc5b1e812003-10-22 22:59:07 +0000169 elementSize = 3 * sizeof(GLshort);
jtgafb833d1999-08-19 00:55:39 +0000170 break;
171 case GL_INT:
Brian Paulc5b1e812003-10-22 22:59:07 +0000172 elementSize = 3 * sizeof(GLint);
jtgafb833d1999-08-19 00:55:39 +0000173 break;
174 case GL_FLOAT:
Brian Paulc5b1e812003-10-22 22:59:07 +0000175 elementSize = 3 * sizeof(GLfloat);
jtgafb833d1999-08-19 00:55:39 +0000176 break;
177 case GL_DOUBLE:
Brian Paulc5b1e812003-10-22 22:59:07 +0000178 elementSize = 3 * sizeof(GLdouble);
jtgafb833d1999-08-19 00:55:39 +0000179 break;
Dave Airliecfe884e2010-01-18 16:29:31 +1000180 case GL_HALF_FLOAT:
181 elementSize = 3 * sizeof(GLhalfARB);
182 break;
Brian Paul394c1d12008-06-20 11:32:22 -0600183#if FEATURE_fixedpt
184 case GL_FIXED:
185 elementSize = 3 * sizeof(GLfixed);
186 break;
187#endif
jtgafb833d1999-08-19 00:55:39 +0000188 default:
Brian Paul2b82bc92009-08-04 14:53:24 -0600189 _mesa_error( ctx, GL_INVALID_ENUM, "glNormalPointer(type=%s)",
190 _mesa_lookup_enum_by_nr(type));
jtgafb833d1999-08-19 00:55:39 +0000191 return;
jtgafb833d1999-08-19 00:55:39 +0000192 }
Brian Paul2edd1802002-01-11 17:25:35 +0000193
Brian Paulf549f4c2009-11-12 23:04:26 -0700194 update_array(ctx, &ctx->Array.ArrayObj->Normal, _NEW_ARRAY_NORMAL,
195 elementSize, 3, type, GL_RGBA, stride, GL_TRUE, ptr);
jtgafb833d1999-08-19 00:55:39 +0000196}
197
198
Kendall Bennettc40d1dd2003-10-21 22:22:17 +0000199void GLAPIENTRY
Brian Paulfbd8f211999-11-11 01:22:25 +0000200_mesa_ColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr)
jtgafb833d1999-08-19 00:55:39 +0000201{
Brian Paulc5b1e812003-10-22 22:59:07 +0000202 GLsizei elementSize;
Brian Paul76d27a62009-01-23 11:24:31 -0700203 GLenum format;
Brian Paulfbd8f211999-11-11 01:22:25 +0000204 GET_CURRENT_CONTEXT(ctx);
Keith Whitwellcab974c2000-12-26 05:09:27 +0000205 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
Brian Paulfbd8f211999-11-11 01:22:25 +0000206
Brian Paul2edd1802002-01-11 17:25:35 +0000207 if (size < 3 || size > 4) {
Brian Paul76d27a62009-01-23 11:24:31 -0700208 if (!ctx->Extensions.EXT_vertex_array_bgra || size != GL_BGRA) {
209 _mesa_error(ctx, GL_INVALID_VALUE, "glColorPointer(size)");
210 return;
211 }
jtgafb833d1999-08-19 00:55:39 +0000212 }
Brian Paulc5b1e812003-10-22 22:59:07 +0000213 if (stride < 0) {
Brian Paul08836342001-03-03 20:33:27 +0000214 _mesa_error( ctx, GL_INVALID_VALUE, "glColorPointer(stride)" );
jtgafb833d1999-08-19 00:55:39 +0000215 return;
216 }
217
218 if (MESA_VERBOSE&(VERBOSE_VARRAY|VERBOSE_API))
Brian Paul4753d602002-06-15 02:38:15 +0000219 _mesa_debug(ctx, "glColorPointer( sz %d type %s stride %d )\n", size,
220 _mesa_lookup_enum_by_nr( type ), stride);
jtgafb833d1999-08-19 00:55:39 +0000221
Brian Paul76d27a62009-01-23 11:24:31 -0700222 if (size == GL_BGRA) {
223 if (type != GL_UNSIGNED_BYTE) {
224 _mesa_error(ctx, GL_INVALID_VALUE, "glColorPointer(GL_BGRA/GLubyte)");
225 return;
226 }
227 format = GL_BGRA;
228 size = 4;
229 }
230 else {
231 format = GL_RGBA;
232 }
233
Brian Paul2edd1802002-01-11 17:25:35 +0000234 switch (type) {
jtgafb833d1999-08-19 00:55:39 +0000235 case GL_BYTE:
Brian Paulc5b1e812003-10-22 22:59:07 +0000236 elementSize = size * sizeof(GLbyte);
jtgafb833d1999-08-19 00:55:39 +0000237 break;
238 case GL_UNSIGNED_BYTE:
Brian Paulc5b1e812003-10-22 22:59:07 +0000239 elementSize = size * sizeof(GLubyte);
jtgafb833d1999-08-19 00:55:39 +0000240 break;
241 case GL_SHORT:
Brian Paulc5b1e812003-10-22 22:59:07 +0000242 elementSize = size * sizeof(GLshort);
jtgafb833d1999-08-19 00:55:39 +0000243 break;
244 case GL_UNSIGNED_SHORT:
Brian Paulc5b1e812003-10-22 22:59:07 +0000245 elementSize = size * sizeof(GLushort);
jtgafb833d1999-08-19 00:55:39 +0000246 break;
247 case GL_INT:
Brian Paulc5b1e812003-10-22 22:59:07 +0000248 elementSize = size * sizeof(GLint);
jtgafb833d1999-08-19 00:55:39 +0000249 break;
250 case GL_UNSIGNED_INT:
Brian Paulc5b1e812003-10-22 22:59:07 +0000251 elementSize = size * sizeof(GLuint);
jtgafb833d1999-08-19 00:55:39 +0000252 break;
253 case GL_FLOAT:
Brian Paulc5b1e812003-10-22 22:59:07 +0000254 elementSize = size * sizeof(GLfloat);
jtgafb833d1999-08-19 00:55:39 +0000255 break;
256 case GL_DOUBLE:
Brian Paulc5b1e812003-10-22 22:59:07 +0000257 elementSize = size * sizeof(GLdouble);
jtgafb833d1999-08-19 00:55:39 +0000258 break;
Dave Airliecfe884e2010-01-18 16:29:31 +1000259 case GL_HALF_FLOAT:
260 elementSize = size * sizeof(GLhalfARB);
261 break;
Brian Paul394c1d12008-06-20 11:32:22 -0600262#if FEATURE_fixedpt
263 case GL_FIXED:
264 elementSize = size * sizeof(GLfixed);
265 break;
266#endif
jtgafb833d1999-08-19 00:55:39 +0000267 default:
Brian Paul2b82bc92009-08-04 14:53:24 -0600268 _mesa_error( ctx, GL_INVALID_ENUM, "glColorPointer(type=%s)",
269 _mesa_lookup_enum_by_nr(type));
jtgafb833d1999-08-19 00:55:39 +0000270 return;
jtgafb833d1999-08-19 00:55:39 +0000271 }
Brian Paul2edd1802002-01-11 17:25:35 +0000272
Brian Paulf549f4c2009-11-12 23:04:26 -0700273 update_array(ctx, &ctx->Array.ArrayObj->Color, _NEW_ARRAY_COLOR0,
274 elementSize, size, type, format, stride, GL_TRUE, ptr);
jtgafb833d1999-08-19 00:55:39 +0000275}
276
277
Kendall Bennettc40d1dd2003-10-21 22:22:17 +0000278void GLAPIENTRY
Keith Whitwellfe5d67d2000-10-27 16:44:40 +0000279_mesa_FogCoordPointerEXT(GLenum type, GLsizei stride, const GLvoid *ptr)
280{
Brian Paulc5b1e812003-10-22 22:59:07 +0000281 GLint elementSize;
Keith Whitwellfe5d67d2000-10-27 16:44:40 +0000282 GET_CURRENT_CONTEXT(ctx);
Keith Whitwellcab974c2000-12-26 05:09:27 +0000283 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +0000284
Brian Paul2edd1802002-01-11 17:25:35 +0000285 if (stride < 0) {
Brian Paul08836342001-03-03 20:33:27 +0000286 _mesa_error( ctx, GL_INVALID_VALUE, "glFogCoordPointer(stride)" );
Keith Whitwellfe5d67d2000-10-27 16:44:40 +0000287 return;
288 }
289
Brian Paul2edd1802002-01-11 17:25:35 +0000290 switch (type) {
Keith Whitwellfe5d67d2000-10-27 16:44:40 +0000291 case GL_FLOAT:
Brian Paulc5b1e812003-10-22 22:59:07 +0000292 elementSize = sizeof(GLfloat);
Keith Whitwellfe5d67d2000-10-27 16:44:40 +0000293 break;
294 case GL_DOUBLE:
Brian Paulc5b1e812003-10-22 22:59:07 +0000295 elementSize = sizeof(GLdouble);
Keith Whitwellfe5d67d2000-10-27 16:44:40 +0000296 break;
Dave Airliecfe884e2010-01-18 16:29:31 +1000297 case GL_HALF_FLOAT:
298 elementSize = sizeof(GLhalfARB);
299 break;
Keith Whitwellfe5d67d2000-10-27 16:44:40 +0000300 default:
Brian Paul08836342001-03-03 20:33:27 +0000301 _mesa_error( ctx, GL_INVALID_ENUM, "glFogCoordPointer(type)" );
Keith Whitwellfe5d67d2000-10-27 16:44:40 +0000302 return;
Keith Whitwellfe5d67d2000-10-27 16:44:40 +0000303 }
Brian Paul2edd1802002-01-11 17:25:35 +0000304
Brian Paulf549f4c2009-11-12 23:04:26 -0700305 update_array(ctx, &ctx->Array.ArrayObj->FogCoord, _NEW_ARRAY_FOGCOORD,
306 elementSize, 1, type, GL_RGBA, stride, GL_FALSE, ptr);
Keith Whitwellfe5d67d2000-10-27 16:44:40 +0000307}
308
309
Kendall Bennettc40d1dd2003-10-21 22:22:17 +0000310void GLAPIENTRY
Brian Paulfbd8f211999-11-11 01:22:25 +0000311_mesa_IndexPointer(GLenum type, GLsizei stride, const GLvoid *ptr)
jtgafb833d1999-08-19 00:55:39 +0000312{
Brian Paulc5b1e812003-10-22 22:59:07 +0000313 GLsizei elementSize;
Brian Paulfbd8f211999-11-11 01:22:25 +0000314 GET_CURRENT_CONTEXT(ctx);
Keith Whitwellcab974c2000-12-26 05:09:27 +0000315 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +0000316
Brian Paul2edd1802002-01-11 17:25:35 +0000317 if (stride < 0) {
Brian Paul08836342001-03-03 20:33:27 +0000318 _mesa_error( ctx, GL_INVALID_VALUE, "glIndexPointer(stride)" );
jtgafb833d1999-08-19 00:55:39 +0000319 return;
320 }
321
Brian Paul2edd1802002-01-11 17:25:35 +0000322 switch (type) {
jtgafb833d1999-08-19 00:55:39 +0000323 case GL_UNSIGNED_BYTE:
Brian Paulc5b1e812003-10-22 22:59:07 +0000324 elementSize = sizeof(GLubyte);
jtgafb833d1999-08-19 00:55:39 +0000325 break;
326 case GL_SHORT:
Brian Paulc5b1e812003-10-22 22:59:07 +0000327 elementSize = sizeof(GLshort);
jtgafb833d1999-08-19 00:55:39 +0000328 break;
329 case GL_INT:
Brian Paulc5b1e812003-10-22 22:59:07 +0000330 elementSize = sizeof(GLint);
jtgafb833d1999-08-19 00:55:39 +0000331 break;
332 case GL_FLOAT:
Brian Paulc5b1e812003-10-22 22:59:07 +0000333 elementSize = sizeof(GLfloat);
jtgafb833d1999-08-19 00:55:39 +0000334 break;
335 case GL_DOUBLE:
Brian Paulc5b1e812003-10-22 22:59:07 +0000336 elementSize = sizeof(GLdouble);
jtgafb833d1999-08-19 00:55:39 +0000337 break;
338 default:
Brian Paul08836342001-03-03 20:33:27 +0000339 _mesa_error( ctx, GL_INVALID_ENUM, "glIndexPointer(type)" );
jtgafb833d1999-08-19 00:55:39 +0000340 return;
jtgafb833d1999-08-19 00:55:39 +0000341 }
Brian Paul2edd1802002-01-11 17:25:35 +0000342
Brian Paulf549f4c2009-11-12 23:04:26 -0700343 update_array(ctx, &ctx->Array.ArrayObj->Index, _NEW_ARRAY_INDEX,
344 elementSize, 1, type, GL_RGBA, stride, GL_FALSE, ptr);
jtgafb833d1999-08-19 00:55:39 +0000345}
346
347
Kendall Bennettc40d1dd2003-10-21 22:22:17 +0000348void GLAPIENTRY
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +0000349_mesa_SecondaryColorPointerEXT(GLint size, GLenum type,
Keith Whitwellfe5d67d2000-10-27 16:44:40 +0000350 GLsizei stride, const GLvoid *ptr)
351{
Brian Paulc5b1e812003-10-22 22:59:07 +0000352 GLsizei elementSize;
Brian Paul76d27a62009-01-23 11:24:31 -0700353 GLenum format;
Keith Whitwellfe5d67d2000-10-27 16:44:40 +0000354 GET_CURRENT_CONTEXT(ctx);
Keith Whitwellcab974c2000-12-26 05:09:27 +0000355 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
Keith Whitwellfe5d67d2000-10-27 16:44:40 +0000356
Keith Whitwellfe5d67d2000-10-27 16:44:40 +0000357 if (size != 3 && size != 4) {
Brian Paul76d27a62009-01-23 11:24:31 -0700358 if (!ctx->Extensions.EXT_vertex_array_bgra || size != GL_BGRA) {
359 _mesa_error(ctx, GL_INVALID_VALUE, "glSecondaryColorPointer(size)");
360 return;
361 }
Keith Whitwellfe5d67d2000-10-27 16:44:40 +0000362 }
Brian Paul2edd1802002-01-11 17:25:35 +0000363 if (stride < 0) {
364 _mesa_error( ctx, GL_INVALID_VALUE, "glSecondaryColorPointer(stride)" );
Keith Whitwellfe5d67d2000-10-27 16:44:40 +0000365 return;
366 }
367
368 if (MESA_VERBOSE&(VERBOSE_VARRAY|VERBOSE_API))
Brian Paul4753d602002-06-15 02:38:15 +0000369 _mesa_debug(ctx, "glSecondaryColorPointer( sz %d type %s stride %d )\n",
Brian Pauld09a1d82002-06-13 04:49:17 +0000370 size, _mesa_lookup_enum_by_nr( type ), stride);
Keith Whitwellfe5d67d2000-10-27 16:44:40 +0000371
Brian Paul76d27a62009-01-23 11:24:31 -0700372 if (size == GL_BGRA) {
373 if (type != GL_UNSIGNED_BYTE) {
374 _mesa_error(ctx, GL_INVALID_VALUE, "glColorPointer(GL_BGRA/GLubyte)");
375 return;
376 }
377 format = GL_BGRA;
378 size = 4;
379 }
380 else {
381 format = GL_RGBA;
382 }
383
Brian Paul2edd1802002-01-11 17:25:35 +0000384 switch (type) {
Keith Whitwellfe5d67d2000-10-27 16:44:40 +0000385 case GL_BYTE:
Brian Paulc5b1e812003-10-22 22:59:07 +0000386 elementSize = size * sizeof(GLbyte);
Keith Whitwellfe5d67d2000-10-27 16:44:40 +0000387 break;
388 case GL_UNSIGNED_BYTE:
Brian Paulc5b1e812003-10-22 22:59:07 +0000389 elementSize = size * sizeof(GLubyte);
Keith Whitwellfe5d67d2000-10-27 16:44:40 +0000390 break;
391 case GL_SHORT:
Brian Paulc5b1e812003-10-22 22:59:07 +0000392 elementSize = size * sizeof(GLshort);
Keith Whitwellfe5d67d2000-10-27 16:44:40 +0000393 break;
394 case GL_UNSIGNED_SHORT:
Brian Paulc5b1e812003-10-22 22:59:07 +0000395 elementSize = size * sizeof(GLushort);
Keith Whitwellfe5d67d2000-10-27 16:44:40 +0000396 break;
397 case GL_INT:
Brian Paulc5b1e812003-10-22 22:59:07 +0000398 elementSize = size * sizeof(GLint);
Keith Whitwellfe5d67d2000-10-27 16:44:40 +0000399 break;
400 case GL_UNSIGNED_INT:
Brian Paulc5b1e812003-10-22 22:59:07 +0000401 elementSize = size * sizeof(GLuint);
Keith Whitwellfe5d67d2000-10-27 16:44:40 +0000402 break;
403 case GL_FLOAT:
Brian Paulc5b1e812003-10-22 22:59:07 +0000404 elementSize = size * sizeof(GLfloat);
Keith Whitwellfe5d67d2000-10-27 16:44:40 +0000405 break;
406 case GL_DOUBLE:
Brian Paulc5b1e812003-10-22 22:59:07 +0000407 elementSize = size * sizeof(GLdouble);
Keith Whitwellfe5d67d2000-10-27 16:44:40 +0000408 break;
Dave Airliecfe884e2010-01-18 16:29:31 +1000409 case GL_HALF_FLOAT:
410 elementSize = size * sizeof(GLhalfARB);
411 break;
Keith Whitwellfe5d67d2000-10-27 16:44:40 +0000412 default:
Brian Paul2b82bc92009-08-04 14:53:24 -0600413 _mesa_error( ctx, GL_INVALID_ENUM, "glSecondaryColorPointer(type=%s)",
414 _mesa_lookup_enum_by_nr(type));
Keith Whitwellfe5d67d2000-10-27 16:44:40 +0000415 return;
Keith Whitwellfe5d67d2000-10-27 16:44:40 +0000416 }
Brian Paul2edd1802002-01-11 17:25:35 +0000417
Brian Paulf549f4c2009-11-12 23:04:26 -0700418 update_array(ctx, &ctx->Array.ArrayObj->SecondaryColor, _NEW_ARRAY_COLOR1,
419 elementSize, size, type, format, stride, GL_TRUE, ptr);
Keith Whitwellfe5d67d2000-10-27 16:44:40 +0000420}
421
422
Kendall Bennettc40d1dd2003-10-21 22:22:17 +0000423void GLAPIENTRY
Brian Paul2edd1802002-01-11 17:25:35 +0000424_mesa_TexCoordPointer(GLint size, GLenum type, GLsizei stride,
425 const GLvoid *ptr)
jtgafb833d1999-08-19 00:55:39 +0000426{
Brian Paulc5b1e812003-10-22 22:59:07 +0000427 GLint elementSize;
Brian Paulfbd8f211999-11-11 01:22:25 +0000428 GET_CURRENT_CONTEXT(ctx);
Brian Paulc5b1e812003-10-22 22:59:07 +0000429 const GLuint unit = ctx->Array.ActiveTexture;
Keith Whitwellcab974c2000-12-26 05:09:27 +0000430 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
jtgafb833d1999-08-19 00:55:39 +0000431
Brian Paul2edd1802002-01-11 17:25:35 +0000432 if (size < 1 || size > 4) {
Brian Paul08836342001-03-03 20:33:27 +0000433 _mesa_error( ctx, GL_INVALID_VALUE, "glTexCoordPointer(size)" );
jtgafb833d1999-08-19 00:55:39 +0000434 return;
435 }
Brian Paul2edd1802002-01-11 17:25:35 +0000436 if (stride < 0) {
Brian Paul08836342001-03-03 20:33:27 +0000437 _mesa_error( ctx, GL_INVALID_VALUE, "glTexCoordPointer(stride)" );
jtgafb833d1999-08-19 00:55:39 +0000438 return;
439 }
440
441 if (MESA_VERBOSE&(VERBOSE_VARRAY|VERBOSE_API))
Brian Paul4753d602002-06-15 02:38:15 +0000442 _mesa_debug(ctx, "glTexCoordPointer(unit %u sz %d type %s stride %d)\n",
Brian Paulc5b1e812003-10-22 22:59:07 +0000443 unit, size, _mesa_lookup_enum_by_nr( type ), stride);
jtgafb833d1999-08-19 00:55:39 +0000444
Brian Paul2edd1802002-01-11 17:25:35 +0000445 /* always need to check that <type> is legal */
446 switch (type) {
jtgafb833d1999-08-19 00:55:39 +0000447 case GL_SHORT:
Brian Paulc5b1e812003-10-22 22:59:07 +0000448 elementSize = size * sizeof(GLshort);
jtgafb833d1999-08-19 00:55:39 +0000449 break;
450 case GL_INT:
Brian Paulc5b1e812003-10-22 22:59:07 +0000451 elementSize = size * sizeof(GLint);
jtgafb833d1999-08-19 00:55:39 +0000452 break;
453 case GL_FLOAT:
Brian Paulc5b1e812003-10-22 22:59:07 +0000454 elementSize = size * sizeof(GLfloat);
jtgafb833d1999-08-19 00:55:39 +0000455 break;
456 case GL_DOUBLE:
Brian Paulc5b1e812003-10-22 22:59:07 +0000457 elementSize = size * sizeof(GLdouble);
jtgafb833d1999-08-19 00:55:39 +0000458 break;
Dave Airliecfe884e2010-01-18 16:29:31 +1000459 case GL_HALF_FLOAT:
460 elementSize = size * sizeof(GLhalfARB);
461 break;
Brian Paul394c1d12008-06-20 11:32:22 -0600462#if FEATURE_fixedpt
463 case GL_FIXED:
464 elementSize = size * sizeof(GLfixed);
465 break;
466#endif
Brian Pauld17485f2008-06-20 11:49:25 -0600467#if FEATURE_vertex_array_byte
468 case GL_BYTE:
469 elementSize = size * sizeof(GLbyte);
470 break;
471#endif
jtgafb833d1999-08-19 00:55:39 +0000472 default:
Brian Paul2b82bc92009-08-04 14:53:24 -0600473 _mesa_error( ctx, GL_INVALID_ENUM, "glTexCoordPointer(type=%s)",
474 _mesa_lookup_enum_by_nr(type));
jtgafb833d1999-08-19 00:55:39 +0000475 return;
jtgafb833d1999-08-19 00:55:39 +0000476 }
Brian Paul2edd1802002-01-11 17:25:35 +0000477
Brian Paul89c8ff32010-02-03 13:24:43 -0700478 ASSERT(unit < Elements(ctx->Array.ArrayObj->TexCoord));
479
Brian Paulf549f4c2009-11-12 23:04:26 -0700480 update_array(ctx, &ctx->Array.ArrayObj->TexCoord[unit],
481 _NEW_ARRAY_TEXCOORD(unit),
482 elementSize, size, type, GL_RGBA, stride, GL_FALSE, ptr);
jtgafb833d1999-08-19 00:55:39 +0000483}
484
485
Kendall Bennettc40d1dd2003-10-21 22:22:17 +0000486void GLAPIENTRY
Brian Paulc5b1e812003-10-22 22:59:07 +0000487_mesa_EdgeFlagPointer(GLsizei stride, const GLvoid *ptr)
jtgafb833d1999-08-19 00:55:39 +0000488{
Brian Paulfbd8f211999-11-11 01:22:25 +0000489 GET_CURRENT_CONTEXT(ctx);
Keith Whitwellcab974c2000-12-26 05:09:27 +0000490 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
jtgafb833d1999-08-19 00:55:39 +0000491
Brian Paulc5b1e812003-10-22 22:59:07 +0000492 if (stride < 0) {
Brian Paul08836342001-03-03 20:33:27 +0000493 _mesa_error( ctx, GL_INVALID_VALUE, "glEdgeFlagPointer(stride)" );
jtgafb833d1999-08-19 00:55:39 +0000494 return;
495 }
Brian Paulc5b1e812003-10-22 22:59:07 +0000496
Brian Paulf549f4c2009-11-12 23:04:26 -0700497 update_array(ctx, &ctx->Array.ArrayObj->EdgeFlag, _NEW_ARRAY_EDGEFLAG,
498 sizeof(GLboolean), 1, GL_UNSIGNED_BYTE, GL_RGBA,
499 stride, GL_FALSE, ptr);
jtgafb833d1999-08-19 00:55:39 +0000500}
501
502
Brian Paul1cf2c8a2008-06-25 08:45:14 -0600503void GLAPIENTRY
504_mesa_PointSizePointer(GLenum type, GLsizei stride, const GLvoid *ptr)
505{
506 GLsizei elementSize;
507 GET_CURRENT_CONTEXT(ctx);
508 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
509
510 if (stride < 0) {
511 _mesa_error( ctx, GL_INVALID_VALUE, "glPointSizePointer(stride)" );
512 return;
513 }
514
515 switch (type) {
516 case GL_FLOAT:
517 elementSize = sizeof(GLfloat);
518 break;
519#if FEATURE_fixedpt
520 case GL_FIXED:
521 elementSize = sizeof(GLfixed);
522 break;
523#endif
524 default:
525 _mesa_error( ctx, GL_INVALID_ENUM, "glPointSizePointer(type)" );
526 return;
527 }
528
529 update_array(ctx, &ctx->Array.ArrayObj->PointSize, _NEW_ARRAY_POINT_SIZE,
Brian Paul76d27a62009-01-23 11:24:31 -0700530 elementSize, 1, type, GL_RGBA, stride, GL_FALSE, ptr);
Brian Paul1cf2c8a2008-06-25 08:45:14 -0600531}
532
533
Brian Paul148a2842003-09-17 03:40:11 +0000534#if FEATURE_NV_vertex_program
Brian Paula554d7c2009-05-21 15:55:33 -0600535/**
536 * Set a vertex attribute array.
537 * Note that these arrays DO alias the conventional GL vertex arrays
538 * (position, normal, color, fog, texcoord, etc).
539 * The generic attribute slots at #16 and above are not touched.
540 */
Kendall Bennettc40d1dd2003-10-21 22:22:17 +0000541void GLAPIENTRY
Brian Paul92f97852003-05-01 22:44:02 +0000542_mesa_VertexAttribPointerNV(GLuint index, GLint size, GLenum type,
543 GLsizei stride, const GLvoid *ptr)
Brian Paul2edd1802002-01-11 17:25:35 +0000544{
Markus Amsler29fbf722008-03-09 17:53:22 -0600545 GLboolean normalized = GL_FALSE;
Brian Paulc5b1e812003-10-22 22:59:07 +0000546 GLsizei elementSize;
Maciej Cencora4adb1902009-06-08 07:23:56 -0600547 GLenum format;
Brian Paul2edd1802002-01-11 17:25:35 +0000548 GET_CURRENT_CONTEXT(ctx);
549 ASSERT_OUTSIDE_BEGIN_END(ctx);
jtgafb833d1999-08-19 00:55:39 +0000550
Brian Pauld2a74d72009-05-21 17:03:21 -0600551 if (index >= MAX_NV_VERTEX_PROGRAM_INPUTS) {
Brian Paul2edd1802002-01-11 17:25:35 +0000552 _mesa_error(ctx, GL_INVALID_VALUE, "glVertexAttribPointerNV(index)");
553 return;
554 }
555
556 if (size < 1 || size > 4) {
557 _mesa_error(ctx, GL_INVALID_VALUE, "glVertexAttribPointerNV(size)");
558 return;
559 }
560
561 if (stride < 0) {
562 _mesa_error(ctx, GL_INVALID_VALUE, "glVertexAttribPointerNV(stride)");
563 return;
564 }
565
566 if (type == GL_UNSIGNED_BYTE && size != 4) {
567 _mesa_error(ctx, GL_INVALID_VALUE, "glVertexAttribPointerNV(size!=4)");
568 return;
569 }
570
Maciej Cencora4adb1902009-06-08 07:23:56 -0600571 if (size == GL_BGRA) {
572 if (type != GL_UNSIGNED_BYTE) {
573 _mesa_error(ctx, GL_INVALID_VALUE,
574 "glVertexAttribPointerNV(GL_BGRA/type)");
575 return;
576 }
577
578 format = GL_BGRA;
579 size = 4;
580 normalized = GL_TRUE;
581 }
582 else {
583 format = GL_RGBA;
584 }
585
Brian Paul2edd1802002-01-11 17:25:35 +0000586 /* check for valid 'type' and compute StrideB right away */
587 switch (type) {
588 case GL_UNSIGNED_BYTE:
Markus Amsler29fbf722008-03-09 17:53:22 -0600589 normalized = GL_TRUE;
Brian Paulc5b1e812003-10-22 22:59:07 +0000590 elementSize = size * sizeof(GLubyte);
Brian Paul2edd1802002-01-11 17:25:35 +0000591 break;
592 case GL_SHORT:
Brian Paulc5b1e812003-10-22 22:59:07 +0000593 elementSize = size * sizeof(GLshort);
Brian Paul2edd1802002-01-11 17:25:35 +0000594 break;
595 case GL_FLOAT:
Brian Paulc5b1e812003-10-22 22:59:07 +0000596 elementSize = size * sizeof(GLfloat);
Brian Paul2edd1802002-01-11 17:25:35 +0000597 break;
598 case GL_DOUBLE:
Brian Paulc5b1e812003-10-22 22:59:07 +0000599 elementSize = size * sizeof(GLdouble);
Brian Paul2edd1802002-01-11 17:25:35 +0000600 break;
601 default:
Brian Paul2b82bc92009-08-04 14:53:24 -0600602 _mesa_error( ctx, GL_INVALID_ENUM, "glVertexAttribPointerNV(type=%s)",
603 _mesa_lookup_enum_by_nr(type));
Brian Paul2edd1802002-01-11 17:25:35 +0000604 return;
605 }
606
Brian Paulf549f4c2009-11-12 23:04:26 -0700607 update_array(ctx, &ctx->Array.ArrayObj->VertexAttrib[index],
608 _NEW_ARRAY_ATTRIB(index),
609 elementSize, size, type, format, stride, normalized, ptr);
Brian Paul2edd1802002-01-11 17:25:35 +0000610}
Brian Paul148a2842003-09-17 03:40:11 +0000611#endif
jtgafb833d1999-08-19 00:55:39 +0000612
Brian Paul1f0e2132000-06-12 15:30:51 +0000613
Brian Paul148a2842003-09-17 03:40:11 +0000614#if FEATURE_ARB_vertex_program
Brian Paula554d7c2009-05-21 15:55:33 -0600615/**
616 * Set a generic vertex attribute array.
617 * Note that these arrays DO NOT alias the conventional GL vertex arrays
618 * (position, normal, color, fog, texcoord, etc).
619 */
Kendall Bennettc40d1dd2003-10-21 22:22:17 +0000620void GLAPIENTRY
Brian Paul92f97852003-05-01 22:44:02 +0000621_mesa_VertexAttribPointerARB(GLuint index, GLint size, GLenum type,
622 GLboolean normalized,
623 GLsizei stride, const GLvoid *ptr)
624{
Brian Paulc5b1e812003-10-22 22:59:07 +0000625 GLsizei elementSize;
Brian Paul76d27a62009-01-23 11:24:31 -0700626 GLenum format;
Brian Paul92f97852003-05-01 22:44:02 +0000627 GET_CURRENT_CONTEXT(ctx);
628 ASSERT_OUTSIDE_BEGIN_END(ctx);
629
Brian Paul05051032005-11-01 04:36:33 +0000630 if (index >= ctx->Const.VertexProgram.MaxAttribs) {
Brian Paul92f97852003-05-01 22:44:02 +0000631 _mesa_error(ctx, GL_INVALID_VALUE, "glVertexAttribPointerARB(index)");
632 return;
633 }
634
635 if (size < 1 || size > 4) {
Brian Paul76d27a62009-01-23 11:24:31 -0700636 if (!ctx->Extensions.EXT_vertex_array_bgra || size != GL_BGRA) {
637 _mesa_error(ctx, GL_INVALID_VALUE, "glVertexAttribPointerARB(size)");
638 return;
639 }
Brian Paul92f97852003-05-01 22:44:02 +0000640 }
641
642 if (stride < 0) {
643 _mesa_error(ctx, GL_INVALID_VALUE, "glVertexAttribPointerARB(stride)");
644 return;
645 }
646
Brian Paul76d27a62009-01-23 11:24:31 -0700647 if (size == GL_BGRA) {
648 if (type != GL_UNSIGNED_BYTE) {
649 _mesa_error(ctx, GL_INVALID_VALUE,
650 "glVertexAttribPointerARB(GL_BGRA/type)");
651 return;
652 }
Maciej Cencora4adb1902009-06-08 07:23:56 -0600653 if (normalized != GL_TRUE) {
654 _mesa_error(ctx, GL_INVALID_VALUE,
655 "glVertexAttribPointerARB(GL_BGRA/normalized)");
656 return;
657 }
658
Brian Paul76d27a62009-01-23 11:24:31 -0700659 format = GL_BGRA;
660 size = 4;
Brian Paul76d27a62009-01-23 11:24:31 -0700661 }
662 else {
663 format = GL_RGBA;
664 }
665
Brian Paul92f97852003-05-01 22:44:02 +0000666 /* check for valid 'type' and compute StrideB right away */
Brian Paul196a90b2003-06-11 18:47:51 +0000667 /* NOTE: more types are supported here than in the NV extension */
Brian Paul92f97852003-05-01 22:44:02 +0000668 switch (type) {
Brian Paul196a90b2003-06-11 18:47:51 +0000669 case GL_BYTE:
Brian Paulc5b1e812003-10-22 22:59:07 +0000670 elementSize = size * sizeof(GLbyte);
Brian Paul196a90b2003-06-11 18:47:51 +0000671 break;
Brian Paul92f97852003-05-01 22:44:02 +0000672 case GL_UNSIGNED_BYTE:
Brian Paulc5b1e812003-10-22 22:59:07 +0000673 elementSize = size * sizeof(GLubyte);
Brian Paul92f97852003-05-01 22:44:02 +0000674 break;
675 case GL_SHORT:
Brian Paulc5b1e812003-10-22 22:59:07 +0000676 elementSize = size * sizeof(GLshort);
Brian Paul92f97852003-05-01 22:44:02 +0000677 break;
Brian Paul196a90b2003-06-11 18:47:51 +0000678 case GL_UNSIGNED_SHORT:
Brian Paulc5b1e812003-10-22 22:59:07 +0000679 elementSize = size * sizeof(GLushort);
Brian Paul196a90b2003-06-11 18:47:51 +0000680 break;
681 case GL_INT:
Brian Paulc5b1e812003-10-22 22:59:07 +0000682 elementSize = size * sizeof(GLint);
Brian Paul196a90b2003-06-11 18:47:51 +0000683 break;
684 case GL_UNSIGNED_INT:
Brian Paulc5b1e812003-10-22 22:59:07 +0000685 elementSize = size * sizeof(GLuint);
Brian Paul196a90b2003-06-11 18:47:51 +0000686 break;
Brian Paul92f97852003-05-01 22:44:02 +0000687 case GL_FLOAT:
Brian Paulc5b1e812003-10-22 22:59:07 +0000688 elementSize = size * sizeof(GLfloat);
Brian Paul92f97852003-05-01 22:44:02 +0000689 break;
690 case GL_DOUBLE:
Brian Paulc5b1e812003-10-22 22:59:07 +0000691 elementSize = size * sizeof(GLdouble);
Brian Paul92f97852003-05-01 22:44:02 +0000692 break;
Dave Airliecfe884e2010-01-18 16:29:31 +1000693 case GL_HALF_FLOAT:
694 elementSize = size * sizeof(GLhalfARB);
695 break;
Brian Paul48cba702008-07-03 14:12:27 -0600696#if FEATURE_fixedpt
697 case GL_FIXED:
698 elementSize = size * sizeof(GLfixed);
699 break;
700#endif
Brian Paul92f97852003-05-01 22:44:02 +0000701 default:
702 _mesa_error( ctx, GL_INVALID_ENUM, "glVertexAttribPointerARB(type)" );
703 return;
704 }
705
Brian Paulf549f4c2009-11-12 23:04:26 -0700706 update_array(ctx, &ctx->Array.ArrayObj->VertexAttrib[index],
707 _NEW_ARRAY_ATTRIB(index),
708 elementSize, size, type, format, stride, normalized, ptr);
Brian Paul92f97852003-05-01 22:44:02 +0000709}
Brian Paul148a2842003-09-17 03:40:11 +0000710#endif
Brian Paul92f97852003-05-01 22:44:02 +0000711
712
Kendall Bennettc40d1dd2003-10-21 22:22:17 +0000713void GLAPIENTRY
Brian Paul1f0e2132000-06-12 15:30:51 +0000714_mesa_VertexPointerEXT(GLint size, GLenum type, GLsizei stride,
715 GLsizei count, const GLvoid *ptr)
716{
717 (void) count;
718 _mesa_VertexPointer(size, type, stride, ptr);
719}
720
721
Kendall Bennettc40d1dd2003-10-21 22:22:17 +0000722void GLAPIENTRY
Brian Paul1f0e2132000-06-12 15:30:51 +0000723_mesa_NormalPointerEXT(GLenum type, GLsizei stride, GLsizei count,
724 const GLvoid *ptr)
725{
726 (void) count;
727 _mesa_NormalPointer(type, stride, ptr);
728}
729
730
Kendall Bennettc40d1dd2003-10-21 22:22:17 +0000731void GLAPIENTRY
Brian Paul1f0e2132000-06-12 15:30:51 +0000732_mesa_ColorPointerEXT(GLint size, GLenum type, GLsizei stride, GLsizei count,
733 const GLvoid *ptr)
734{
735 (void) count;
736 _mesa_ColorPointer(size, type, stride, ptr);
737}
738
739
Kendall Bennettc40d1dd2003-10-21 22:22:17 +0000740void GLAPIENTRY
Brian Paul1f0e2132000-06-12 15:30:51 +0000741_mesa_IndexPointerEXT(GLenum type, GLsizei stride, GLsizei count,
742 const GLvoid *ptr)
743{
744 (void) count;
745 _mesa_IndexPointer(type, stride, ptr);
746}
747
748
Kendall Bennettc40d1dd2003-10-21 22:22:17 +0000749void GLAPIENTRY
Brian Paul1f0e2132000-06-12 15:30:51 +0000750_mesa_TexCoordPointerEXT(GLint size, GLenum type, GLsizei stride,
751 GLsizei count, const GLvoid *ptr)
752{
753 (void) count;
754 _mesa_TexCoordPointer(size, type, stride, ptr);
755}
756
757
Kendall Bennettc40d1dd2003-10-21 22:22:17 +0000758void GLAPIENTRY
Brian Paul1f0e2132000-06-12 15:30:51 +0000759_mesa_EdgeFlagPointerEXT(GLsizei stride, GLsizei count, const GLboolean *ptr)
760{
761 (void) count;
762 _mesa_EdgeFlagPointer(stride, ptr);
763}
764
765
Kendall Bennettc40d1dd2003-10-21 22:22:17 +0000766void GLAPIENTRY
Brian Paulfbd8f211999-11-11 01:22:25 +0000767_mesa_InterleavedArrays(GLenum format, GLsizei stride, const GLvoid *pointer)
jtgafb833d1999-08-19 00:55:39 +0000768{
Brian Paulfbd8f211999-11-11 01:22:25 +0000769 GET_CURRENT_CONTEXT(ctx);
jtgafb833d1999-08-19 00:55:39 +0000770 GLboolean tflag, cflag, nflag; /* enable/disable flags */
771 GLint tcomps, ccomps, vcomps; /* components per texcoord, color, vertex */
Keith Whitwellf4b02d12001-01-05 05:31:42 +0000772 GLenum ctype = 0; /* color type */
773 GLint coffset = 0, noffset = 0, voffset;/* color, normal, vertex offsets */
Brian Paul4a3110f2003-12-12 18:40:02 +0000774 const GLint toffset = 0; /* always zero */
jtgafb833d1999-08-19 00:55:39 +0000775 GLint defstride; /* default stride */
776 GLint c, f;
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +0000777
Keith Whitwellcab974c2000-12-26 05:09:27 +0000778 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
779
jtgafb833d1999-08-19 00:55:39 +0000780 f = sizeof(GLfloat);
Brian Paulc5b1e812003-10-22 22:59:07 +0000781 c = f * ((4 * sizeof(GLubyte) + (f - 1)) / f);
jtgafb833d1999-08-19 00:55:39 +0000782
Brian Paulc5b1e812003-10-22 22:59:07 +0000783 if (stride < 0) {
Brian Paul08836342001-03-03 20:33:27 +0000784 _mesa_error( ctx, GL_INVALID_VALUE, "glInterleavedArrays(stride)" );
jtgafb833d1999-08-19 00:55:39 +0000785 return;
786 }
787
788 switch (format) {
789 case GL_V2F:
790 tflag = GL_FALSE; cflag = GL_FALSE; nflag = GL_FALSE;
791 tcomps = 0; ccomps = 0; vcomps = 2;
792 voffset = 0;
793 defstride = 2*f;
794 break;
795 case GL_V3F:
796 tflag = GL_FALSE; cflag = GL_FALSE; nflag = GL_FALSE;
797 tcomps = 0; ccomps = 0; vcomps = 3;
798 voffset = 0;
799 defstride = 3*f;
800 break;
801 case GL_C4UB_V2F:
802 tflag = GL_FALSE; cflag = GL_TRUE; nflag = GL_FALSE;
803 tcomps = 0; ccomps = 4; vcomps = 2;
804 ctype = GL_UNSIGNED_BYTE;
805 coffset = 0;
806 voffset = c;
807 defstride = c + 2*f;
808 break;
809 case GL_C4UB_V3F:
810 tflag = GL_FALSE; cflag = GL_TRUE; nflag = GL_FALSE;
811 tcomps = 0; ccomps = 4; vcomps = 3;
812 ctype = GL_UNSIGNED_BYTE;
813 coffset = 0;
814 voffset = c;
815 defstride = c + 3*f;
816 break;
817 case GL_C3F_V3F:
818 tflag = GL_FALSE; cflag = GL_TRUE; nflag = GL_FALSE;
819 tcomps = 0; ccomps = 3; vcomps = 3;
820 ctype = GL_FLOAT;
821 coffset = 0;
822 voffset = 3*f;
823 defstride = 6*f;
824 break;
825 case GL_N3F_V3F:
826 tflag = GL_FALSE; cflag = GL_FALSE; nflag = GL_TRUE;
827 tcomps = 0; ccomps = 0; vcomps = 3;
828 noffset = 0;
829 voffset = 3*f;
830 defstride = 6*f;
831 break;
832 case GL_C4F_N3F_V3F:
833 tflag = GL_FALSE; cflag = GL_TRUE; nflag = GL_TRUE;
834 tcomps = 0; ccomps = 4; vcomps = 3;
835 ctype = GL_FLOAT;
836 coffset = 0;
837 noffset = 4*f;
838 voffset = 7*f;
839 defstride = 10*f;
840 break;
841 case GL_T2F_V3F:
842 tflag = GL_TRUE; cflag = GL_FALSE; nflag = GL_FALSE;
843 tcomps = 2; ccomps = 0; vcomps = 3;
844 voffset = 2*f;
845 defstride = 5*f;
846 break;
847 case GL_T4F_V4F:
848 tflag = GL_TRUE; cflag = GL_FALSE; nflag = GL_FALSE;
849 tcomps = 4; ccomps = 0; vcomps = 4;
850 voffset = 4*f;
851 defstride = 8*f;
852 break;
853 case GL_T2F_C4UB_V3F:
854 tflag = GL_TRUE; cflag = GL_TRUE; nflag = GL_FALSE;
855 tcomps = 2; ccomps = 4; vcomps = 3;
856 ctype = GL_UNSIGNED_BYTE;
857 coffset = 2*f;
858 voffset = c+2*f;
859 defstride = c+5*f;
860 break;
861 case GL_T2F_C3F_V3F:
862 tflag = GL_TRUE; cflag = GL_TRUE; nflag = GL_FALSE;
863 tcomps = 2; ccomps = 3; vcomps = 3;
864 ctype = GL_FLOAT;
865 coffset = 2*f;
866 voffset = 5*f;
867 defstride = 8*f;
868 break;
869 case GL_T2F_N3F_V3F:
870 tflag = GL_TRUE; cflag = GL_FALSE; nflag = GL_TRUE;
871 tcomps = 2; ccomps = 0; vcomps = 3;
872 noffset = 2*f;
873 voffset = 5*f;
874 defstride = 8*f;
875 break;
876 case GL_T2F_C4F_N3F_V3F:
877 tflag = GL_TRUE; cflag = GL_TRUE; nflag = GL_TRUE;
878 tcomps = 2; ccomps = 4; vcomps = 3;
879 ctype = GL_FLOAT;
880 coffset = 2*f;
881 noffset = 6*f;
882 voffset = 9*f;
883 defstride = 12*f;
884 break;
885 case GL_T4F_C4F_N3F_V4F:
886 tflag = GL_TRUE; cflag = GL_TRUE; nflag = GL_TRUE;
887 tcomps = 4; ccomps = 4; vcomps = 4;
888 ctype = GL_FLOAT;
889 coffset = 4*f;
890 noffset = 8*f;
891 voffset = 11*f;
892 defstride = 15*f;
893 break;
894 default:
Brian Paul08836342001-03-03 20:33:27 +0000895 _mesa_error( ctx, GL_INVALID_ENUM, "glInterleavedArrays(format)" );
jtgafb833d1999-08-19 00:55:39 +0000896 return;
897 }
898
899 if (stride==0) {
900 stride = defstride;
901 }
902
Brian Paulfbd8f211999-11-11 01:22:25 +0000903 _mesa_DisableClientState( GL_EDGE_FLAG_ARRAY );
904 _mesa_DisableClientState( GL_INDEX_ARRAY );
Brian Paul095c6692006-04-25 00:21:32 +0000905 /* XXX also disable secondary color and generic arrays? */
jtgafb833d1999-08-19 00:55:39 +0000906
907 /* Texcoords */
jtgafb833d1999-08-19 00:55:39 +0000908 if (tflag) {
Brian Paul4a3110f2003-12-12 18:40:02 +0000909 _mesa_EnableClientState( GL_TEXTURE_COORD_ARRAY );
910 _mesa_TexCoordPointer( tcomps, GL_FLOAT, stride,
Brian Paulab928e52004-03-10 16:17:35 +0000911 (GLubyte *) pointer + toffset );
jtgafb833d1999-08-19 00:55:39 +0000912 }
913 else {
Brian Paulab928e52004-03-10 16:17:35 +0000914 _mesa_DisableClientState( GL_TEXTURE_COORD_ARRAY );
jtgafb833d1999-08-19 00:55:39 +0000915 }
jtgafb833d1999-08-19 00:55:39 +0000916
917 /* Color */
918 if (cflag) {
Brian Paulfbd8f211999-11-11 01:22:25 +0000919 _mesa_EnableClientState( GL_COLOR_ARRAY );
Keith Whitwellcab974c2000-12-26 05:09:27 +0000920 _mesa_ColorPointer( ccomps, ctype, stride,
Brian Paul4a3110f2003-12-12 18:40:02 +0000921 (GLubyte *) pointer + coffset );
jtgafb833d1999-08-19 00:55:39 +0000922 }
923 else {
Brian Paulfbd8f211999-11-11 01:22:25 +0000924 _mesa_DisableClientState( GL_COLOR_ARRAY );
jtgafb833d1999-08-19 00:55:39 +0000925 }
926
927
928 /* Normals */
929 if (nflag) {
Brian Paulfbd8f211999-11-11 01:22:25 +0000930 _mesa_EnableClientState( GL_NORMAL_ARRAY );
Brian Paul4a3110f2003-12-12 18:40:02 +0000931 _mesa_NormalPointer( GL_FLOAT, stride, (GLubyte *) pointer + noffset );
jtgafb833d1999-08-19 00:55:39 +0000932 }
933 else {
Brian Paulfbd8f211999-11-11 01:22:25 +0000934 _mesa_DisableClientState( GL_NORMAL_ARRAY );
jtgafb833d1999-08-19 00:55:39 +0000935 }
936
Brian Paul4a3110f2003-12-12 18:40:02 +0000937 /* Vertices */
Brian Paulfbd8f211999-11-11 01:22:25 +0000938 _mesa_EnableClientState( GL_VERTEX_ARRAY );
Keith Whitwellcab974c2000-12-26 05:09:27 +0000939 _mesa_VertexPointer( vcomps, GL_FLOAT, stride,
940 (GLubyte *) pointer + voffset );
jtgafb833d1999-08-19 00:55:39 +0000941}
942
943
Kendall Bennettc40d1dd2003-10-21 22:22:17 +0000944void GLAPIENTRY
Keith Whitwellad2ac212000-11-24 10:25:05 +0000945_mesa_LockArraysEXT(GLint first, GLsizei count)
946{
947 GET_CURRENT_CONTEXT(ctx);
Keith Whitwellcab974c2000-12-26 05:09:27 +0000948 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
Keith Whitwellad2ac212000-11-24 10:25:05 +0000949
950 if (MESA_VERBOSE & VERBOSE_API)
Brian Paul4753d602002-06-15 02:38:15 +0000951 _mesa_debug(ctx, "glLockArrays %d %d\n", first, count);
Keith Whitwellad2ac212000-11-24 10:25:05 +0000952
Eric Anholt5857e982008-02-02 02:54:13 -0800953 if (first < 0) {
954 _mesa_error( ctx, GL_INVALID_VALUE, "glLockArraysEXT(first)" );
955 return;
Gareth Hughes22144ab2001-03-12 00:48:37 +0000956 }
Eric Anholt5857e982008-02-02 02:54:13 -0800957 if (count <= 0) {
958 _mesa_error( ctx, GL_INVALID_VALUE, "glLockArraysEXT(count)" );
959 return;
Keith Whitwellad2ac212000-11-24 10:25:05 +0000960 }
Eric Anholt5857e982008-02-02 02:54:13 -0800961 if (ctx->Array.LockCount != 0) {
962 _mesa_error( ctx, GL_INVALID_OPERATION, "glLockArraysEXT(reentry)" );
963 return;
964 }
965
966 ctx->Array.LockFirst = first;
967 ctx->Array.LockCount = count;
Keith Whitwellad2ac212000-11-24 10:25:05 +0000968
969 ctx->NewState |= _NEW_ARRAY;
Keith Whitwellcab974c2000-12-26 05:09:27 +0000970 ctx->Array.NewState |= _NEW_ARRAY_ALL;
Keith Whitwellad2ac212000-11-24 10:25:05 +0000971}
972
973
Kendall Bennettc40d1dd2003-10-21 22:22:17 +0000974void GLAPIENTRY
Keith Whitwellad2ac212000-11-24 10:25:05 +0000975_mesa_UnlockArraysEXT( void )
976{
977 GET_CURRENT_CONTEXT(ctx);
Keith Whitwellcab974c2000-12-26 05:09:27 +0000978 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
Keith Whitwellad2ac212000-11-24 10:25:05 +0000979
980 if (MESA_VERBOSE & VERBOSE_API)
Brian Paul4753d602002-06-15 02:38:15 +0000981 _mesa_debug(ctx, "glUnlockArrays\n");
Keith Whitwellad2ac212000-11-24 10:25:05 +0000982
Eric Anholt5857e982008-02-02 02:54:13 -0800983 if (ctx->Array.LockCount == 0) {
984 _mesa_error( ctx, GL_INVALID_OPERATION, "glUnlockArraysEXT(reexit)" );
985 return;
986 }
987
Keith Whitwellad2ac212000-11-24 10:25:05 +0000988 ctx->Array.LockFirst = 0;
989 ctx->Array.LockCount = 0;
990 ctx->NewState |= _NEW_ARRAY;
Keith Whitwellcab974c2000-12-26 05:09:27 +0000991 ctx->Array.NewState |= _NEW_ARRAY_ALL;
Keith Whitwellad2ac212000-11-24 10:25:05 +0000992}
Brian Paul2525bc72002-06-30 15:47:00 +0000993
994
Brian Paul2525bc72002-06-30 15:47:00 +0000995/* GL_EXT_multi_draw_arrays */
996/* Somebody forgot to spec the first and count parameters as const! <sigh> */
Kendall Bennettc40d1dd2003-10-21 22:22:17 +0000997void GLAPIENTRY
Brian Paul2525bc72002-06-30 15:47:00 +0000998_mesa_MultiDrawArraysEXT( GLenum mode, GLint *first,
999 GLsizei *count, GLsizei primcount )
1000{
1001 GET_CURRENT_CONTEXT(ctx);
1002 GLint i;
1003
1004 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
1005
1006 for (i = 0; i < primcount; i++) {
1007 if (count[i] > 0) {
Ian Romanick9bdfee32005-07-18 12:31:24 +00001008 CALL_DrawArrays(ctx->Exec, (mode, first[i], count[i]));
Brian Paul2525bc72002-06-30 15:47:00 +00001009 }
1010 }
1011}
1012
1013
Ian Romanick3baefe62003-08-22 23:28:03 +00001014/* GL_IBM_multimode_draw_arrays */
Kendall Bennettc40d1dd2003-10-21 22:22:17 +00001015void GLAPIENTRY
Ian Romanick3baefe62003-08-22 23:28:03 +00001016_mesa_MultiModeDrawArraysIBM( const GLenum * mode, const GLint * first,
1017 const GLsizei * count,
1018 GLsizei primcount, GLint modestride )
1019{
1020 GET_CURRENT_CONTEXT(ctx);
1021 GLint i;
1022
1023 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
1024
1025 for ( i = 0 ; i < primcount ; i++ ) {
1026 if ( count[i] > 0 ) {
Brian Paul03e29a52003-12-04 03:16:27 +00001027 GLenum m = *((GLenum *) ((GLubyte *) mode + i * modestride));
Ian Romanick9bdfee32005-07-18 12:31:24 +00001028 CALL_DrawArrays(ctx->Exec, ( m, first[i], count[i] ));
Ian Romanick3baefe62003-08-22 23:28:03 +00001029 }
1030 }
1031}
1032
1033
1034/* GL_IBM_multimode_draw_arrays */
Kendall Bennettc40d1dd2003-10-21 22:22:17 +00001035void GLAPIENTRY
Ian Romanick3baefe62003-08-22 23:28:03 +00001036_mesa_MultiModeDrawElementsIBM( const GLenum * mode, const GLsizei * count,
1037 GLenum type, const GLvoid * const * indices,
1038 GLsizei primcount, GLint modestride )
1039{
1040 GET_CURRENT_CONTEXT(ctx);
1041 GLint i;
1042
1043 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
1044
Brian Pauld2afb392003-09-17 18:15:13 +00001045 /* XXX not sure about ARB_vertex_buffer_object handling here */
1046
Ian Romanick3baefe62003-08-22 23:28:03 +00001047 for ( i = 0 ; i < primcount ; i++ ) {
1048 if ( count[i] > 0 ) {
Brian Paul03e29a52003-12-04 03:16:27 +00001049 GLenum m = *((GLenum *) ((GLubyte *) mode + i * modestride));
Ian Romanick9bdfee32005-07-18 12:31:24 +00001050 CALL_DrawElements(ctx->Exec, ( m, count[i], type, indices[i] ));
Ian Romanick3baefe62003-08-22 23:28:03 +00001051 }
1052 }
1053}
1054
1055
Brian Paul095c6692006-04-25 00:21:32 +00001056/**
Brian Paulb2885402009-08-06 13:53:06 -06001057 * Copy one client vertex array to another.
1058 */
1059void
1060_mesa_copy_client_array(GLcontext *ctx,
1061 struct gl_client_array *dst,
1062 struct gl_client_array *src)
1063{
1064 dst->Size = src->Size;
1065 dst->Type = src->Type;
1066 dst->Format = src->Format;
1067 dst->Stride = src->Stride;
1068 dst->StrideB = src->StrideB;
1069 dst->Ptr = src->Ptr;
1070 dst->Enabled = src->Enabled;
1071 dst->Normalized = src->Normalized;
1072 dst->_ElementSize = src->_ElementSize;
1073 _mesa_reference_buffer_object(ctx, &dst->BufferObj, src->BufferObj);
1074 dst->_MaxElement = src->_MaxElement;
1075}
1076
1077
1078
1079/**
Brian Paul39d75242009-05-14 16:25:32 -06001080 * Print vertex array's fields.
1081 */
1082static void
1083print_array(const char *name, GLint index, const struct gl_client_array *array)
1084{
1085 if (index >= 0)
1086 _mesa_printf(" %s[%d]: ", name, index);
1087 else
1088 _mesa_printf(" %s: ", name);
1089 _mesa_printf("Ptr=%p, Type=0x%x, Size=%d, ElemSize=%u, Stride=%d, Buffer=%u(Size %u), MaxElem=%u\n",
1090 array->Ptr, array->Type, array->Size,
1091 array->_ElementSize, array->StrideB,
1092 array->BufferObj->Name, array->BufferObj->Size,
1093 array->_MaxElement);
1094}
1095
1096
1097/**
1098 * Print current vertex object/array info. For debug.
1099 */
1100void
1101_mesa_print_arrays(GLcontext *ctx)
1102{
Brian Paul6a2211f2009-05-21 15:55:50 -06001103 struct gl_array_object *arrayObj = ctx->Array.ArrayObj;
Brian Paul39d75242009-05-14 16:25:32 -06001104 GLuint i;
1105
Brian Paul8fe31342009-05-21 15:36:25 -06001106 _mesa_update_array_object_max_element(ctx, arrayObj);
1107
Brian Paul39d75242009-05-14 16:25:32 -06001108 _mesa_printf("Array Object %u\n", arrayObj->Name);
1109 if (arrayObj->Vertex.Enabled)
1110 print_array("Vertex", -1, &arrayObj->Vertex);
1111 if (arrayObj->Normal.Enabled)
1112 print_array("Normal", -1, &arrayObj->Normal);
1113 if (arrayObj->Color.Enabled)
1114 print_array("Color", -1, &arrayObj->Color);
Brian Pauld30163a2009-05-22 14:23:02 -06001115 for (i = 0; i < Elements(arrayObj->TexCoord); i++)
Brian Paul39d75242009-05-14 16:25:32 -06001116 if (arrayObj->TexCoord[i].Enabled)
1117 print_array("TexCoord", i, &arrayObj->TexCoord[i]);
Brian Pauld30163a2009-05-22 14:23:02 -06001118 for (i = 0; i < Elements(arrayObj->VertexAttrib); i++)
Brian Paul39d75242009-05-14 16:25:32 -06001119 if (arrayObj->VertexAttrib[i].Enabled)
1120 print_array("Attrib", i, &arrayObj->VertexAttrib[i]);
1121 _mesa_printf(" _MaxElement = %u\n", arrayObj->_MaxElement);
1122}
1123
1124
1125/**
Brian Paul095c6692006-04-25 00:21:32 +00001126 * Initialize vertex array state for given context.
1127 */
Kendall Bennettc40d1dd2003-10-21 22:22:17 +00001128void
Brian Paul095c6692006-04-25 00:21:32 +00001129_mesa_init_varray(GLcontext *ctx)
Keith Whitwell6dc85572003-07-17 13:43:59 +00001130{
Ian Romanickee34e6e2006-06-12 16:26:29 +00001131 ctx->Array.DefaultArrayObj = _mesa_new_array_object(ctx, 0);
Brian Paul1030bf02009-05-07 13:52:26 -06001132 _mesa_reference_array_object(ctx, &ctx->Array.ArrayObj,
1133 ctx->Array.DefaultArrayObj);
Brian Paul095c6692006-04-25 00:21:32 +00001134 ctx->Array.ActiveTexture = 0; /* GL_ARB_multitexture */
Brian Paul12cf98f2009-06-19 17:58:47 -06001135
1136 ctx->Array.Objects = _mesa_NewHashTable();
1137}
1138
1139
1140/**
1141 * Callback for deleting an array object. Called by _mesa_HashDeleteAll().
1142 */
1143static void
1144delete_arrayobj_cb(GLuint id, void *data, void *userData)
1145{
1146 struct gl_array_object *arrayObj = (struct gl_array_object *) data;
1147 GLcontext *ctx = (GLcontext *) userData;
1148 _mesa_delete_array_object(ctx, arrayObj);
1149}
1150
1151
1152/**
1153 * Free vertex array state for given context.
1154 */
1155void
1156_mesa_free_varray_data(GLcontext *ctx)
1157{
1158 _mesa_HashDeleteAll(ctx->Array.Objects, delete_arrayobj_cb, ctx);
1159 _mesa_DeleteHashTable(ctx->Array.Objects);
Keith Whitwell6dc85572003-07-17 13:43:59 +00001160}