fixed a bunch of g++ warnings/errors. Compiling with g++ can help find lots of poten...
[mesa.git] / src / mesa / main / varray.c
1 /* $Id: varray.c,v 1.38 2001/03/07 05:06:12 brianp Exp $ */
2
3 /*
4 * Mesa 3-D graphics library
5 * Version: 3.5
6 *
7 * Copyright (C) 1999-2000 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.Type = type;
141 ctx->Array.Normal.Stride = stride;
142 ctx->Array.Normal.Ptr = (void *) ptr;
143 ctx->NewState |= _NEW_ARRAY;
144 ctx->Array.NewState |= _NEW_ARRAY_VERTEX;
145
146 if (ctx->Driver.NormalPointer)
147 ctx->Driver.NormalPointer( ctx, type, stride, ptr );
148 }
149
150
151
152 void
153 _mesa_ColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr)
154 {
155 GET_CURRENT_CONTEXT(ctx);
156 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
157
158 if (size<3 || size>4) {
159 _mesa_error( ctx, GL_INVALID_VALUE, "glColorPointer(size)" );
160 return;
161 }
162 if (stride<0) {
163 _mesa_error( ctx, GL_INVALID_VALUE, "glColorPointer(stride)" );
164 return;
165 }
166
167 if (MESA_VERBOSE&(VERBOSE_VARRAY|VERBOSE_API))
168 fprintf(stderr, "glColorPointer( sz %d type %s stride %d )\n", size,
169 _mesa_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 _mesa_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;
208 ctx->NewState |= _NEW_ARRAY;
209 ctx->Array.NewState |= _NEW_ARRAY_VERTEX;
210
211 if (ctx->Driver.ColorPointer)
212 ctx->Driver.ColorPointer( ctx, size, type, stride, ptr );
213 }
214
215
216
217 void
218 _mesa_FogCoordPointerEXT(GLenum type, GLsizei stride, const GLvoid *ptr)
219 {
220 GET_CURRENT_CONTEXT(ctx);
221 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
222
223 if (stride<0) {
224 _mesa_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 _mesa_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;
245 ctx->NewState |= _NEW_ARRAY;
246 ctx->Array.NewState |= _NEW_ARRAY_VERTEX;
247
248 if (ctx->Driver.FogCoordPointer)
249 ctx->Driver.FogCoordPointer( ctx, type, stride, ptr );
250 }
251
252
253 void
254 _mesa_IndexPointer(GLenum type, GLsizei stride, const GLvoid *ptr)
255 {
256 GET_CURRENT_CONTEXT(ctx);
257 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
258
259 if (stride<0) {
260 _mesa_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 _mesa_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;
290 ctx->NewState |= _NEW_ARRAY;
291 ctx->Array.NewState |= _NEW_ARRAY_VERTEX;
292
293 if (ctx->Driver.IndexPointer)
294 ctx->Driver.IndexPointer( ctx, type, stride, ptr );
295 }
296
297
298 void
299 _mesa_SecondaryColorPointerEXT(GLint size, GLenum type,
300 GLsizei stride, const GLvoid *ptr)
301 {
302 GET_CURRENT_CONTEXT(ctx);
303 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
304
305 if (size != 3 && size != 4) {
306 _mesa_error( ctx, GL_INVALID_VALUE, "glColorPointer(size)" );
307 return;
308 }
309 if (stride<0) {
310 _mesa_error( ctx, GL_INVALID_VALUE, "glColorPointer(stride)" );
311 return;
312 }
313
314 if (MESA_VERBOSE&(VERBOSE_VARRAY|VERBOSE_API))
315 fprintf(stderr, "glColorPointer( sz %d type %s stride %d )\n", size,
316 _mesa_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 _mesa_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;
355 ctx->NewState |= _NEW_ARRAY;
356 ctx->Array.NewState |= _NEW_ARRAY_VERTEX;
357
358 if (ctx->Driver.SecondaryColorPointer)
359 ctx->Driver.SecondaryColorPointer( ctx, size, type, stride, ptr );
360 }
361
362
363
364 void
365 _mesa_TexCoordPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr)
366 {
367 GET_CURRENT_CONTEXT(ctx);
368 GLuint texUnit = ctx->Array.ActiveTexture;
369 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
370
371 if (size<1 || size>4) {
372 _mesa_error( ctx, GL_INVALID_VALUE, "glTexCoordPointer(size)" );
373 return;
374 }
375 if (stride<0) {
376 _mesa_error( ctx, GL_INVALID_VALUE, "glTexCoordPointer(stride)" );
377 return;
378 }
379
380 if (MESA_VERBOSE&(VERBOSE_VARRAY|VERBOSE_API))
381 fprintf(stderr, "glTexCoordPointer( unit %u sz %d type %s stride %d )\n",
382 texUnit,
383 size,
384 _mesa_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 _mesa_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;
411 ctx->NewState |= _NEW_ARRAY;
412 ctx->Array.NewState |= _NEW_ARRAY_VERTEX;
413
414 /* fprintf(stderr, "%s ptr %p\n", __FUNCTION__, ptr); */
415
416 if (ctx->Driver.TexCoordPointer)
417 ctx->Driver.TexCoordPointer( ctx, size, type, stride, ptr );
418 }
419
420
421
422
423 void
424 _mesa_EdgeFlagPointer(GLsizei stride, const void *vptr)
425 {
426 GET_CURRENT_CONTEXT(ctx);
427 const GLboolean *ptr = (GLboolean *)vptr;
428 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
429
430 if (stride<0) {
431 _mesa_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;
437 ctx->NewState |= _NEW_ARRAY;
438 ctx->Array.NewState |= _NEW_ARRAY_VERTEX;
439
440 if (ctx->Driver.EdgeFlagPointer)
441 ctx->Driver.EdgeFlagPointer( ctx, stride, ptr );
442 }
443
444
445
446
447
448 void
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
457 void
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
466 void
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
475 void
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
484 void
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
493 void
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
504
505 void
506 _mesa_InterleavedArrays(GLenum format, GLsizei stride, const GLvoid *pointer)
507 {
508 GET_CURRENT_CONTEXT(ctx);
509 GLboolean tflag, cflag, nflag; /* enable/disable flags */
510 GLint tcomps, ccomps, vcomps; /* components per texcoord, color, vertex */
511
512 GLenum ctype = 0; /* color type */
513 GLint coffset = 0, noffset = 0, voffset;/* color, normal, vertex offsets */
514 GLint defstride; /* default stride */
515 GLint c, f;
516 GLint coordUnitSave;
517
518 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
519
520 f = sizeof(GLfloat);
521 c = f * ((4*sizeof(GLubyte) + (f-1)) / f);
522
523 if (stride<0) {
524 _mesa_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 _mesa_error( ctx, GL_INVALID_ENUM, "glInterleavedArrays(format)" );
636 return;
637 }
638
639 if (stride==0) {
640 stride = defstride;
641 }
642
643 _mesa_DisableClientState( GL_EDGE_FLAG_ARRAY );
644 _mesa_DisableClientState( GL_INDEX_ARRAY );
645
646 /* Texcoords */
647 coordUnitSave = ctx->Array.ActiveTexture;
648 if (tflag) {
649 GLint i;
650 GLint factor = ctx->Array.TexCoordInterleaveFactor;
651 for (i = 0; i < factor; i++) {
652 _mesa_ClientActiveTextureARB( (GLenum) (GL_TEXTURE0_ARB + i) );
653 _mesa_EnableClientState( GL_TEXTURE_COORD_ARRAY );
654 _mesa_TexCoordPointer( tcomps, GL_FLOAT, stride,
655 (GLubyte *) pointer + i * coffset );
656 }
657 for (i = factor; i < (GLint) ctx->Const.MaxTextureUnits; i++) {
658 _mesa_ClientActiveTextureARB( (GLenum) (GL_TEXTURE0_ARB + i) );
659 _mesa_DisableClientState( GL_TEXTURE_COORD_ARRAY );
660 }
661 }
662 else {
663 GLint i;
664 for (i = 0; i < (GLint) ctx->Const.MaxTextureUnits; i++) {
665 _mesa_ClientActiveTextureARB( (GLenum) (GL_TEXTURE0_ARB + i) );
666 _mesa_DisableClientState( GL_TEXTURE_COORD_ARRAY );
667 }
668 }
669 /* Restore texture coordinate unit index */
670 _mesa_ClientActiveTextureARB( (GLenum) (GL_TEXTURE0_ARB + coordUnitSave) );
671
672
673 /* Color */
674 if (cflag) {
675 _mesa_EnableClientState( GL_COLOR_ARRAY );
676 _mesa_ColorPointer( ccomps, ctype, stride,
677 (GLubyte*) pointer + coffset );
678 }
679 else {
680 _mesa_DisableClientState( GL_COLOR_ARRAY );
681 }
682
683
684 /* Normals */
685 if (nflag) {
686 _mesa_EnableClientState( GL_NORMAL_ARRAY );
687 _mesa_NormalPointer( GL_FLOAT, stride,
688 (GLubyte*) pointer + noffset );
689 }
690 else {
691 _mesa_DisableClientState( GL_NORMAL_ARRAY );
692 }
693
694 _mesa_EnableClientState( GL_VERTEX_ARRAY );
695 _mesa_VertexPointer( vcomps, GL_FLOAT, stride,
696 (GLubyte *) pointer + voffset );
697 }
698
699
700
701 void
702 _mesa_LockArraysEXT(GLint first, GLsizei count)
703 {
704 GET_CURRENT_CONTEXT(ctx);
705 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
706
707 if (MESA_VERBOSE & VERBOSE_API)
708 fprintf(stderr, "glLockArrays %d %d\n", first, count);
709
710 if (first == 0 && count > 0 &&
711 count <= (GLint) ctx->Const.MaxArrayLockSize) {
712 ctx->Array.LockFirst = first;
713 ctx->Array.LockCount = count;
714 }
715 else {
716 ctx->Array.LockFirst = 0;
717 ctx->Array.LockCount = 0;
718 }
719
720 ctx->NewState |= _NEW_ARRAY;
721 ctx->Array.NewState |= _NEW_ARRAY_ALL;
722
723 if (ctx->Driver.LockArraysEXT)
724 ctx->Driver.LockArraysEXT( ctx, first, count );
725 }
726
727
728 void
729 _mesa_UnlockArraysEXT( void )
730 {
731 GET_CURRENT_CONTEXT(ctx);
732 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
733
734 if (MESA_VERBOSE & VERBOSE_API)
735 fprintf(stderr, "glUnlockArrays\n");
736
737 ctx->Array.LockFirst = 0;
738 ctx->Array.LockCount = 0;
739 ctx->NewState |= _NEW_ARRAY;
740 ctx->Array.NewState |= _NEW_ARRAY_ALL;
741
742 if (ctx->Driver.UnlockArraysEXT)
743 ctx->Driver.UnlockArraysEXT( ctx );
744 }