blob: 0050d9a1a177dbb75d88ea038c0a1c3be1f34457 [file] [log] [blame]
Keith Whitwell88f3b892000-12-28 22:11:04 +00001/* $Id: varray.c,v 1.35 2000/12/28 22:11:05 keithw Exp $ */
jtgafb833d1999-08-19 00:55:39 +00002
3/*
4 * Mesa 3-D graphics library
Brian Paulce938b32000-10-18 15:02:59 +00005 * Version: 3.5
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +00006 *
Brian Paul4463a242000-01-13 00:25:22 +00007 * Copyright (C) 1999-2000 Brian Paul All Rights Reserved.
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +00008 *
jtgafb833d1999-08-19 00:55:39 +00009 * Permission is hereby granted, free of charge, to any person obtaining a
10 * copy of this software and associated documentation files (the "Software"),
11 * to deal in the Software without restriction, including without limitation
12 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
13 * and/or sell copies of the Software, and to permit persons to whom the
14 * Software is furnished to do so, subject to the following conditions:
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +000015 *
jtgafb833d1999-08-19 00:55:39 +000016 * The above copyright notice and this permission notice shall be included
17 * in all copies or substantial portions of the Software.
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +000018 *
jtgafb833d1999-08-19 00:55:39 +000019 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
23 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
24 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 */
26
27#ifdef PC_HEADER
28#include "all.h"
29#else
Brian Paulfbd8f211999-11-11 01:22:25 +000030#include "glheader.h"
jtgafb833d1999-08-19 00:55:39 +000031#include "context.h"
jtgafb833d1999-08-19 00:55:39 +000032#include "enable.h"
33#include "enums.h"
34#include "dlist.h"
35#include "light.h"
36#include "macros.h"
37#include "mmath.h"
Brian Paulea39f042000-02-02 19:17:57 +000038#include "state.h"
jtgafb833d1999-08-19 00:55:39 +000039#include "texstate.h"
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +000040#include "mtypes.h"
jtgafb833d1999-08-19 00:55:39 +000041#include "varray.h"
Keith Whitwell23caf202000-11-16 21:05:34 +000042#include "math/m_translate.h"
Keith Whitwell485f0401999-10-08 09:27:09 +000043#endif
44
jtgafb833d1999-08-19 00:55:39 +000045
Brian Paulfbd8f211999-11-11 01:22:25 +000046
47void
48_mesa_VertexPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr)
jtgafb833d1999-08-19 00:55:39 +000049{
Brian Paulfbd8f211999-11-11 01:22:25 +000050 GET_CURRENT_CONTEXT(ctx);
Keith Whitwellcab974c2000-12-26 05:09:27 +000051 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +000052
jtgafb833d1999-08-19 00:55:39 +000053 if (size<2 || size>4) {
54 gl_error( ctx, GL_INVALID_VALUE, "glVertexPointer(size)" );
55 return;
56 }
57 if (stride<0) {
58 gl_error( ctx, GL_INVALID_VALUE, "glVertexPointer(stride)" );
59 return;
60 }
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +000061
jtgafb833d1999-08-19 00:55:39 +000062 if (MESA_VERBOSE&(VERBOSE_VARRAY|VERBOSE_API))
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +000063 fprintf(stderr, "glVertexPointer( sz %d type %s stride %d )\n", size,
jtgafb833d1999-08-19 00:55:39 +000064 gl_lookup_enum_by_nr( type ),
65 stride);
66
67 ctx->Array.Vertex.StrideB = stride;
68 if (!stride) {
69 switch (type) {
70 case GL_SHORT:
71 ctx->Array.Vertex.StrideB = size*sizeof(GLshort);
72 break;
73 case GL_INT:
74 ctx->Array.Vertex.StrideB = size*sizeof(GLint);
75 break;
76 case GL_FLOAT:
77 ctx->Array.Vertex.StrideB = size*sizeof(GLfloat);
78 break;
79 case GL_DOUBLE:
80 ctx->Array.Vertex.StrideB = size*sizeof(GLdouble);
81 break;
82 default:
83 gl_error( ctx, GL_INVALID_ENUM, "glVertexPointer(type)" );
84 return;
85 }
86 }
87 ctx->Array.Vertex.Size = size;
88 ctx->Array.Vertex.Type = type;
89 ctx->Array.Vertex.Stride = stride;
90 ctx->Array.Vertex.Ptr = (void *) ptr;
Keith Whitwella96308c2000-10-30 13:31:59 +000091 ctx->NewState |= _NEW_ARRAY;
Keith Whitwellcab974c2000-12-26 05:09:27 +000092 ctx->Array.NewState |= _NEW_ARRAY_VERTEX;
Keith Whitwell23caf202000-11-16 21:05:34 +000093
94 if (ctx->Driver.VertexPointer)
95 ctx->Driver.VertexPointer( ctx, size, type, stride, ptr );
jtgafb833d1999-08-19 00:55:39 +000096}
97
98
99
100
Brian Paulfbd8f211999-11-11 01:22:25 +0000101void
102_mesa_NormalPointer(GLenum type, GLsizei stride, const GLvoid *ptr )
jtgafb833d1999-08-19 00:55:39 +0000103{
Brian Paulfbd8f211999-11-11 01:22:25 +0000104 GET_CURRENT_CONTEXT(ctx);
Keith Whitwellcab974c2000-12-26 05:09:27 +0000105 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +0000106
jtgafb833d1999-08-19 00:55:39 +0000107 if (stride<0) {
108 gl_error( ctx, GL_INVALID_VALUE, "glNormalPointer(stride)" );
109 return;
110 }
111
112 if (MESA_VERBOSE&(VERBOSE_VARRAY|VERBOSE_API))
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +0000113 fprintf(stderr, "glNormalPointer( type %s stride %d )\n",
jtgafb833d1999-08-19 00:55:39 +0000114 gl_lookup_enum_by_nr( type ),
115 stride);
116
117 ctx->Array.Normal.StrideB = stride;
118 if (!stride) {
119 switch (type) {
120 case GL_BYTE:
121 ctx->Array.Normal.StrideB = 3*sizeof(GLbyte);
122 break;
123 case GL_SHORT:
124 ctx->Array.Normal.StrideB = 3*sizeof(GLshort);
125 break;
126 case GL_INT:
127 ctx->Array.Normal.StrideB = 3*sizeof(GLint);
128 break;
129 case GL_FLOAT:
130 ctx->Array.Normal.StrideB = 3*sizeof(GLfloat);
131 break;
132 case GL_DOUBLE:
133 ctx->Array.Normal.StrideB = 3*sizeof(GLdouble);
134 break;
135 default:
136 gl_error( ctx, GL_INVALID_ENUM, "glNormalPointer(type)" );
137 return;
138 }
139 }
140 ctx->Array.Normal.Type = type;
141 ctx->Array.Normal.Stride = stride;
142 ctx->Array.Normal.Ptr = (void *) ptr;
Keith Whitwella96308c2000-10-30 13:31:59 +0000143 ctx->NewState |= _NEW_ARRAY;
Keith Whitwellcab974c2000-12-26 05:09:27 +0000144 ctx->Array.NewState |= _NEW_ARRAY_VERTEX;
Keith Whitwell23caf202000-11-16 21:05:34 +0000145
146 if (ctx->Driver.NormalPointer)
147 ctx->Driver.NormalPointer( ctx, type, stride, ptr );
jtgafb833d1999-08-19 00:55:39 +0000148}
149
150
151
Brian Paulfbd8f211999-11-11 01:22:25 +0000152void
153_mesa_ColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr)
jtgafb833d1999-08-19 00:55:39 +0000154{
Brian Paulfbd8f211999-11-11 01:22:25 +0000155 GET_CURRENT_CONTEXT(ctx);
Keith Whitwellcab974c2000-12-26 05:09:27 +0000156 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
Brian Paulfbd8f211999-11-11 01:22:25 +0000157
jtgafb833d1999-08-19 00:55:39 +0000158 if (size<3 || size>4) {
159 gl_error( ctx, GL_INVALID_VALUE, "glColorPointer(size)" );
160 return;
161 }
162 if (stride<0) {
163 gl_error( ctx, GL_INVALID_VALUE, "glColorPointer(stride)" );
164 return;
165 }
166
167 if (MESA_VERBOSE&(VERBOSE_VARRAY|VERBOSE_API))
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +0000168 fprintf(stderr, "glColorPointer( sz %d type %s stride %d )\n", size,
jtgafb833d1999-08-19 00:55:39 +0000169 gl_lookup_enum_by_nr( type ),
170 stride);
171
172 ctx->Array.Color.StrideB = stride;
173 if (!stride) {
174 switch (type) {
175 case GL_BYTE:
176 ctx->Array.Color.StrideB = size*sizeof(GLbyte);
177 break;
178 case GL_UNSIGNED_BYTE:
179 ctx->Array.Color.StrideB = size*sizeof(GLubyte);
180 break;
181 case GL_SHORT:
182 ctx->Array.Color.StrideB = size*sizeof(GLshort);
183 break;
184 case GL_UNSIGNED_SHORT:
185 ctx->Array.Color.StrideB = size*sizeof(GLushort);
186 break;
187 case GL_INT:
188 ctx->Array.Color.StrideB = size*sizeof(GLint);
189 break;
190 case GL_UNSIGNED_INT:
191 ctx->Array.Color.StrideB = size*sizeof(GLuint);
192 break;
193 case GL_FLOAT:
194 ctx->Array.Color.StrideB = size*sizeof(GLfloat);
195 break;
196 case GL_DOUBLE:
197 ctx->Array.Color.StrideB = size*sizeof(GLdouble);
198 break;
199 default:
200 gl_error( ctx, GL_INVALID_ENUM, "glColorPointer(type)" );
201 return;
202 }
203 }
204 ctx->Array.Color.Size = size;
205 ctx->Array.Color.Type = type;
206 ctx->Array.Color.Stride = stride;
207 ctx->Array.Color.Ptr = (void *) ptr;
Keith Whitwella96308c2000-10-30 13:31:59 +0000208 ctx->NewState |= _NEW_ARRAY;
Keith Whitwellcab974c2000-12-26 05:09:27 +0000209 ctx->Array.NewState |= _NEW_ARRAY_VERTEX;
Keith Whitwell23caf202000-11-16 21:05:34 +0000210
211 if (ctx->Driver.ColorPointer)
212 ctx->Driver.ColorPointer( ctx, size, type, stride, ptr );
jtgafb833d1999-08-19 00:55:39 +0000213}
214
215
216
Brian Paulfbd8f211999-11-11 01:22:25 +0000217void
Keith Whitwellfe5d67d2000-10-27 16:44:40 +0000218_mesa_FogCoordPointerEXT(GLenum type, GLsizei stride, const GLvoid *ptr)
219{
220 GET_CURRENT_CONTEXT(ctx);
Keith Whitwellcab974c2000-12-26 05:09:27 +0000221 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +0000222
Keith Whitwellfe5d67d2000-10-27 16:44:40 +0000223 if (stride<0) {
224 gl_error( ctx, GL_INVALID_VALUE, "glFogCoordPointer(stride)" );
225 return;
226 }
227
228 ctx->Array.FogCoord.StrideB = stride;
229 if (!stride) {
230 switch (type) {
231 case GL_FLOAT:
232 ctx->Array.FogCoord.StrideB = sizeof(GLfloat);
233 break;
234 case GL_DOUBLE:
235 ctx->Array.FogCoord.StrideB = sizeof(GLdouble);
236 break;
237 default:
238 gl_error( ctx, GL_INVALID_ENUM, "glFogCoordPointer(type)" );
239 return;
240 }
241 }
242 ctx->Array.FogCoord.Type = type;
243 ctx->Array.FogCoord.Stride = stride;
244 ctx->Array.FogCoord.Ptr = (void *) ptr;
Keith Whitwella96308c2000-10-30 13:31:59 +0000245 ctx->NewState |= _NEW_ARRAY;
Keith Whitwellcab974c2000-12-26 05:09:27 +0000246 ctx->Array.NewState |= _NEW_ARRAY_VERTEX;
Keith Whitwell23caf202000-11-16 21:05:34 +0000247
248 if (ctx->Driver.FogCoordPointer)
249 ctx->Driver.FogCoordPointer( ctx, type, stride, ptr );
Keith Whitwellfe5d67d2000-10-27 16:44:40 +0000250}
251
252
253void
Brian Paulfbd8f211999-11-11 01:22:25 +0000254_mesa_IndexPointer(GLenum type, GLsizei stride, const GLvoid *ptr)
jtgafb833d1999-08-19 00:55:39 +0000255{
Brian Paulfbd8f211999-11-11 01:22:25 +0000256 GET_CURRENT_CONTEXT(ctx);
Keith Whitwellcab974c2000-12-26 05:09:27 +0000257 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +0000258
jtgafb833d1999-08-19 00:55:39 +0000259 if (stride<0) {
260 gl_error( ctx, GL_INVALID_VALUE, "glIndexPointer(stride)" );
261 return;
262 }
263
264 ctx->Array.Index.StrideB = stride;
265 if (!stride) {
266 switch (type) {
267 case GL_UNSIGNED_BYTE:
268 ctx->Array.Index.StrideB = sizeof(GLubyte);
269 break;
270 case GL_SHORT:
271 ctx->Array.Index.StrideB = sizeof(GLshort);
272 break;
273 case GL_INT:
274 ctx->Array.Index.StrideB = sizeof(GLint);
275 break;
276 case GL_FLOAT:
277 ctx->Array.Index.StrideB = sizeof(GLfloat);
278 break;
279 case GL_DOUBLE:
280 ctx->Array.Index.StrideB = sizeof(GLdouble);
281 break;
282 default:
283 gl_error( ctx, GL_INVALID_ENUM, "glIndexPointer(type)" );
284 return;
285 }
286 }
287 ctx->Array.Index.Type = type;
288 ctx->Array.Index.Stride = stride;
289 ctx->Array.Index.Ptr = (void *) ptr;
Keith Whitwella96308c2000-10-30 13:31:59 +0000290 ctx->NewState |= _NEW_ARRAY;
Keith Whitwellcab974c2000-12-26 05:09:27 +0000291 ctx->Array.NewState |= _NEW_ARRAY_VERTEX;
Keith Whitwell23caf202000-11-16 21:05:34 +0000292
293 if (ctx->Driver.IndexPointer)
294 ctx->Driver.IndexPointer( ctx, type, stride, ptr );
jtgafb833d1999-08-19 00:55:39 +0000295}
296
297
Keith Whitwellfe5d67d2000-10-27 16:44:40 +0000298void
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +0000299_mesa_SecondaryColorPointerEXT(GLint size, GLenum type,
Keith Whitwellfe5d67d2000-10-27 16:44:40 +0000300 GLsizei stride, const GLvoid *ptr)
301{
302 GET_CURRENT_CONTEXT(ctx);
Keith Whitwellcab974c2000-12-26 05:09:27 +0000303 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
Keith Whitwellfe5d67d2000-10-27 16:44:40 +0000304
Keith Whitwellfe5d67d2000-10-27 16:44:40 +0000305 if (size != 3 && size != 4) {
306 gl_error( ctx, GL_INVALID_VALUE, "glColorPointer(size)" );
307 return;
308 }
309 if (stride<0) {
310 gl_error( ctx, GL_INVALID_VALUE, "glColorPointer(stride)" );
311 return;
312 }
313
314 if (MESA_VERBOSE&(VERBOSE_VARRAY|VERBOSE_API))
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +0000315 fprintf(stderr, "glColorPointer( sz %d type %s stride %d )\n", size,
Keith Whitwellfe5d67d2000-10-27 16:44:40 +0000316 gl_lookup_enum_by_nr( type ),
317 stride);
318
319 ctx->Array.SecondaryColor.StrideB = stride;
320 if (!stride) {
321 switch (type) {
322 case GL_BYTE:
323 ctx->Array.SecondaryColor.StrideB = size*sizeof(GLbyte);
324 break;
325 case GL_UNSIGNED_BYTE:
326 ctx->Array.SecondaryColor.StrideB = size*sizeof(GLubyte);
327 break;
328 case GL_SHORT:
329 ctx->Array.SecondaryColor.StrideB = size*sizeof(GLshort);
330 break;
331 case GL_UNSIGNED_SHORT:
332 ctx->Array.SecondaryColor.StrideB = size*sizeof(GLushort);
333 break;
334 case GL_INT:
335 ctx->Array.SecondaryColor.StrideB = size*sizeof(GLint);
336 break;
337 case GL_UNSIGNED_INT:
338 ctx->Array.SecondaryColor.StrideB = size*sizeof(GLuint);
339 break;
340 case GL_FLOAT:
341 ctx->Array.SecondaryColor.StrideB = size*sizeof(GLfloat);
342 break;
343 case GL_DOUBLE:
344 ctx->Array.SecondaryColor.StrideB = size*sizeof(GLdouble);
345 break;
346 default:
347 gl_error( ctx, GL_INVALID_ENUM, "glSecondaryColorPointer(type)" );
348 return;
349 }
350 }
351 ctx->Array.SecondaryColor.Size = 3; /* hardwire */
352 ctx->Array.SecondaryColor.Type = type;
353 ctx->Array.SecondaryColor.Stride = stride;
354 ctx->Array.SecondaryColor.Ptr = (void *) ptr;
Keith Whitwella96308c2000-10-30 13:31:59 +0000355 ctx->NewState |= _NEW_ARRAY;
Keith Whitwellcab974c2000-12-26 05:09:27 +0000356 ctx->Array.NewState |= _NEW_ARRAY_VERTEX;
Keith Whitwell23caf202000-11-16 21:05:34 +0000357
358 if (ctx->Driver.SecondaryColorPointer)
359 ctx->Driver.SecondaryColorPointer( ctx, size, type, stride, ptr );
Keith Whitwellfe5d67d2000-10-27 16:44:40 +0000360}
361
362
jtgafb833d1999-08-19 00:55:39 +0000363
Brian Paulfbd8f211999-11-11 01:22:25 +0000364void
365_mesa_TexCoordPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr)
jtgafb833d1999-08-19 00:55:39 +0000366{
Brian Paulfbd8f211999-11-11 01:22:25 +0000367 GET_CURRENT_CONTEXT(ctx);
Keith Whitwellcab974c2000-12-26 05:09:27 +0000368 GLuint texUnit = ctx->Array.ActiveTexture;
369 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
jtgafb833d1999-08-19 00:55:39 +0000370
371 if (size<1 || size>4) {
372 gl_error( ctx, GL_INVALID_VALUE, "glTexCoordPointer(size)" );
373 return;
374 }
375 if (stride<0) {
376 gl_error( ctx, GL_INVALID_VALUE, "glTexCoordPointer(stride)" );
377 return;
378 }
379
380 if (MESA_VERBOSE&(VERBOSE_VARRAY|VERBOSE_API))
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +0000381 fprintf(stderr, "glTexCoordPointer( unit %u sz %d type %s stride %d )\n",
jtgafb833d1999-08-19 00:55:39 +0000382 texUnit,
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +0000383 size,
jtgafb833d1999-08-19 00:55:39 +0000384 gl_lookup_enum_by_nr( type ),
385 stride);
386
387 ctx->Array.TexCoord[texUnit].StrideB = stride;
388 if (!stride) {
389 switch (type) {
390 case GL_SHORT:
391 ctx->Array.TexCoord[texUnit].StrideB = size*sizeof(GLshort);
392 break;
393 case GL_INT:
394 ctx->Array.TexCoord[texUnit].StrideB = size*sizeof(GLint);
395 break;
396 case GL_FLOAT:
397 ctx->Array.TexCoord[texUnit].StrideB = size*sizeof(GLfloat);
398 break;
399 case GL_DOUBLE:
400 ctx->Array.TexCoord[texUnit].StrideB = size*sizeof(GLdouble);
401 break;
402 default:
403 gl_error( ctx, GL_INVALID_ENUM, "glTexCoordPointer(type)" );
404 return;
405 }
406 }
407 ctx->Array.TexCoord[texUnit].Size = size;
408 ctx->Array.TexCoord[texUnit].Type = type;
409 ctx->Array.TexCoord[texUnit].Stride = stride;
410 ctx->Array.TexCoord[texUnit].Ptr = (void *) ptr;
Keith Whitwella96308c2000-10-30 13:31:59 +0000411 ctx->NewState |= _NEW_ARRAY;
Keith Whitwellcab974c2000-12-26 05:09:27 +0000412 ctx->Array.NewState |= _NEW_ARRAY_VERTEX;
Keith Whitwell23caf202000-11-16 21:05:34 +0000413
Keith Whitwell88f3b892000-12-28 22:11:04 +0000414/* fprintf(stderr, "%s ptr %p\n", __FUNCTION__, ptr); */
415
Keith Whitwell23caf202000-11-16 21:05:34 +0000416 if (ctx->Driver.TexCoordPointer)
417 ctx->Driver.TexCoordPointer( ctx, size, type, stride, ptr );
jtgafb833d1999-08-19 00:55:39 +0000418}
419
420
421
422
Brian Paulfbd8f211999-11-11 01:22:25 +0000423void
424_mesa_EdgeFlagPointer(GLsizei stride, const void *vptr)
jtgafb833d1999-08-19 00:55:39 +0000425{
Brian Paulfbd8f211999-11-11 01:22:25 +0000426 GET_CURRENT_CONTEXT(ctx);
jtgafb833d1999-08-19 00:55:39 +0000427 const GLboolean *ptr = (GLboolean *)vptr;
Keith Whitwellcab974c2000-12-26 05:09:27 +0000428 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
jtgafb833d1999-08-19 00:55:39 +0000429
430 if (stride<0) {
431 gl_error( ctx, GL_INVALID_VALUE, "glEdgeFlagPointer(stride)" );
432 return;
433 }
434 ctx->Array.EdgeFlag.Stride = stride;
435 ctx->Array.EdgeFlag.StrideB = stride ? stride : sizeof(GLboolean);
436 ctx->Array.EdgeFlag.Ptr = (GLboolean *) ptr;
Keith Whitwella96308c2000-10-30 13:31:59 +0000437 ctx->NewState |= _NEW_ARRAY;
Keith Whitwellcab974c2000-12-26 05:09:27 +0000438 ctx->Array.NewState |= _NEW_ARRAY_VERTEX;
Keith Whitwell23caf202000-11-16 21:05:34 +0000439
440 if (ctx->Driver.EdgeFlagPointer)
441 ctx->Driver.EdgeFlagPointer( ctx, stride, ptr );
jtgafb833d1999-08-19 00:55:39 +0000442}
443
444
jtgafb833d1999-08-19 00:55:39 +0000445
446
Brian Paul1f0e2132000-06-12 15:30:51 +0000447
448void
449_mesa_VertexPointerEXT(GLint size, GLenum type, GLsizei stride,
450 GLsizei count, const GLvoid *ptr)
451{
452 (void) count;
453 _mesa_VertexPointer(size, type, stride, ptr);
454}
455
456
457void
458_mesa_NormalPointerEXT(GLenum type, GLsizei stride, GLsizei count,
459 const GLvoid *ptr)
460{
461 (void) count;
462 _mesa_NormalPointer(type, stride, ptr);
463}
464
465
466void
467_mesa_ColorPointerEXT(GLint size, GLenum type, GLsizei stride, GLsizei count,
468 const GLvoid *ptr)
469{
470 (void) count;
471 _mesa_ColorPointer(size, type, stride, ptr);
472}
473
474
475void
476_mesa_IndexPointerEXT(GLenum type, GLsizei stride, GLsizei count,
477 const GLvoid *ptr)
478{
479 (void) count;
480 _mesa_IndexPointer(type, stride, ptr);
481}
482
483
484void
485_mesa_TexCoordPointerEXT(GLint size, GLenum type, GLsizei stride,
486 GLsizei count, const GLvoid *ptr)
487{
488 (void) count;
489 _mesa_TexCoordPointer(size, type, stride, ptr);
490}
491
492
493void
494_mesa_EdgeFlagPointerEXT(GLsizei stride, GLsizei count, const GLboolean *ptr)
495{
496 (void) count;
497 _mesa_EdgeFlagPointer(stride, ptr);
498}
499
500
501
502
503
jtgafb833d1999-08-19 00:55:39 +0000504
Brian Paulfbd8f211999-11-11 01:22:25 +0000505void
506_mesa_InterleavedArrays(GLenum format, GLsizei stride, const GLvoid *pointer)
jtgafb833d1999-08-19 00:55:39 +0000507{
Brian Paulfbd8f211999-11-11 01:22:25 +0000508 GET_CURRENT_CONTEXT(ctx);
jtgafb833d1999-08-19 00:55:39 +0000509 GLboolean tflag, cflag, nflag; /* enable/disable flags */
510 GLint tcomps, ccomps, vcomps; /* components per texcoord, color, vertex */
511
512 GLenum ctype; /* color type */
513 GLint coffset, noffset, voffset;/* color, normal, vertex offsets */
514 GLint defstride; /* default stride */
515 GLint c, f;
516 GLint coordUnitSave;
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +0000517
Keith Whitwellcab974c2000-12-26 05:09:27 +0000518 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
519
jtgafb833d1999-08-19 00:55:39 +0000520 f = sizeof(GLfloat);
521 c = f * ((4*sizeof(GLubyte) + (f-1)) / f);
522
523 if (stride<0) {
524 gl_error( ctx, GL_INVALID_VALUE, "glInterleavedArrays(stride)" );
525 return;
526 }
527
528 switch (format) {
529 case GL_V2F:
530 tflag = GL_FALSE; cflag = GL_FALSE; nflag = GL_FALSE;
531 tcomps = 0; ccomps = 0; vcomps = 2;
532 voffset = 0;
533 defstride = 2*f;
534 break;
535 case GL_V3F:
536 tflag = GL_FALSE; cflag = GL_FALSE; nflag = GL_FALSE;
537 tcomps = 0; ccomps = 0; vcomps = 3;
538 voffset = 0;
539 defstride = 3*f;
540 break;
541 case GL_C4UB_V2F:
542 tflag = GL_FALSE; cflag = GL_TRUE; nflag = GL_FALSE;
543 tcomps = 0; ccomps = 4; vcomps = 2;
544 ctype = GL_UNSIGNED_BYTE;
545 coffset = 0;
546 voffset = c;
547 defstride = c + 2*f;
548 break;
549 case GL_C4UB_V3F:
550 tflag = GL_FALSE; cflag = GL_TRUE; nflag = GL_FALSE;
551 tcomps = 0; ccomps = 4; vcomps = 3;
552 ctype = GL_UNSIGNED_BYTE;
553 coffset = 0;
554 voffset = c;
555 defstride = c + 3*f;
556 break;
557 case GL_C3F_V3F:
558 tflag = GL_FALSE; cflag = GL_TRUE; nflag = GL_FALSE;
559 tcomps = 0; ccomps = 3; vcomps = 3;
560 ctype = GL_FLOAT;
561 coffset = 0;
562 voffset = 3*f;
563 defstride = 6*f;
564 break;
565 case GL_N3F_V3F:
566 tflag = GL_FALSE; cflag = GL_FALSE; nflag = GL_TRUE;
567 tcomps = 0; ccomps = 0; vcomps = 3;
568 noffset = 0;
569 voffset = 3*f;
570 defstride = 6*f;
571 break;
572 case GL_C4F_N3F_V3F:
573 tflag = GL_FALSE; cflag = GL_TRUE; nflag = GL_TRUE;
574 tcomps = 0; ccomps = 4; vcomps = 3;
575 ctype = GL_FLOAT;
576 coffset = 0;
577 noffset = 4*f;
578 voffset = 7*f;
579 defstride = 10*f;
580 break;
581 case GL_T2F_V3F:
582 tflag = GL_TRUE; cflag = GL_FALSE; nflag = GL_FALSE;
583 tcomps = 2; ccomps = 0; vcomps = 3;
584 voffset = 2*f;
585 defstride = 5*f;
586 break;
587 case GL_T4F_V4F:
588 tflag = GL_TRUE; cflag = GL_FALSE; nflag = GL_FALSE;
589 tcomps = 4; ccomps = 0; vcomps = 4;
590 voffset = 4*f;
591 defstride = 8*f;
592 break;
593 case GL_T2F_C4UB_V3F:
594 tflag = GL_TRUE; cflag = GL_TRUE; nflag = GL_FALSE;
595 tcomps = 2; ccomps = 4; vcomps = 3;
596 ctype = GL_UNSIGNED_BYTE;
597 coffset = 2*f;
598 voffset = c+2*f;
599 defstride = c+5*f;
600 break;
601 case GL_T2F_C3F_V3F:
602 tflag = GL_TRUE; cflag = GL_TRUE; nflag = GL_FALSE;
603 tcomps = 2; ccomps = 3; vcomps = 3;
604 ctype = GL_FLOAT;
605 coffset = 2*f;
606 voffset = 5*f;
607 defstride = 8*f;
608 break;
609 case GL_T2F_N3F_V3F:
610 tflag = GL_TRUE; cflag = GL_FALSE; nflag = GL_TRUE;
611 tcomps = 2; ccomps = 0; vcomps = 3;
612 noffset = 2*f;
613 voffset = 5*f;
614 defstride = 8*f;
615 break;
616 case GL_T2F_C4F_N3F_V3F:
617 tflag = GL_TRUE; cflag = GL_TRUE; nflag = GL_TRUE;
618 tcomps = 2; ccomps = 4; vcomps = 3;
619 ctype = GL_FLOAT;
620 coffset = 2*f;
621 noffset = 6*f;
622 voffset = 9*f;
623 defstride = 12*f;
624 break;
625 case GL_T4F_C4F_N3F_V4F:
626 tflag = GL_TRUE; cflag = GL_TRUE; nflag = GL_TRUE;
627 tcomps = 4; ccomps = 4; vcomps = 4;
628 ctype = GL_FLOAT;
629 coffset = 4*f;
630 noffset = 8*f;
631 voffset = 11*f;
632 defstride = 15*f;
633 break;
634 default:
635 gl_error( ctx, GL_INVALID_ENUM, "glInterleavedArrays(format)" );
636 return;
637 }
638
639 if (stride==0) {
640 stride = defstride;
641 }
642
Brian Paulfbd8f211999-11-11 01:22:25 +0000643 _mesa_DisableClientState( GL_EDGE_FLAG_ARRAY );
644 _mesa_DisableClientState( GL_INDEX_ARRAY );
jtgafb833d1999-08-19 00:55:39 +0000645
646 /* Texcoords */
Brian Paul45224fa1999-09-07 22:31:30 +0000647 coordUnitSave = ctx->Array.ActiveTexture;
jtgafb833d1999-08-19 00:55:39 +0000648 if (tflag) {
649 GLint i;
650 GLint factor = ctx->Array.TexCoordInterleaveFactor;
651 for (i = 0; i < factor; i++) {
Brian Paulfbd8f211999-11-11 01:22:25 +0000652 _mesa_ClientActiveTextureARB( (GLenum) (GL_TEXTURE0_ARB + i) );
653 _mesa_EnableClientState( GL_TEXTURE_COORD_ARRAY );
Keith Whitwellcab974c2000-12-26 05:09:27 +0000654 _mesa_TexCoordPointer( tcomps, GL_FLOAT, stride,
655 (GLubyte *) pointer + i * coffset );
jtgafb833d1999-08-19 00:55:39 +0000656 }
657 for (i = factor; i < ctx->Const.MaxTextureUnits; i++) {
Brian Paulfbd8f211999-11-11 01:22:25 +0000658 _mesa_ClientActiveTextureARB( (GLenum) (GL_TEXTURE0_ARB + i) );
659 _mesa_DisableClientState( GL_TEXTURE_COORD_ARRAY );
jtgafb833d1999-08-19 00:55:39 +0000660 }
661 }
662 else {
663 GLint i;
664 for (i = 0; i < ctx->Const.MaxTextureUnits; i++) {
Brian Paulfbd8f211999-11-11 01:22:25 +0000665 _mesa_ClientActiveTextureARB( (GLenum) (GL_TEXTURE0_ARB + i) );
666 _mesa_DisableClientState( GL_TEXTURE_COORD_ARRAY );
jtgafb833d1999-08-19 00:55:39 +0000667 }
668 }
669 /* Restore texture coordinate unit index */
Brian Paulfbd8f211999-11-11 01:22:25 +0000670 _mesa_ClientActiveTextureARB( (GLenum) (GL_TEXTURE0_ARB + coordUnitSave) );
jtgafb833d1999-08-19 00:55:39 +0000671
672
673 /* Color */
674 if (cflag) {
Brian Paulfbd8f211999-11-11 01:22:25 +0000675 _mesa_EnableClientState( GL_COLOR_ARRAY );
Keith Whitwellcab974c2000-12-26 05:09:27 +0000676 _mesa_ColorPointer( ccomps, ctype, stride,
677 (GLubyte*) pointer + coffset );
jtgafb833d1999-08-19 00:55:39 +0000678 }
679 else {
Brian Paulfbd8f211999-11-11 01:22:25 +0000680 _mesa_DisableClientState( GL_COLOR_ARRAY );
jtgafb833d1999-08-19 00:55:39 +0000681 }
682
683
684 /* Normals */
685 if (nflag) {
Brian Paulfbd8f211999-11-11 01:22:25 +0000686 _mesa_EnableClientState( GL_NORMAL_ARRAY );
Keith Whitwellcab974c2000-12-26 05:09:27 +0000687 _mesa_NormalPointer( GL_FLOAT, stride,
688 (GLubyte*) pointer + noffset );
jtgafb833d1999-08-19 00:55:39 +0000689 }
690 else {
Brian Paulfbd8f211999-11-11 01:22:25 +0000691 _mesa_DisableClientState( GL_NORMAL_ARRAY );
jtgafb833d1999-08-19 00:55:39 +0000692 }
693
Brian Paulfbd8f211999-11-11 01:22:25 +0000694 _mesa_EnableClientState( GL_VERTEX_ARRAY );
Keith Whitwellcab974c2000-12-26 05:09:27 +0000695 _mesa_VertexPointer( vcomps, GL_FLOAT, stride,
696 (GLubyte *) pointer + voffset );
jtgafb833d1999-08-19 00:55:39 +0000697}
698
699
700
Keith Whitwellad2ac212000-11-24 10:25:05 +0000701void
702_mesa_LockArraysEXT(GLint first, GLsizei count)
703{
704 GET_CURRENT_CONTEXT(ctx);
Keith Whitwellcab974c2000-12-26 05:09:27 +0000705 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
Keith Whitwellad2ac212000-11-24 10:25:05 +0000706
707 if (MESA_VERBOSE & VERBOSE_API)
708 fprintf(stderr, "glLockArrays %d %d\n", first, count);
709
710 if (first == 0 && count > 0 && count <= ctx->Const.MaxArrayLockSize) {
711 ctx->Array.LockFirst = first;
712 ctx->Array.LockCount = count;
713 }
714 else {
715 ctx->Array.LockFirst = 0;
716 ctx->Array.LockCount = 0;
717 }
718
719 ctx->NewState |= _NEW_ARRAY;
Keith Whitwellcab974c2000-12-26 05:09:27 +0000720 ctx->Array.NewState |= _NEW_ARRAY_ALL;
Keith Whitwellad2ac212000-11-24 10:25:05 +0000721
722 if (ctx->Driver.LockArraysEXT)
723 ctx->Driver.LockArraysEXT( ctx, first, count );
724}
725
726
727void
728_mesa_UnlockArraysEXT( void )
729{
730 GET_CURRENT_CONTEXT(ctx);
Keith Whitwellcab974c2000-12-26 05:09:27 +0000731 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
Keith Whitwellad2ac212000-11-24 10:25:05 +0000732
733 if (MESA_VERBOSE & VERBOSE_API)
734 fprintf(stderr, "glUnlockArrays\n");
735
736 ctx->Array.LockFirst = 0;
737 ctx->Array.LockCount = 0;
738 ctx->NewState |= _NEW_ARRAY;
Keith Whitwellcab974c2000-12-26 05:09:27 +0000739 ctx->Array.NewState |= _NEW_ARRAY_ALL;
Keith Whitwellad2ac212000-11-24 10:25:05 +0000740
741 if (ctx->Driver.UnlockArraysEXT)
742 ctx->Driver.UnlockArraysEXT( ctx );
743}