2 * Mesa 3-D graphics library
5 * Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
7 * 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:
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
17 * 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.
26 * Keith Whitwell <keith@tungstengraphics.com>
30 #include "api_arrayelt.h"
36 #include "glapioffsets.h"
39 typedef void (GLAPIENTRY
*array_func
)( const void * );
42 const struct gl_client_array
*array
;
46 typedef void (GLAPIENTRY
*attrib_func
)( GLuint indx
, const void *data
);
49 const struct gl_client_array
*array
;
56 AEattrib attribs
[VERT_ATTRIB_MAX
+ 1];
60 #define AE_CONTEXT(ctx) ((AEcontext *)(ctx)->aelt_context)
64 * Convert GL_BYTE, GL_UNSIGNED_BYTE, .. GL_DOUBLE into an integer
65 * in the range [0, 7]. Luckily these type tokens are sequentially
66 * numbered in gl.h, except for GL_DOUBLE.
68 #define TYPE_IDX(t) ( (t) == GL_DOUBLE ? 7 : (t) & 7 )
70 static const int ColorFuncs
[2][8] = {
93 static const int VertexFuncs
[3][8] = {
126 static const int IndexFuncs
[8] = {
137 static const int NormalFuncs
[8] = {
148 static const int SecondaryColorFuncs
[8] = {
149 _gloffset_SecondaryColor3bvEXT
,
150 _gloffset_SecondaryColor3ubvEXT
,
151 _gloffset_SecondaryColor3svEXT
,
152 _gloffset_SecondaryColor3usvEXT
,
153 _gloffset_SecondaryColor3ivEXT
,
154 _gloffset_SecondaryColor3uivEXT
,
155 _gloffset_SecondaryColor3fvEXT
,
156 _gloffset_SecondaryColor3dvEXT
,
159 static const int FogCoordFuncs
[8] = {
166 _gloffset_FogCoordfvEXT
,
167 _gloffset_FogCoorddvEXT
170 /**********************************************************************/
172 /* GL_BYTE attributes */
174 static void GLAPIENTRY
VertexAttrib1NbvNV(GLuint index
, const GLbyte
*v
)
176 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, BYTE_TO_FLOAT(v
[0])));
179 static void GLAPIENTRY
VertexAttrib1bvNV(GLuint index
, const GLbyte
*v
)
181 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, v
[0]));
184 static void GLAPIENTRY
VertexAttrib2NbvNV(GLuint index
, const GLbyte
*v
)
186 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, BYTE_TO_FLOAT(v
[0]), BYTE_TO_FLOAT(v
[1])));
189 static void GLAPIENTRY
VertexAttrib2bvNV(GLuint index
, const GLbyte
*v
)
191 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, v
[0], v
[1]));
194 static void GLAPIENTRY
VertexAttrib3NbvNV(GLuint index
, const GLbyte
*v
)
196 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, BYTE_TO_FLOAT(v
[0]),
198 BYTE_TO_FLOAT(v
[2])));
201 static void GLAPIENTRY
VertexAttrib3bvNV(GLuint index
, const GLbyte
*v
)
203 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, v
[0], v
[1], v
[2]));
206 static void GLAPIENTRY
VertexAttrib4NbvNV(GLuint index
, const GLbyte
*v
)
208 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, BYTE_TO_FLOAT(v
[0]),
211 BYTE_TO_FLOAT(v
[3])));
214 static void GLAPIENTRY
VertexAttrib4bvNV(GLuint index
, const GLbyte
*v
)
216 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, v
[0], v
[1], v
[2], v
[3]));
219 /* GL_UNSIGNED_BYTE attributes */
221 static void GLAPIENTRY
VertexAttrib1NubvNV(GLuint index
, const GLubyte
*v
)
223 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, UBYTE_TO_FLOAT(v
[0])));
226 static void GLAPIENTRY
VertexAttrib1ubvNV(GLuint index
, const GLubyte
*v
)
228 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, v
[0]));
231 static void GLAPIENTRY
VertexAttrib2NubvNV(GLuint index
, const GLubyte
*v
)
233 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, UBYTE_TO_FLOAT(v
[0]),
234 UBYTE_TO_FLOAT(v
[1])));
237 static void GLAPIENTRY
VertexAttrib2ubvNV(GLuint index
, const GLubyte
*v
)
239 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, v
[0], v
[1]));
242 static void GLAPIENTRY
VertexAttrib3NubvNV(GLuint index
, const GLubyte
*v
)
244 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, UBYTE_TO_FLOAT(v
[0]),
245 UBYTE_TO_FLOAT(v
[1]),
246 UBYTE_TO_FLOAT(v
[2])));
248 static void GLAPIENTRY
VertexAttrib3ubvNV(GLuint index
, const GLubyte
*v
)
250 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, v
[0], v
[1], v
[2]));
253 static void GLAPIENTRY
VertexAttrib4NubvNV(GLuint index
, const GLubyte
*v
)
255 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, UBYTE_TO_FLOAT(v
[0]),
256 UBYTE_TO_FLOAT(v
[1]),
257 UBYTE_TO_FLOAT(v
[2]),
258 UBYTE_TO_FLOAT(v
[3])));
261 static void GLAPIENTRY
VertexAttrib4ubvNV(GLuint index
, const GLubyte
*v
)
263 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, v
[0], v
[1], v
[2], v
[3]));
266 /* GL_SHORT attributes */
268 static void GLAPIENTRY
VertexAttrib1NsvNV(GLuint index
, const GLshort
*v
)
270 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, SHORT_TO_FLOAT(v
[0])));
273 static void GLAPIENTRY
VertexAttrib1svNV(GLuint index
, const GLshort
*v
)
275 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, v
[0]));
278 static void GLAPIENTRY
VertexAttrib2NsvNV(GLuint index
, const GLshort
*v
)
280 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, SHORT_TO_FLOAT(v
[0]),
281 SHORT_TO_FLOAT(v
[1])));
284 static void GLAPIENTRY
VertexAttrib2svNV(GLuint index
, const GLshort
*v
)
286 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, v
[0], v
[1]));
289 static void GLAPIENTRY
VertexAttrib3NsvNV(GLuint index
, const GLshort
*v
)
291 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, SHORT_TO_FLOAT(v
[0]),
292 SHORT_TO_FLOAT(v
[1]),
293 SHORT_TO_FLOAT(v
[2])));
296 static void GLAPIENTRY
VertexAttrib3svNV(GLuint index
, const GLshort
*v
)
298 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, v
[0], v
[1], v
[2]));
301 static void GLAPIENTRY
VertexAttrib4NsvNV(GLuint index
, const GLshort
*v
)
303 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, SHORT_TO_FLOAT(v
[0]),
304 SHORT_TO_FLOAT(v
[1]),
305 SHORT_TO_FLOAT(v
[2]),
306 SHORT_TO_FLOAT(v
[3])));
309 static void GLAPIENTRY
VertexAttrib4svNV(GLuint index
, const GLshort
*v
)
311 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, v
[0], v
[1], v
[2], v
[3]));
314 /* GL_UNSIGNED_SHORT attributes */
316 static void GLAPIENTRY
VertexAttrib1NusvNV(GLuint index
, const GLushort
*v
)
318 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, USHORT_TO_FLOAT(v
[0])));
321 static void GLAPIENTRY
VertexAttrib1usvNV(GLuint index
, const GLushort
*v
)
323 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, v
[0]));
326 static void GLAPIENTRY
VertexAttrib2NusvNV(GLuint index
, const GLushort
*v
)
328 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, USHORT_TO_FLOAT(v
[0]),
329 USHORT_TO_FLOAT(v
[1])));
332 static void GLAPIENTRY
VertexAttrib2usvNV(GLuint index
, const GLushort
*v
)
334 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, v
[0], v
[1]));
337 static void GLAPIENTRY
VertexAttrib3NusvNV(GLuint index
, const GLushort
*v
)
339 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, USHORT_TO_FLOAT(v
[0]),
340 USHORT_TO_FLOAT(v
[1]),
341 USHORT_TO_FLOAT(v
[2])));
344 static void GLAPIENTRY
VertexAttrib3usvNV(GLuint index
, const GLushort
*v
)
346 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, v
[0], v
[1], v
[2]));
349 static void GLAPIENTRY
VertexAttrib4NusvNV(GLuint index
, const GLushort
*v
)
351 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, USHORT_TO_FLOAT(v
[0]),
352 USHORT_TO_FLOAT(v
[1]),
353 USHORT_TO_FLOAT(v
[2]),
354 USHORT_TO_FLOAT(v
[3])));
357 static void GLAPIENTRY
VertexAttrib4usvNV(GLuint index
, const GLushort
*v
)
359 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, v
[0], v
[1], v
[2], v
[3]));
362 /* GL_INT attributes */
364 static void GLAPIENTRY
VertexAttrib1NivNV(GLuint index
, const GLint
*v
)
366 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, INT_TO_FLOAT(v
[0])));
369 static void GLAPIENTRY
VertexAttrib1ivNV(GLuint index
, const GLint
*v
)
371 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, v
[0]));
374 static void GLAPIENTRY
VertexAttrib2NivNV(GLuint index
, const GLint
*v
)
376 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, INT_TO_FLOAT(v
[0]),
377 INT_TO_FLOAT(v
[1])));
380 static void GLAPIENTRY
VertexAttrib2ivNV(GLuint index
, const GLint
*v
)
382 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, v
[0], v
[1]));
385 static void GLAPIENTRY
VertexAttrib3NivNV(GLuint index
, const GLint
*v
)
387 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, INT_TO_FLOAT(v
[0]),
389 INT_TO_FLOAT(v
[2])));
392 static void GLAPIENTRY
VertexAttrib3ivNV(GLuint index
, const GLint
*v
)
394 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, v
[0], v
[1], v
[2]));
397 static void GLAPIENTRY
VertexAttrib4NivNV(GLuint index
, const GLint
*v
)
399 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, INT_TO_FLOAT(v
[0]),
402 INT_TO_FLOAT(v
[3])));
405 static void GLAPIENTRY
VertexAttrib4ivNV(GLuint index
, const GLint
*v
)
407 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, v
[0], v
[1], v
[2], v
[3]));
410 /* GL_UNSIGNED_INT attributes */
412 static void GLAPIENTRY
VertexAttrib1NuivNV(GLuint index
, const GLuint
*v
)
414 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, UINT_TO_FLOAT(v
[0])));
417 static void GLAPIENTRY
VertexAttrib1uivNV(GLuint index
, const GLuint
*v
)
419 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, v
[0]));
422 static void GLAPIENTRY
VertexAttrib2NuivNV(GLuint index
, const GLuint
*v
)
424 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, UINT_TO_FLOAT(v
[0]),
425 UINT_TO_FLOAT(v
[1])));
428 static void GLAPIENTRY
VertexAttrib2uivNV(GLuint index
, const GLuint
*v
)
430 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, v
[0], v
[1]));
433 static void GLAPIENTRY
VertexAttrib3NuivNV(GLuint index
, const GLuint
*v
)
435 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, UINT_TO_FLOAT(v
[0]),
437 UINT_TO_FLOAT(v
[2])));
440 static void GLAPIENTRY
VertexAttrib3uivNV(GLuint index
, const GLuint
*v
)
442 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, v
[0], v
[1], v
[2]));
445 static void GLAPIENTRY
VertexAttrib4NuivNV(GLuint index
, const GLuint
*v
)
447 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, UINT_TO_FLOAT(v
[0]),
450 UINT_TO_FLOAT(v
[3])));
453 static void GLAPIENTRY
VertexAttrib4uivNV(GLuint index
, const GLuint
*v
)
455 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, v
[0], v
[1], v
[2], v
[3]));
458 /* GL_FLOAT attributes */
460 static void GLAPIENTRY
VertexAttrib1fvNV(GLuint index
, const GLfloat
*v
)
462 CALL_VertexAttrib1fvNV(GET_DISPATCH(), (index
, v
));
465 static void GLAPIENTRY
VertexAttrib2fvNV(GLuint index
, const GLfloat
*v
)
467 CALL_VertexAttrib2fvNV(GET_DISPATCH(), (index
, v
));
470 static void GLAPIENTRY
VertexAttrib3fvNV(GLuint index
, const GLfloat
*v
)
472 CALL_VertexAttrib3fvNV(GET_DISPATCH(), (index
, v
));
475 static void GLAPIENTRY
VertexAttrib4fvNV(GLuint index
, const GLfloat
*v
)
477 CALL_VertexAttrib4fvNV(GET_DISPATCH(), (index
, v
));
480 /* GL_DOUBLE attributes */
482 static void GLAPIENTRY
VertexAttrib1dvNV(GLuint index
, const GLdouble
*v
)
484 CALL_VertexAttrib1dvNV(GET_DISPATCH(), (index
, v
));
487 static void GLAPIENTRY
VertexAttrib2dvNV(GLuint index
, const GLdouble
*v
)
489 CALL_VertexAttrib2dvNV(GET_DISPATCH(), (index
, v
));
492 static void GLAPIENTRY
VertexAttrib3dvNV(GLuint index
, const GLdouble
*v
)
494 CALL_VertexAttrib3dvNV(GET_DISPATCH(), (index
, v
));
497 static void GLAPIENTRY
VertexAttrib4dvNV(GLuint index
, const GLdouble
*v
)
499 CALL_VertexAttrib4dvNV(GET_DISPATCH(), (index
, v
));
504 * Array [size][type] of VertexAttrib functions
506 static attrib_func AttribFuncsNV
[2][4][8] = {
511 (attrib_func
) VertexAttrib1bvNV
,
512 (attrib_func
) VertexAttrib1ubvNV
,
513 (attrib_func
) VertexAttrib1svNV
,
514 (attrib_func
) VertexAttrib1usvNV
,
515 (attrib_func
) VertexAttrib1ivNV
,
516 (attrib_func
) VertexAttrib1uivNV
,
517 (attrib_func
) VertexAttrib1fvNV
,
518 (attrib_func
) VertexAttrib1dvNV
522 (attrib_func
) VertexAttrib2bvNV
,
523 (attrib_func
) VertexAttrib2ubvNV
,
524 (attrib_func
) VertexAttrib2svNV
,
525 (attrib_func
) VertexAttrib2usvNV
,
526 (attrib_func
) VertexAttrib2ivNV
,
527 (attrib_func
) VertexAttrib2uivNV
,
528 (attrib_func
) VertexAttrib2fvNV
,
529 (attrib_func
) VertexAttrib2dvNV
533 (attrib_func
) VertexAttrib3bvNV
,
534 (attrib_func
) VertexAttrib3ubvNV
,
535 (attrib_func
) VertexAttrib3svNV
,
536 (attrib_func
) VertexAttrib3usvNV
,
537 (attrib_func
) VertexAttrib3ivNV
,
538 (attrib_func
) VertexAttrib3uivNV
,
539 (attrib_func
) VertexAttrib3fvNV
,
540 (attrib_func
) VertexAttrib3dvNV
544 (attrib_func
) VertexAttrib4bvNV
,
545 (attrib_func
) VertexAttrib4ubvNV
,
546 (attrib_func
) VertexAttrib4svNV
,
547 (attrib_func
) VertexAttrib4usvNV
,
548 (attrib_func
) VertexAttrib4ivNV
,
549 (attrib_func
) VertexAttrib4uivNV
,
550 (attrib_func
) VertexAttrib4fvNV
,
551 (attrib_func
) VertexAttrib4dvNV
555 /* normalized (except for float/double) */
558 (attrib_func
) VertexAttrib1NbvNV
,
559 (attrib_func
) VertexAttrib1NubvNV
,
560 (attrib_func
) VertexAttrib1NsvNV
,
561 (attrib_func
) VertexAttrib1NusvNV
,
562 (attrib_func
) VertexAttrib1NivNV
,
563 (attrib_func
) VertexAttrib1NuivNV
,
564 (attrib_func
) VertexAttrib1fvNV
,
565 (attrib_func
) VertexAttrib1dvNV
569 (attrib_func
) VertexAttrib2NbvNV
,
570 (attrib_func
) VertexAttrib2NubvNV
,
571 (attrib_func
) VertexAttrib2NsvNV
,
572 (attrib_func
) VertexAttrib2NusvNV
,
573 (attrib_func
) VertexAttrib2NivNV
,
574 (attrib_func
) VertexAttrib2NuivNV
,
575 (attrib_func
) VertexAttrib2fvNV
,
576 (attrib_func
) VertexAttrib2dvNV
580 (attrib_func
) VertexAttrib3NbvNV
,
581 (attrib_func
) VertexAttrib3NubvNV
,
582 (attrib_func
) VertexAttrib3NsvNV
,
583 (attrib_func
) VertexAttrib3NusvNV
,
584 (attrib_func
) VertexAttrib3NivNV
,
585 (attrib_func
) VertexAttrib3NuivNV
,
586 (attrib_func
) VertexAttrib3fvNV
,
587 (attrib_func
) VertexAttrib3dvNV
591 (attrib_func
) VertexAttrib4NbvNV
,
592 (attrib_func
) VertexAttrib4NubvNV
,
593 (attrib_func
) VertexAttrib4NsvNV
,
594 (attrib_func
) VertexAttrib4NusvNV
,
595 (attrib_func
) VertexAttrib4NivNV
,
596 (attrib_func
) VertexAttrib4NuivNV
,
597 (attrib_func
) VertexAttrib4fvNV
,
598 (attrib_func
) VertexAttrib4dvNV
603 /**********************************************************************/
606 GLboolean
_ae_create_context( GLcontext
*ctx
)
608 if (ctx
->aelt_context
)
611 ctx
->aelt_context
= MALLOC( sizeof(AEcontext
) );
612 if (!ctx
->aelt_context
)
615 AE_CONTEXT(ctx
)->NewState
= ~0;
620 void _ae_destroy_context( GLcontext
*ctx
)
622 if ( AE_CONTEXT( ctx
) ) {
623 FREE( ctx
->aelt_context
);
624 ctx
->aelt_context
= NULL
;
630 * Make a list of per-vertex functions to call for each glArrayElement call.
631 * These functions access the array data (i.e. glVertex, glColor, glNormal,
633 * Note: this may be called during display list construction.
635 static void _ae_update_state( GLcontext
*ctx
)
637 AEcontext
*actx
= AE_CONTEXT(ctx
);
638 AEarray
*aa
= actx
->arrays
;
639 AEattrib
*at
= actx
->attribs
;
642 /* conventional vertex arrays */
643 if (ctx
->Array
.Index
.Enabled
) {
644 aa
->array
= &ctx
->Array
.Index
;
645 aa
->offset
= IndexFuncs
[TYPE_IDX(aa
->array
->Type
)];
648 if (ctx
->Array
.EdgeFlag
.Enabled
) {
649 aa
->array
= &ctx
->Array
.EdgeFlag
;
650 aa
->offset
= _gloffset_EdgeFlagv
;
653 if (ctx
->Array
.Normal
.Enabled
) {
654 aa
->array
= &ctx
->Array
.Normal
;
655 aa
->offset
= NormalFuncs
[TYPE_IDX(aa
->array
->Type
)];
658 if (ctx
->Array
.Color
.Enabled
) {
659 aa
->array
= &ctx
->Array
.Color
;
660 aa
->offset
= ColorFuncs
[aa
->array
->Size
-3][TYPE_IDX(aa
->array
->Type
)];
663 if (ctx
->Array
.SecondaryColor
.Enabled
) {
664 aa
->array
= &ctx
->Array
.SecondaryColor
;
665 aa
->offset
= SecondaryColorFuncs
[TYPE_IDX(aa
->array
->Type
)];
668 if (ctx
->Array
.FogCoord
.Enabled
) {
669 aa
->array
= &ctx
->Array
.FogCoord
;
670 aa
->offset
= FogCoordFuncs
[TYPE_IDX(aa
->array
->Type
)];
673 for (i
= 0; i
< ctx
->Const
.MaxTextureCoordUnits
; i
++) {
674 if (ctx
->Array
.TexCoord
[i
].Enabled
) {
675 /* NOTE: we use generic glVertexAttrib functions here.
676 * If we ever de-alias conventional/generic vertex attribs this
677 * will have to change.
679 struct gl_client_array
*attribArray
= &ctx
->Array
.TexCoord
[i
];
680 at
->array
= attribArray
;
681 at
->func
= AttribFuncsNV
[at
->array
->Normalized
][at
->array
->Size
-1][TYPE_IDX(at
->array
->Type
)];
682 at
->index
= VERT_ATTRIB_TEX0
+ i
;
687 /* generic vertex attribute arrays */
688 for (i
= 1; i
< VERT_ATTRIB_MAX
; i
++) { /* skip zero! */
689 if (ctx
->Array
.VertexAttrib
[i
].Enabled
) {
690 struct gl_client_array
*attribArray
= &ctx
->Array
.VertexAttrib
[i
];
691 at
->array
= attribArray
;
692 /* Note: we can't grab the _glapi_Dispatch->VertexAttrib1fvNV
693 * function pointer here (for float arrays) since the pointer may
694 * change from one execution of _ae_loopback_array_elt() to
695 * the next. Doing so caused UT to break.
697 at
->func
= AttribFuncsNV
[at
->array
->Normalized
][at
->array
->Size
-1][TYPE_IDX(at
->array
->Type
)];
703 /* finally, vertex position */
704 if (ctx
->Array
.VertexAttrib
[0].Enabled
) {
705 /* Use glVertex(v) instead of glVertexAttrib(0, v) to be sure it's
706 * issued as the last (proviking) attribute).
708 aa
->array
= &ctx
->Array
.VertexAttrib
[0];
709 assert(aa
->array
->Size
>= 2); /* XXX fix someday? */
710 aa
->offset
= VertexFuncs
[aa
->array
->Size
-2][TYPE_IDX(aa
->array
->Type
)];
713 else if (ctx
->Array
.Vertex
.Enabled
) {
714 aa
->array
= &ctx
->Array
.Vertex
;
715 aa
->offset
= VertexFuncs
[aa
->array
->Size
-2][TYPE_IDX(aa
->array
->Type
)];
719 ASSERT(at
- actx
->attribs
<= VERT_ATTRIB_MAX
);
720 ASSERT(aa
- actx
->arrays
< 32);
721 at
->func
= NULL
; /* terminate the list */
722 aa
->offset
= -1; /* terminate the list */
729 * Called via glArrayElement() and glDrawArrays().
730 * Issue the glNormal, glVertex, glColor, glVertexAttrib, etc functions
731 * for all enabled vertex arrays (for elt-th element).
732 * Note: this may be called during display list construction.
734 void GLAPIENTRY
_ae_loopback_array_elt( GLint elt
)
736 GET_CURRENT_CONTEXT(ctx
);
737 const AEcontext
*actx
= AE_CONTEXT(ctx
);
740 const struct _glapi_table
* const disp
= GET_DISPATCH();
744 _ae_update_state( ctx
);
746 /* generic attributes */
747 for (at
= actx
->attribs
; at
->func
; at
++) {
748 const GLubyte
*src
= at
->array
->BufferObj
->Data
749 + (uintptr_t) at
->array
->Ptr
750 + elt
* at
->array
->StrideB
;
751 at
->func( at
->index
, src
);
754 /* conventional arrays */
755 for (aa
= actx
->arrays
; aa
->offset
!= -1 ; aa
++) {
756 const GLubyte
*src
= aa
->array
->BufferObj
->Data
757 + (uintptr_t) aa
->array
->Ptr
758 + elt
* aa
->array
->StrideB
;
759 CALL_by_offset( disp
, (array_func
), aa
->offset
,
760 ((const void *) src
) );
765 void _ae_invalidate_state( GLcontext
*ctx
, GLuint new_state
)
767 AE_CONTEXT(ctx
)->NewState
|= new_state
;