blob: bf1ad0165e66e8fd1a5b89c1fa2b9f1d433edb96 [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"
Ian Romanick9bdfee32005-07-18 12:31:24 +000035#include "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{
Brian Paul095c6692006-04-25 00:21:32 +0000446 const 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:
Brian Paulc5b1e812003-10-22 22:59:07 +0000474 elementSize = size * sizeof(GLubyte);
Brian Paul2edd1802002-01-11 17:25:35 +0000475 break;
476 case GL_SHORT:
Brian Paulc5b1e812003-10-22 22:59:07 +0000477 elementSize = size * sizeof(GLshort);
Brian Paul2edd1802002-01-11 17:25:35 +0000478 break;
479 case GL_FLOAT:
Brian Paulc5b1e812003-10-22 22:59:07 +0000480 elementSize = size * sizeof(GLfloat);
Brian Paul2edd1802002-01-11 17:25:35 +0000481 break;
482 case GL_DOUBLE:
Brian Paulc5b1e812003-10-22 22:59:07 +0000483 elementSize = size * sizeof(GLdouble);
Brian Paul2edd1802002-01-11 17:25:35 +0000484 break;
485 default:
486 _mesa_error( ctx, GL_INVALID_ENUM, "glVertexAttribPointerNV(type)" );
487 return;
488 }
489
Brian Paulf9d88c82006-06-13 17:24:36 +0000490 update_array(ctx, &ctx->Array.ArrayObj->VertexAttrib[index],
491 _NEW_ARRAY_ATTRIB(index),
Brian Paul095c6692006-04-25 00:21:32 +0000492 elementSize, size, type, stride, normalized, ptr);
Brian Paul2edd1802002-01-11 17:25:35 +0000493
Brian Paulb7752722002-04-21 18:49:18 +0000494 if (ctx->Driver.VertexAttribPointer)
Brian Paul2edd1802002-01-11 17:25:35 +0000495 ctx->Driver.VertexAttribPointer( ctx, index, size, type, stride, ptr );
Brian Paul2edd1802002-01-11 17:25:35 +0000496}
Brian Paul148a2842003-09-17 03:40:11 +0000497#endif
jtgafb833d1999-08-19 00:55:39 +0000498
Brian Paul1f0e2132000-06-12 15:30:51 +0000499
Brian Paul148a2842003-09-17 03:40:11 +0000500#if FEATURE_ARB_vertex_program
Kendall Bennettc40d1dd2003-10-21 22:22:17 +0000501void GLAPIENTRY
Brian Paul92f97852003-05-01 22:44:02 +0000502_mesa_VertexAttribPointerARB(GLuint index, GLint size, GLenum type,
503 GLboolean normalized,
504 GLsizei stride, const GLvoid *ptr)
505{
Brian Paulc5b1e812003-10-22 22:59:07 +0000506 GLsizei elementSize;
Brian Paul92f97852003-05-01 22:44:02 +0000507 GET_CURRENT_CONTEXT(ctx);
508 ASSERT_OUTSIDE_BEGIN_END(ctx);
509
Brian Paul05051032005-11-01 04:36:33 +0000510 if (index >= ctx->Const.VertexProgram.MaxAttribs) {
Brian Paul92f97852003-05-01 22:44:02 +0000511 _mesa_error(ctx, GL_INVALID_VALUE, "glVertexAttribPointerARB(index)");
512 return;
513 }
514
515 if (size < 1 || size > 4) {
516 _mesa_error(ctx, GL_INVALID_VALUE, "glVertexAttribPointerARB(size)");
517 return;
518 }
519
520 if (stride < 0) {
521 _mesa_error(ctx, GL_INVALID_VALUE, "glVertexAttribPointerARB(stride)");
522 return;
523 }
524
525 if (type == GL_UNSIGNED_BYTE && size != 4) {
526 _mesa_error(ctx, GL_INVALID_VALUE, "glVertexAttribPointerARB(size!=4)");
527 return;
528 }
529
530 /* check for valid 'type' and compute StrideB right away */
Brian Paul196a90b2003-06-11 18:47:51 +0000531 /* NOTE: more types are supported here than in the NV extension */
Brian Paul92f97852003-05-01 22:44:02 +0000532 switch (type) {
Brian Paul196a90b2003-06-11 18:47:51 +0000533 case GL_BYTE:
Brian Paulc5b1e812003-10-22 22:59:07 +0000534 elementSize = size * sizeof(GLbyte);
Brian Paul196a90b2003-06-11 18:47:51 +0000535 break;
Brian Paul92f97852003-05-01 22:44:02 +0000536 case GL_UNSIGNED_BYTE:
Brian Paulc5b1e812003-10-22 22:59:07 +0000537 elementSize = size * sizeof(GLubyte);
Brian Paul92f97852003-05-01 22:44:02 +0000538 break;
539 case GL_SHORT:
Brian Paulc5b1e812003-10-22 22:59:07 +0000540 elementSize = size * sizeof(GLshort);
Brian Paul92f97852003-05-01 22:44:02 +0000541 break;
Brian Paul196a90b2003-06-11 18:47:51 +0000542 case GL_UNSIGNED_SHORT:
Brian Paulc5b1e812003-10-22 22:59:07 +0000543 elementSize = size * sizeof(GLushort);
Brian Paul196a90b2003-06-11 18:47:51 +0000544 break;
545 case GL_INT:
Brian Paulc5b1e812003-10-22 22:59:07 +0000546 elementSize = size * sizeof(GLint);
Brian Paul196a90b2003-06-11 18:47:51 +0000547 break;
548 case GL_UNSIGNED_INT:
Brian Paulc5b1e812003-10-22 22:59:07 +0000549 elementSize = size * sizeof(GLuint);
Brian Paul196a90b2003-06-11 18:47:51 +0000550 break;
Brian Paul92f97852003-05-01 22:44:02 +0000551 case GL_FLOAT:
Brian Paulc5b1e812003-10-22 22:59:07 +0000552 elementSize = size * sizeof(GLfloat);
Brian Paul92f97852003-05-01 22:44:02 +0000553 break;
554 case GL_DOUBLE:
Brian Paulc5b1e812003-10-22 22:59:07 +0000555 elementSize = size * sizeof(GLdouble);
Brian Paul92f97852003-05-01 22:44:02 +0000556 break;
557 default:
558 _mesa_error( ctx, GL_INVALID_ENUM, "glVertexAttribPointerARB(type)" );
559 return;
560 }
561
Brian Paulf9d88c82006-06-13 17:24:36 +0000562 update_array(ctx, &ctx->Array.ArrayObj->VertexAttrib[index],
563 _NEW_ARRAY_ATTRIB(index),
Brian Paulc5b1e812003-10-22 22:59:07 +0000564 elementSize, size, type, stride, normalized, ptr);
Brian Paul92f97852003-05-01 22:44:02 +0000565
Brian Paul92f97852003-05-01 22:44:02 +0000566 if (ctx->Driver.VertexAttribPointer)
Brian Paulf9d88c82006-06-13 17:24:36 +0000567 ctx->Driver.VertexAttribPointer(ctx, index, size, type, stride, ptr);
Brian Paul92f97852003-05-01 22:44:02 +0000568}
Brian Paul148a2842003-09-17 03:40:11 +0000569#endif
Brian Paul92f97852003-05-01 22:44:02 +0000570
571
Kendall Bennettc40d1dd2003-10-21 22:22:17 +0000572void GLAPIENTRY
Brian Paul1f0e2132000-06-12 15:30:51 +0000573_mesa_VertexPointerEXT(GLint size, GLenum type, GLsizei stride,
574 GLsizei count, const GLvoid *ptr)
575{
576 (void) count;
577 _mesa_VertexPointer(size, type, stride, ptr);
578}
579
580
Kendall Bennettc40d1dd2003-10-21 22:22:17 +0000581void GLAPIENTRY
Brian Paul1f0e2132000-06-12 15:30:51 +0000582_mesa_NormalPointerEXT(GLenum type, GLsizei stride, GLsizei count,
583 const GLvoid *ptr)
584{
585 (void) count;
586 _mesa_NormalPointer(type, stride, ptr);
587}
588
589
Kendall Bennettc40d1dd2003-10-21 22:22:17 +0000590void GLAPIENTRY
Brian Paul1f0e2132000-06-12 15:30:51 +0000591_mesa_ColorPointerEXT(GLint size, GLenum type, GLsizei stride, GLsizei count,
592 const GLvoid *ptr)
593{
594 (void) count;
595 _mesa_ColorPointer(size, type, stride, ptr);
596}
597
598
Kendall Bennettc40d1dd2003-10-21 22:22:17 +0000599void GLAPIENTRY
Brian Paul1f0e2132000-06-12 15:30:51 +0000600_mesa_IndexPointerEXT(GLenum type, GLsizei stride, GLsizei count,
601 const GLvoid *ptr)
602{
603 (void) count;
604 _mesa_IndexPointer(type, stride, ptr);
605}
606
607
Kendall Bennettc40d1dd2003-10-21 22:22:17 +0000608void GLAPIENTRY
Brian Paul1f0e2132000-06-12 15:30:51 +0000609_mesa_TexCoordPointerEXT(GLint size, GLenum type, GLsizei stride,
610 GLsizei count, const GLvoid *ptr)
611{
612 (void) count;
613 _mesa_TexCoordPointer(size, type, stride, ptr);
614}
615
616
Kendall Bennettc40d1dd2003-10-21 22:22:17 +0000617void GLAPIENTRY
Brian Paul1f0e2132000-06-12 15:30:51 +0000618_mesa_EdgeFlagPointerEXT(GLsizei stride, GLsizei count, const GLboolean *ptr)
619{
620 (void) count;
621 _mesa_EdgeFlagPointer(stride, ptr);
622}
623
624
Kendall Bennettc40d1dd2003-10-21 22:22:17 +0000625void GLAPIENTRY
Brian Paulfbd8f211999-11-11 01:22:25 +0000626_mesa_InterleavedArrays(GLenum format, GLsizei stride, const GLvoid *pointer)
jtgafb833d1999-08-19 00:55:39 +0000627{
Brian Paulfbd8f211999-11-11 01:22:25 +0000628 GET_CURRENT_CONTEXT(ctx);
jtgafb833d1999-08-19 00:55:39 +0000629 GLboolean tflag, cflag, nflag; /* enable/disable flags */
630 GLint tcomps, ccomps, vcomps; /* components per texcoord, color, vertex */
Keith Whitwellf4b02d12001-01-05 05:31:42 +0000631 GLenum ctype = 0; /* color type */
632 GLint coffset = 0, noffset = 0, voffset;/* color, normal, vertex offsets */
Brian Paul4a3110f2003-12-12 18:40:02 +0000633 const GLint toffset = 0; /* always zero */
jtgafb833d1999-08-19 00:55:39 +0000634 GLint defstride; /* default stride */
635 GLint c, f;
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +0000636
Keith Whitwellcab974c2000-12-26 05:09:27 +0000637 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
638
jtgafb833d1999-08-19 00:55:39 +0000639 f = sizeof(GLfloat);
Brian Paulc5b1e812003-10-22 22:59:07 +0000640 c = f * ((4 * sizeof(GLubyte) + (f - 1)) / f);
jtgafb833d1999-08-19 00:55:39 +0000641
Brian Paulc5b1e812003-10-22 22:59:07 +0000642 if (stride < 0) {
Brian Paul08836342001-03-03 20:33:27 +0000643 _mesa_error( ctx, GL_INVALID_VALUE, "glInterleavedArrays(stride)" );
jtgafb833d1999-08-19 00:55:39 +0000644 return;
645 }
646
647 switch (format) {
648 case GL_V2F:
649 tflag = GL_FALSE; cflag = GL_FALSE; nflag = GL_FALSE;
650 tcomps = 0; ccomps = 0; vcomps = 2;
651 voffset = 0;
652 defstride = 2*f;
653 break;
654 case GL_V3F:
655 tflag = GL_FALSE; cflag = GL_FALSE; nflag = GL_FALSE;
656 tcomps = 0; ccomps = 0; vcomps = 3;
657 voffset = 0;
658 defstride = 3*f;
659 break;
660 case GL_C4UB_V2F:
661 tflag = GL_FALSE; cflag = GL_TRUE; nflag = GL_FALSE;
662 tcomps = 0; ccomps = 4; vcomps = 2;
663 ctype = GL_UNSIGNED_BYTE;
664 coffset = 0;
665 voffset = c;
666 defstride = c + 2*f;
667 break;
668 case GL_C4UB_V3F:
669 tflag = GL_FALSE; cflag = GL_TRUE; nflag = GL_FALSE;
670 tcomps = 0; ccomps = 4; vcomps = 3;
671 ctype = GL_UNSIGNED_BYTE;
672 coffset = 0;
673 voffset = c;
674 defstride = c + 3*f;
675 break;
676 case GL_C3F_V3F:
677 tflag = GL_FALSE; cflag = GL_TRUE; nflag = GL_FALSE;
678 tcomps = 0; ccomps = 3; vcomps = 3;
679 ctype = GL_FLOAT;
680 coffset = 0;
681 voffset = 3*f;
682 defstride = 6*f;
683 break;
684 case GL_N3F_V3F:
685 tflag = GL_FALSE; cflag = GL_FALSE; nflag = GL_TRUE;
686 tcomps = 0; ccomps = 0; vcomps = 3;
687 noffset = 0;
688 voffset = 3*f;
689 defstride = 6*f;
690 break;
691 case GL_C4F_N3F_V3F:
692 tflag = GL_FALSE; cflag = GL_TRUE; nflag = GL_TRUE;
693 tcomps = 0; ccomps = 4; vcomps = 3;
694 ctype = GL_FLOAT;
695 coffset = 0;
696 noffset = 4*f;
697 voffset = 7*f;
698 defstride = 10*f;
699 break;
700 case GL_T2F_V3F:
701 tflag = GL_TRUE; cflag = GL_FALSE; nflag = GL_FALSE;
702 tcomps = 2; ccomps = 0; vcomps = 3;
703 voffset = 2*f;
704 defstride = 5*f;
705 break;
706 case GL_T4F_V4F:
707 tflag = GL_TRUE; cflag = GL_FALSE; nflag = GL_FALSE;
708 tcomps = 4; ccomps = 0; vcomps = 4;
709 voffset = 4*f;
710 defstride = 8*f;
711 break;
712 case GL_T2F_C4UB_V3F:
713 tflag = GL_TRUE; cflag = GL_TRUE; nflag = GL_FALSE;
714 tcomps = 2; ccomps = 4; vcomps = 3;
715 ctype = GL_UNSIGNED_BYTE;
716 coffset = 2*f;
717 voffset = c+2*f;
718 defstride = c+5*f;
719 break;
720 case GL_T2F_C3F_V3F:
721 tflag = GL_TRUE; cflag = GL_TRUE; nflag = GL_FALSE;
722 tcomps = 2; ccomps = 3; vcomps = 3;
723 ctype = GL_FLOAT;
724 coffset = 2*f;
725 voffset = 5*f;
726 defstride = 8*f;
727 break;
728 case GL_T2F_N3F_V3F:
729 tflag = GL_TRUE; cflag = GL_FALSE; nflag = GL_TRUE;
730 tcomps = 2; ccomps = 0; vcomps = 3;
731 noffset = 2*f;
732 voffset = 5*f;
733 defstride = 8*f;
734 break;
735 case GL_T2F_C4F_N3F_V3F:
736 tflag = GL_TRUE; cflag = GL_TRUE; nflag = GL_TRUE;
737 tcomps = 2; ccomps = 4; vcomps = 3;
738 ctype = GL_FLOAT;
739 coffset = 2*f;
740 noffset = 6*f;
741 voffset = 9*f;
742 defstride = 12*f;
743 break;
744 case GL_T4F_C4F_N3F_V4F:
745 tflag = GL_TRUE; cflag = GL_TRUE; nflag = GL_TRUE;
746 tcomps = 4; ccomps = 4; vcomps = 4;
747 ctype = GL_FLOAT;
748 coffset = 4*f;
749 noffset = 8*f;
750 voffset = 11*f;
751 defstride = 15*f;
752 break;
753 default:
Brian Paul08836342001-03-03 20:33:27 +0000754 _mesa_error( ctx, GL_INVALID_ENUM, "glInterleavedArrays(format)" );
jtgafb833d1999-08-19 00:55:39 +0000755 return;
756 }
757
758 if (stride==0) {
759 stride = defstride;
760 }
761
Brian Paulfbd8f211999-11-11 01:22:25 +0000762 _mesa_DisableClientState( GL_EDGE_FLAG_ARRAY );
763 _mesa_DisableClientState( GL_INDEX_ARRAY );
Brian Paul095c6692006-04-25 00:21:32 +0000764 /* XXX also disable secondary color and generic arrays? */
jtgafb833d1999-08-19 00:55:39 +0000765
766 /* Texcoords */
jtgafb833d1999-08-19 00:55:39 +0000767 if (tflag) {
Brian Paul4a3110f2003-12-12 18:40:02 +0000768 _mesa_EnableClientState( GL_TEXTURE_COORD_ARRAY );
769 _mesa_TexCoordPointer( tcomps, GL_FLOAT, stride,
Brian Paulab928e52004-03-10 16:17:35 +0000770 (GLubyte *) pointer + toffset );
jtgafb833d1999-08-19 00:55:39 +0000771 }
772 else {
Brian Paulab928e52004-03-10 16:17:35 +0000773 _mesa_DisableClientState( GL_TEXTURE_COORD_ARRAY );
jtgafb833d1999-08-19 00:55:39 +0000774 }
jtgafb833d1999-08-19 00:55:39 +0000775
776 /* Color */
777 if (cflag) {
Brian Paulfbd8f211999-11-11 01:22:25 +0000778 _mesa_EnableClientState( GL_COLOR_ARRAY );
Keith Whitwellcab974c2000-12-26 05:09:27 +0000779 _mesa_ColorPointer( ccomps, ctype, stride,
Brian Paul4a3110f2003-12-12 18:40:02 +0000780 (GLubyte *) pointer + coffset );
jtgafb833d1999-08-19 00:55:39 +0000781 }
782 else {
Brian Paulfbd8f211999-11-11 01:22:25 +0000783 _mesa_DisableClientState( GL_COLOR_ARRAY );
jtgafb833d1999-08-19 00:55:39 +0000784 }
785
786
787 /* Normals */
788 if (nflag) {
Brian Paulfbd8f211999-11-11 01:22:25 +0000789 _mesa_EnableClientState( GL_NORMAL_ARRAY );
Brian Paul4a3110f2003-12-12 18:40:02 +0000790 _mesa_NormalPointer( GL_FLOAT, stride, (GLubyte *) pointer + noffset );
jtgafb833d1999-08-19 00:55:39 +0000791 }
792 else {
Brian Paulfbd8f211999-11-11 01:22:25 +0000793 _mesa_DisableClientState( GL_NORMAL_ARRAY );
jtgafb833d1999-08-19 00:55:39 +0000794 }
795
Brian Paul4a3110f2003-12-12 18:40:02 +0000796 /* Vertices */
Brian Paulfbd8f211999-11-11 01:22:25 +0000797 _mesa_EnableClientState( GL_VERTEX_ARRAY );
Keith Whitwellcab974c2000-12-26 05:09:27 +0000798 _mesa_VertexPointer( vcomps, GL_FLOAT, stride,
799 (GLubyte *) pointer + voffset );
jtgafb833d1999-08-19 00:55:39 +0000800}
801
802
Kendall Bennettc40d1dd2003-10-21 22:22:17 +0000803void GLAPIENTRY
Keith Whitwellad2ac212000-11-24 10:25:05 +0000804_mesa_LockArraysEXT(GLint first, GLsizei count)
805{
806 GET_CURRENT_CONTEXT(ctx);
Keith Whitwellcab974c2000-12-26 05:09:27 +0000807 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
Keith Whitwellad2ac212000-11-24 10:25:05 +0000808
809 if (MESA_VERBOSE & VERBOSE_API)
Brian Paul4753d602002-06-15 02:38:15 +0000810 _mesa_debug(ctx, "glLockArrays %d %d\n", first, count);
Keith Whitwellad2ac212000-11-24 10:25:05 +0000811
Brian Paulb51b0a82001-03-07 05:06:11 +0000812 if (first == 0 && count > 0 &&
813 count <= (GLint) ctx->Const.MaxArrayLockSize) {
Keith Whitwellad2ac212000-11-24 10:25:05 +0000814 ctx->Array.LockFirst = first;
815 ctx->Array.LockCount = count;
Gareth Hughes22144ab2001-03-12 00:48:37 +0000816 }
Keith Whitwellad2ac212000-11-24 10:25:05 +0000817 else {
818 ctx->Array.LockFirst = 0;
819 ctx->Array.LockCount = 0;
820 }
821
822 ctx->NewState |= _NEW_ARRAY;
Keith Whitwellcab974c2000-12-26 05:09:27 +0000823 ctx->Array.NewState |= _NEW_ARRAY_ALL;
Keith Whitwellad2ac212000-11-24 10:25:05 +0000824
825 if (ctx->Driver.LockArraysEXT)
826 ctx->Driver.LockArraysEXT( ctx, first, count );
827}
828
829
Kendall Bennettc40d1dd2003-10-21 22:22:17 +0000830void GLAPIENTRY
Keith Whitwellad2ac212000-11-24 10:25:05 +0000831_mesa_UnlockArraysEXT( void )
832{
833 GET_CURRENT_CONTEXT(ctx);
Keith Whitwellcab974c2000-12-26 05:09:27 +0000834 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
Keith Whitwellad2ac212000-11-24 10:25:05 +0000835
836 if (MESA_VERBOSE & VERBOSE_API)
Brian Paul4753d602002-06-15 02:38:15 +0000837 _mesa_debug(ctx, "glUnlockArrays\n");
Keith Whitwellad2ac212000-11-24 10:25:05 +0000838
839 ctx->Array.LockFirst = 0;
840 ctx->Array.LockCount = 0;
841 ctx->NewState |= _NEW_ARRAY;
Keith Whitwellcab974c2000-12-26 05:09:27 +0000842 ctx->Array.NewState |= _NEW_ARRAY_ALL;
Keith Whitwellad2ac212000-11-24 10:25:05 +0000843
844 if (ctx->Driver.UnlockArraysEXT)
845 ctx->Driver.UnlockArraysEXT( ctx );
846}
Brian Paul2525bc72002-06-30 15:47:00 +0000847
848
Brian Paul2525bc72002-06-30 15:47:00 +0000849/* GL_EXT_multi_draw_arrays */
850/* Somebody forgot to spec the first and count parameters as const! <sigh> */
Kendall Bennettc40d1dd2003-10-21 22:22:17 +0000851void GLAPIENTRY
Brian Paul2525bc72002-06-30 15:47:00 +0000852_mesa_MultiDrawArraysEXT( GLenum mode, GLint *first,
853 GLsizei *count, GLsizei primcount )
854{
855 GET_CURRENT_CONTEXT(ctx);
856 GLint i;
857
858 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
859
860 for (i = 0; i < primcount; i++) {
861 if (count[i] > 0) {
Ian Romanick9bdfee32005-07-18 12:31:24 +0000862 CALL_DrawArrays(ctx->Exec, (mode, first[i], count[i]));
Brian Paul2525bc72002-06-30 15:47:00 +0000863 }
864 }
865}
866
867
868/* GL_EXT_multi_draw_arrays */
Kendall Bennettc40d1dd2003-10-21 22:22:17 +0000869void GLAPIENTRY
Brian Paul2525bc72002-06-30 15:47:00 +0000870_mesa_MultiDrawElementsEXT( GLenum mode, const GLsizei *count, GLenum type,
871 const GLvoid **indices, GLsizei primcount )
872{
873 GET_CURRENT_CONTEXT(ctx);
874 GLint i;
875
876 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
877
878 for (i = 0; i < primcount; i++) {
879 if (count[i] > 0) {
Ian Romanick9bdfee32005-07-18 12:31:24 +0000880 CALL_DrawElements(ctx->Exec, (mode, count[i], type, indices[i]));
Brian Paul2525bc72002-06-30 15:47:00 +0000881 }
882 }
883}
Keith Whitwell6dc85572003-07-17 13:43:59 +0000884
885
Ian Romanick3baefe62003-08-22 23:28:03 +0000886/* GL_IBM_multimode_draw_arrays */
Kendall Bennettc40d1dd2003-10-21 22:22:17 +0000887void GLAPIENTRY
Ian Romanick3baefe62003-08-22 23:28:03 +0000888_mesa_MultiModeDrawArraysIBM( const GLenum * mode, const GLint * first,
889 const GLsizei * count,
890 GLsizei primcount, GLint modestride )
891{
892 GET_CURRENT_CONTEXT(ctx);
893 GLint i;
894
895 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
896
897 for ( i = 0 ; i < primcount ; i++ ) {
898 if ( count[i] > 0 ) {
Brian Paul03e29a52003-12-04 03:16:27 +0000899 GLenum m = *((GLenum *) ((GLubyte *) mode + i * modestride));
Ian Romanick9bdfee32005-07-18 12:31:24 +0000900 CALL_DrawArrays(ctx->Exec, ( m, first[i], count[i] ));
Ian Romanick3baefe62003-08-22 23:28:03 +0000901 }
902 }
903}
904
905
906/* GL_IBM_multimode_draw_arrays */
Kendall Bennettc40d1dd2003-10-21 22:22:17 +0000907void GLAPIENTRY
Ian Romanick3baefe62003-08-22 23:28:03 +0000908_mesa_MultiModeDrawElementsIBM( const GLenum * mode, const GLsizei * count,
909 GLenum type, const GLvoid * const * indices,
910 GLsizei primcount, GLint modestride )
911{
912 GET_CURRENT_CONTEXT(ctx);
913 GLint i;
914
915 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
916
Brian Pauld2afb392003-09-17 18:15:13 +0000917 /* XXX not sure about ARB_vertex_buffer_object handling here */
918
Ian Romanick3baefe62003-08-22 23:28:03 +0000919 for ( i = 0 ; i < primcount ; i++ ) {
920 if ( count[i] > 0 ) {
Brian Paul03e29a52003-12-04 03:16:27 +0000921 GLenum m = *((GLenum *) ((GLubyte *) mode + i * modestride));
Ian Romanick9bdfee32005-07-18 12:31:24 +0000922 CALL_DrawElements(ctx->Exec, ( m, count[i], type, indices[i] ));
Ian Romanick3baefe62003-08-22 23:28:03 +0000923 }
924 }
925}
926
927
Brian Paul095c6692006-04-25 00:21:32 +0000928/**
929 * Initialize vertex array state for given context.
930 */
Kendall Bennettc40d1dd2003-10-21 22:22:17 +0000931void
Brian Paul095c6692006-04-25 00:21:32 +0000932_mesa_init_varray(GLcontext *ctx)
Keith Whitwell6dc85572003-07-17 13:43:59 +0000933{
Ian Romanickee34e6e2006-06-12 16:26:29 +0000934 ctx->Array.DefaultArrayObj = _mesa_new_array_object(ctx, 0);
935 ctx->Array.ArrayObj = ctx->Array.DefaultArrayObj;
Brian Paul095c6692006-04-25 00:21:32 +0000936
937 ctx->Array.ActiveTexture = 0; /* GL_ARB_multitexture */
Keith Whitwell6dc85572003-07-17 13:43:59 +0000938}