Vertex program checkpoint commit: converted all vertex attributes (color,
[mesa.git] / src / mesa / main / varray.c
1 /* $Id: varray.c,v 1.40 2002/01/05 20:51:12 brianp Exp $ */
2
3 /*
4 * Mesa 3-D graphics library
5 * Version: 4.1
6 *
7 * Copyright (C) 1999-2002 Brian Paul All Rights Reserved.
8 *
9 * 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:
15 *
16 * The above copyright notice and this permission notice shall be included
17 * in all copies or substantial portions of the Software.
18 *
19 * 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
30 #include "glheader.h"
31 #include "context.h"
32 #include "enable.h"
33 #include "enums.h"
34 #include "dlist.h"
35 #include "light.h"
36 #include "macros.h"
37 #include "mmath.h"
38 #include "state.h"
39 #include "texstate.h"
40 #include "mtypes.h"
41 #include "varray.h"
42 #include "math/m_translate.h"
43 #endif
44
45
46
47 void
48 _mesa_VertexPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr)
49 {
50 GET_CURRENT_CONTEXT(ctx);
51 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
52
53 if (size<2 || size>4) {
54 _mesa_error( ctx, GL_INVALID_VALUE, "glVertexPointer(size)" );
55 return;
56 }
57 if (stride<0) {
58 _mesa_error( ctx, GL_INVALID_VALUE, "glVertexPointer(stride)" );
59 return;
60 }
61
62 if (MESA_VERBOSE&(VERBOSE_VARRAY|VERBOSE_API))
63 fprintf(stderr, "glVertexPointer( sz %d type %s stride %d )\n", size,
64 _mesa_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 _mesa_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;
91 ctx->NewState |= _NEW_ARRAY;
92 ctx->Array.NewState |= _NEW_ARRAY_VERTEX;
93
94 if (ctx->Driver.VertexPointer)
95 ctx->Driver.VertexPointer( ctx, size, type, stride, ptr );
96 }
97
98
99
100
101 void
102 _mesa_NormalPointer(GLenum type, GLsizei stride, const GLvoid *ptr )
103 {
104 GET_CURRENT_CONTEXT(ctx);
105 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
106
107 if (stride<0) {
108 _mesa_error( ctx, GL_INVALID_VALUE, "glNormalPointer(stride)" );
109 return;
110 }
111
112 if (MESA_VERBOSE&(VERBOSE_VARRAY|VERBOSE_API))
113 fprintf(stderr, "glNormalPointer( type %s stride %d )\n",
114 _mesa_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 _mesa_error( ctx, GL_INVALID_ENUM, "glNormalPointer(type)" );
137 return;
138 }
139 }
140 ctx->Array.Normal.Size = 3;
141 ctx->Array.Normal.Type = type;
142 ctx->Array.Normal.Stride = stride;
143 ctx->Array.Normal.Ptr = (void *) ptr;
144 ctx->NewState |= _NEW_ARRAY;
145 ctx->Array.NewState |= _NEW_ARRAY_VERTEX;
146
147 if (ctx->Driver.NormalPointer)
148 ctx->Driver.NormalPointer( ctx, type, stride, ptr );
149 }
150
151
152
153 void
154 _mesa_ColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr)
155 {
156 GET_CURRENT_CONTEXT(ctx);
157 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
158
159 if (size<3 || size>4) {
160 _mesa_error( ctx, GL_INVALID_VALUE, "glColorPointer(size)" );
161 return;
162 }
163 if (stride<0) {
164 _mesa_error( ctx, GL_INVALID_VALUE, "glColorPointer(stride)" );
165 return;
166 }
167
168 if (MESA_VERBOSE&(VERBOSE_VARRAY|VERBOSE_API))
169 fprintf(stderr, "glColorPointer( sz %d type %s stride %d )\n", size,
170 _mesa_lookup_enum_by_nr( type ),
171 stride);
172
173 ctx->Array.Color.StrideB = stride;
174 if (!stride) {
175 switch (type) {
176 case GL_BYTE:
177 ctx->Array.Color.StrideB = size*sizeof(GLbyte);
178 break;
179 case GL_UNSIGNED_BYTE:
180 ctx->Array.Color.StrideB = size*sizeof(GLubyte);
181 break;
182 case GL_SHORT:
183 ctx->Array.Color.StrideB = size*sizeof(GLshort);
184 break;
185 case GL_UNSIGNED_SHORT:
186 ctx->Array.Color.StrideB = size*sizeof(GLushort);
187 break;
188 case GL_INT:
189 ctx->Array.Color.StrideB = size*sizeof(GLint);
190 break;
191 case GL_UNSIGNED_INT:
192 ctx->Array.Color.StrideB = size*sizeof(GLuint);
193 break;
194 case GL_FLOAT:
195 ctx->Array.Color.StrideB = size*sizeof(GLfloat);
196 break;
197 case GL_DOUBLE:
198 ctx->Array.Color.StrideB = size*sizeof(GLdouble);
199 break;
200 default:
201 _mesa_error( ctx, GL_INVALID_ENUM, "glColorPointer(type)" );
202 return;
203 }
204 }
205 ctx->Array.Color.Size = size;
206 ctx->Array.Color.Type = type;
207 ctx->Array.Color.Stride = stride;
208 ctx->Array.Color.Ptr = (void *) ptr;
209 ctx->NewState |= _NEW_ARRAY;
210 ctx->Array.NewState |= _NEW_ARRAY_VERTEX;
211
212 if (ctx->Driver.ColorPointer)
213 ctx->Driver.ColorPointer( ctx, size, type, stride, ptr );
214 }
215
216
217
218 void
219 _mesa_FogCoordPointerEXT(GLenum type, GLsizei stride, const GLvoid *ptr)
220 {
221 GET_CURRENT_CONTEXT(ctx);
222 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
223
224 if (stride<0) {
225 _mesa_error( ctx, GL_INVALID_VALUE, "glFogCoordPointer(stride)" );
226 return;
227 }
228
229 ctx->Array.FogCoord.StrideB = stride;
230 if (!stride) {
231 switch (type) {
232 case GL_FLOAT:
233 ctx->Array.FogCoord.StrideB = sizeof(GLfloat);
234 break;
235 case GL_DOUBLE:
236 ctx->Array.FogCoord.StrideB = sizeof(GLdouble);
237 break;
238 default:
239 _mesa_error( ctx, GL_INVALID_ENUM, "glFogCoordPointer(type)" );
240 return;
241 }
242 }
243 ctx->Array.FogCoord.Size = 1;
244 ctx->Array.FogCoord.Type = type;
245 ctx->Array.FogCoord.Stride = stride;
246 ctx->Array.FogCoord.Ptr = (void *) ptr;
247 ctx->NewState |= _NEW_ARRAY;
248 ctx->Array.NewState |= _NEW_ARRAY_VERTEX;
249
250 if (ctx->Driver.FogCoordPointer)
251 ctx->Driver.FogCoordPointer( ctx, type, stride, ptr );
252 }
253
254
255 void
256 _mesa_IndexPointer(GLenum type, GLsizei stride, const GLvoid *ptr)
257 {
258 GET_CURRENT_CONTEXT(ctx);
259 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
260
261 if (stride<0) {
262 _mesa_error( ctx, GL_INVALID_VALUE, "glIndexPointer(stride)" );
263 return;
264 }
265
266 ctx->Array.Index.StrideB = stride;
267 if (!stride) {
268 switch (type) {
269 case GL_UNSIGNED_BYTE:
270 ctx->Array.Index.StrideB = sizeof(GLubyte);
271 break;
272 case GL_SHORT:
273 ctx->Array.Index.StrideB = sizeof(GLshort);
274 break;
275 case GL_INT:
276 ctx->Array.Index.StrideB = sizeof(GLint);
277 break;
278 case GL_FLOAT:
279 ctx->Array.Index.StrideB = sizeof(GLfloat);
280 break;
281 case GL_DOUBLE:
282 ctx->Array.Index.StrideB = sizeof(GLdouble);
283 break;
284 default:
285 _mesa_error( ctx, GL_INVALID_ENUM, "glIndexPointer(type)" );
286 return;
287 }
288 }
289 ctx->Array.Index.Size = 1;
290 ctx->Array.Index.Type = type;
291 ctx->Array.Index.Stride = stride;
292 ctx->Array.Index.Ptr = (void *) ptr;
293 ctx->NewState |= _NEW_ARRAY;
294 ctx->Array.NewState |= _NEW_ARRAY_VERTEX;
295
296 if (ctx->Driver.IndexPointer)
297 ctx->Driver.IndexPointer( ctx, type, stride, ptr );
298 }
299
300
301 void
302 _mesa_SecondaryColorPointerEXT(GLint size, GLenum type,
303 GLsizei stride, const GLvoid *ptr)
304 {
305 GET_CURRENT_CONTEXT(ctx);
306 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
307
308 if (size != 3 && size != 4) {
309 _mesa_error( ctx, GL_INVALID_VALUE, "glColorPointer(size)" );
310 return;
311 }
312 if (stride<0) {
313 _mesa_error( ctx, GL_INVALID_VALUE, "glColorPointer(stride)" );
314 return;
315 }
316
317 if (MESA_VERBOSE&(VERBOSE_VARRAY|VERBOSE_API))
318 fprintf(stderr, "glColorPointer( sz %d type %s stride %d )\n", size,
319 _mesa_lookup_enum_by_nr( type ),
320 stride);
321
322 ctx->Array.SecondaryColor.StrideB = stride;
323 if (!stride) {
324 switch (type) {
325 case GL_BYTE:
326 ctx->Array.SecondaryColor.StrideB = size*sizeof(GLbyte);
327 break;
328 case GL_UNSIGNED_BYTE:
329 ctx->Array.SecondaryColor.StrideB = size*sizeof(GLubyte);
330 break;
331 case GL_SHORT:
332 ctx->Array.SecondaryColor.StrideB = size*sizeof(GLshort);
333 break;
334 case GL_UNSIGNED_SHORT:
335 ctx->Array.SecondaryColor.StrideB = size*sizeof(GLushort);
336 break;
337 case GL_INT:
338 ctx->Array.SecondaryColor.StrideB = size*sizeof(GLint);
339 break;
340 case GL_UNSIGNED_INT:
341 ctx->Array.SecondaryColor.StrideB = size*sizeof(GLuint);
342 break;
343 case GL_FLOAT:
344 ctx->Array.SecondaryColor.StrideB = size*sizeof(GLfloat);
345 break;
346 case GL_DOUBLE:
347 ctx->Array.SecondaryColor.StrideB = size*sizeof(GLdouble);
348 break;
349 default:
350 _mesa_error( ctx, GL_INVALID_ENUM, "glSecondaryColorPointer(type)" );
351 return;
352 }
353 }
354 ctx->Array.SecondaryColor.Size = 3; /* hardwire */
355 ctx->Array.SecondaryColor.Type = type;
356 ctx->Array.SecondaryColor.Stride = stride;
357 ctx->Array.SecondaryColor.Ptr = (void *) ptr;
358 ctx->NewState |= _NEW_ARRAY;
359 ctx->Array.NewState |= _NEW_ARRAY_VERTEX;
360
361 if (ctx->Driver.SecondaryColorPointer)
362 ctx->Driver.SecondaryColorPointer( ctx, size, type, stride, ptr );
363 }
364
365
366
367 void
368 _mesa_TexCoordPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr)
369 {
370 GET_CURRENT_CONTEXT(ctx);
371 GLuint texUnit = ctx->Array.ActiveTexture;
372 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
373
374 if (size<1 || size>4) {
375 _mesa_error( ctx, GL_INVALID_VALUE, "glTexCoordPointer(size)" );
376 return;
377 }
378 if (stride<0) {
379 _mesa_error( ctx, GL_INVALID_VALUE, "glTexCoordPointer(stride)" );
380 return;
381 }
382
383 if (MESA_VERBOSE&(VERBOSE_VARRAY|VERBOSE_API))
384 fprintf(stderr, "glTexCoordPointer( unit %u sz %d type %s stride %d )\n",
385 texUnit,
386 size,
387 _mesa_lookup_enum_by_nr( type ),
388 stride);
389
390 ctx->Array.TexCoord[texUnit].StrideB = stride;
391 if (!stride) {
392 switch (type) {
393 case GL_SHORT:
394 ctx->Array.TexCoord[texUnit].StrideB = size*sizeof(GLshort);
395 break;
396 case GL_INT:
397 ctx->Array.TexCoord[texUnit].StrideB = size*sizeof(GLint);
398 break;
399 case GL_FLOAT:
400 ctx->Array.TexCoord[texUnit].StrideB = size*sizeof(GLfloat);
401 break;
402 case GL_DOUBLE:
403 ctx->Array.TexCoord[texUnit].StrideB = size*sizeof(GLdouble);
404 break;
405 default:
406 _mesa_error( ctx, GL_INVALID_ENUM, "glTexCoordPointer(type)" );
407 return;
408 }
409 }
410 ctx->Array.TexCoord[texUnit].Size = size;
411 ctx->Array.TexCoord[texUnit].Type = type;
412 ctx->Array.TexCoord[texUnit].Stride = stride;
413 ctx->Array.TexCoord[texUnit].Ptr = (void *) ptr;
414 ctx->NewState |= _NEW_ARRAY;
415 ctx->Array.NewState |= _NEW_ARRAY_VERTEX;
416
417 /* fprintf(stderr, "%s ptr %p\n", __FUNCTION__, ptr); */
418
419 if (ctx->Driver.TexCoordPointer)
420 ctx->Driver.TexCoordPointer( ctx, size, type, stride, ptr );
421 }
422
423
424
425
426 void
427 _mesa_EdgeFlagPointer(GLsizei stride, const void *vptr)
428 {
429 GET_CURRENT_CONTEXT(ctx);
430 const GLboolean *ptr = (GLboolean *)vptr;
431 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
432
433 if (stride<0) {
434 _mesa_error( ctx, GL_INVALID_VALUE, "glEdgeFlagPointer(stride)" );
435 return;
436 }
437 ctx->Array.EdgeFlag.Stride = stride;
438 ctx->Array.EdgeFlag.StrideB = stride ? stride : sizeof(GLboolean);
439 ctx->Array.EdgeFlag.Ptr = (GLboolean *) ptr;
440 ctx->NewState |= _NEW_ARRAY;
441 ctx->Array.NewState |= _NEW_ARRAY_VERTEX;
442
443 if (ctx->Driver.EdgeFlagPointer)
444 ctx->Driver.EdgeFlagPointer( ctx, stride, ptr );
445 }
446
447
448
449
450
451 void
452 _mesa_VertexPointerEXT(GLint size, GLenum type, GLsizei stride,
453 GLsizei count, const GLvoid *ptr)
454 {
455 (void) count;
456 _mesa_VertexPointer(size, type, stride, ptr);
457 }
458
459
460 void
461 _mesa_NormalPointerEXT(GLenum type, GLsizei stride, GLsizei count,
462 const GLvoid *ptr)
463 {
464 (void) count;
465 _mesa_NormalPointer(type, stride, ptr);
466 }
467
468
469 void
470 _mesa_ColorPointerEXT(GLint size, GLenum type, GLsizei stride, GLsizei count,
471 const GLvoid *ptr)
472 {
473 (void) count;
474 _mesa_ColorPointer(size, type, stride, ptr);
475 }
476
477
478 void
479 _mesa_IndexPointerEXT(GLenum type, GLsizei stride, GLsizei count,
480 const GLvoid *ptr)
481 {
482 (void) count;
483 _mesa_IndexPointer(type, stride, ptr);
484 }
485
486
487 void
488 _mesa_TexCoordPointerEXT(GLint size, GLenum type, GLsizei stride,
489 GLsizei count, const GLvoid *ptr)
490 {
491 (void) count;
492 _mesa_TexCoordPointer(size, type, stride, ptr);
493 }
494
495
496 void
497 _mesa_EdgeFlagPointerEXT(GLsizei stride, GLsizei count, const GLboolean *ptr)
498 {
499 (void) count;
500 _mesa_EdgeFlagPointer(stride, ptr);
501 }
502
503
504
505
506
507
508 void
509 _mesa_InterleavedArrays(GLenum format, GLsizei stride, const GLvoid *pointer)
510 {
511 GET_CURRENT_CONTEXT(ctx);
512 GLboolean tflag, cflag, nflag; /* enable/disable flags */
513 GLint tcomps, ccomps, vcomps; /* components per texcoord, color, vertex */
514
515 GLenum ctype = 0; /* color type */
516 GLint coffset = 0, noffset = 0, voffset;/* color, normal, vertex offsets */
517 GLint defstride; /* default stride */
518 GLint c, f;
519 GLint coordUnitSave;
520
521 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
522
523 f = sizeof(GLfloat);
524 c = f * ((4*sizeof(GLubyte) + (f-1)) / f);
525
526 if (stride<0) {
527 _mesa_error( ctx, GL_INVALID_VALUE, "glInterleavedArrays(stride)" );
528 return;
529 }
530
531 switch (format) {
532 case GL_V2F:
533 tflag = GL_FALSE; cflag = GL_FALSE; nflag = GL_FALSE;
534 tcomps = 0; ccomps = 0; vcomps = 2;
535 voffset = 0;
536 defstride = 2*f;
537 break;
538 case GL_V3F:
539 tflag = GL_FALSE; cflag = GL_FALSE; nflag = GL_FALSE;
540 tcomps = 0; ccomps = 0; vcomps = 3;
541 voffset = 0;
542 defstride = 3*f;
543 break;
544 case GL_C4UB_V2F:
545 tflag = GL_FALSE; cflag = GL_TRUE; nflag = GL_FALSE;
546 tcomps = 0; ccomps = 4; vcomps = 2;
547 ctype = GL_UNSIGNED_BYTE;
548 coffset = 0;
549 voffset = c;
550 defstride = c + 2*f;
551 break;
552 case GL_C4UB_V3F:
553 tflag = GL_FALSE; cflag = GL_TRUE; nflag = GL_FALSE;
554 tcomps = 0; ccomps = 4; vcomps = 3;
555 ctype = GL_UNSIGNED_BYTE;
556 coffset = 0;
557 voffset = c;
558 defstride = c + 3*f;
559 break;
560 case GL_C3F_V3F:
561 tflag = GL_FALSE; cflag = GL_TRUE; nflag = GL_FALSE;
562 tcomps = 0; ccomps = 3; vcomps = 3;
563 ctype = GL_FLOAT;
564 coffset = 0;
565 voffset = 3*f;
566 defstride = 6*f;
567 break;
568 case GL_N3F_V3F:
569 tflag = GL_FALSE; cflag = GL_FALSE; nflag = GL_TRUE;
570 tcomps = 0; ccomps = 0; vcomps = 3;
571 noffset = 0;
572 voffset = 3*f;
573 defstride = 6*f;
574 break;
575 case GL_C4F_N3F_V3F:
576 tflag = GL_FALSE; cflag = GL_TRUE; nflag = GL_TRUE;
577 tcomps = 0; ccomps = 4; vcomps = 3;
578 ctype = GL_FLOAT;
579 coffset = 0;
580 noffset = 4*f;
581 voffset = 7*f;
582 defstride = 10*f;
583 break;
584 case GL_T2F_V3F:
585 tflag = GL_TRUE; cflag = GL_FALSE; nflag = GL_FALSE;
586 tcomps = 2; ccomps = 0; vcomps = 3;
587 voffset = 2*f;
588 defstride = 5*f;
589 break;
590 case GL_T4F_V4F:
591 tflag = GL_TRUE; cflag = GL_FALSE; nflag = GL_FALSE;
592 tcomps = 4; ccomps = 0; vcomps = 4;
593 voffset = 4*f;
594 defstride = 8*f;
595 break;
596 case GL_T2F_C4UB_V3F:
597 tflag = GL_TRUE; cflag = GL_TRUE; nflag = GL_FALSE;
598 tcomps = 2; ccomps = 4; vcomps = 3;
599 ctype = GL_UNSIGNED_BYTE;
600 coffset = 2*f;
601 voffset = c+2*f;
602 defstride = c+5*f;
603 break;
604 case GL_T2F_C3F_V3F:
605 tflag = GL_TRUE; cflag = GL_TRUE; nflag = GL_FALSE;
606 tcomps = 2; ccomps = 3; vcomps = 3;
607 ctype = GL_FLOAT;
608 coffset = 2*f;
609 voffset = 5*f;
610 defstride = 8*f;
611 break;
612 case GL_T2F_N3F_V3F:
613 tflag = GL_TRUE; cflag = GL_FALSE; nflag = GL_TRUE;
614 tcomps = 2; ccomps = 0; vcomps = 3;
615 noffset = 2*f;
616 voffset = 5*f;
617 defstride = 8*f;
618 break;
619 case GL_T2F_C4F_N3F_V3F:
620 tflag = GL_TRUE; cflag = GL_TRUE; nflag = GL_TRUE;
621 tcomps = 2; ccomps = 4; vcomps = 3;
622 ctype = GL_FLOAT;
623 coffset = 2*f;
624 noffset = 6*f;
625 voffset = 9*f;
626 defstride = 12*f;
627 break;
628 case GL_T4F_C4F_N3F_V4F:
629 tflag = GL_TRUE; cflag = GL_TRUE; nflag = GL_TRUE;
630 tcomps = 4; ccomps = 4; vcomps = 4;
631 ctype = GL_FLOAT;
632 coffset = 4*f;
633 noffset = 8*f;
634 voffset = 11*f;
635 defstride = 15*f;
636 break;
637 default:
638 _mesa_error( ctx, GL_INVALID_ENUM, "glInterleavedArrays(format)" );
639 return;
640 }
641
642 if (stride==0) {
643 stride = defstride;
644 }
645
646 _mesa_DisableClientState( GL_EDGE_FLAG_ARRAY );
647 _mesa_DisableClientState( GL_INDEX_ARRAY );
648
649 /* Texcoords */
650 coordUnitSave = ctx->Array.ActiveTexture;
651 if (tflag) {
652 GLint i;
653 GLint factor = ctx->Array.TexCoordInterleaveFactor;
654 for (i = 0; i < factor; i++) {
655 _mesa_ClientActiveTextureARB( (GLenum) (GL_TEXTURE0_ARB + i) );
656 _mesa_EnableClientState( GL_TEXTURE_COORD_ARRAY );
657 _mesa_TexCoordPointer( tcomps, GL_FLOAT, stride,
658 (GLubyte *) pointer + i * coffset );
659 }
660 for (i = factor; i < (GLint) ctx->Const.MaxTextureUnits; i++) {
661 _mesa_ClientActiveTextureARB( (GLenum) (GL_TEXTURE0_ARB + i) );
662 _mesa_DisableClientState( GL_TEXTURE_COORD_ARRAY );
663 }
664 }
665 else {
666 GLint i;
667 for (i = 0; i < (GLint) ctx->Const.MaxTextureUnits; i++) {
668 _mesa_ClientActiveTextureARB( (GLenum) (GL_TEXTURE0_ARB + i) );
669 _mesa_DisableClientState( GL_TEXTURE_COORD_ARRAY );
670 }
671 }
672 /* Restore texture coordinate unit index */
673 _mesa_ClientActiveTextureARB( (GLenum) (GL_TEXTURE0_ARB + coordUnitSave) );
674
675
676 /* Color */
677 if (cflag) {
678 _mesa_EnableClientState( GL_COLOR_ARRAY );
679 _mesa_ColorPointer( ccomps, ctype, stride,
680 (GLubyte*) pointer + coffset );
681 }
682 else {
683 _mesa_DisableClientState( GL_COLOR_ARRAY );
684 }
685
686
687 /* Normals */
688 if (nflag) {
689 _mesa_EnableClientState( GL_NORMAL_ARRAY );
690 _mesa_NormalPointer( GL_FLOAT, stride,
691 (GLubyte*) pointer + noffset );
692 }
693 else {
694 _mesa_DisableClientState( GL_NORMAL_ARRAY );
695 }
696
697 _mesa_EnableClientState( GL_VERTEX_ARRAY );
698 _mesa_VertexPointer( vcomps, GL_FLOAT, stride,
699 (GLubyte *) pointer + voffset );
700 }
701
702
703
704 void
705 _mesa_LockArraysEXT(GLint first, GLsizei count)
706 {
707 GET_CURRENT_CONTEXT(ctx);
708 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
709
710 if (MESA_VERBOSE & VERBOSE_API)
711 fprintf(stderr, "glLockArrays %d %d\n", first, count);
712
713 if (first == 0 && count > 0 &&
714 count <= (GLint) ctx->Const.MaxArrayLockSize) {
715 ctx->Array.LockFirst = first;
716 ctx->Array.LockCount = count;
717 }
718 else {
719 ctx->Array.LockFirst = 0;
720 ctx->Array.LockCount = 0;
721 }
722
723 ctx->NewState |= _NEW_ARRAY;
724 ctx->Array.NewState |= _NEW_ARRAY_ALL;
725
726 if (ctx->Driver.LockArraysEXT)
727 ctx->Driver.LockArraysEXT( ctx, first, count );
728 }
729
730
731 void
732 _mesa_UnlockArraysEXT( void )
733 {
734 GET_CURRENT_CONTEXT(ctx);
735 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
736
737 if (MESA_VERBOSE & VERBOSE_API)
738 fprintf(stderr, "glUnlockArrays\n");
739
740 ctx->Array.LockFirst = 0;
741 ctx->Array.LockCount = 0;
742 ctx->NewState |= _NEW_ARRAY;
743 ctx->Array.NewState |= _NEW_ARRAY_ALL;
744
745 if (ctx->Driver.UnlockArraysEXT)
746 ctx->Driver.UnlockArraysEXT( ctx );
747 }