api_arrayelt.c revision cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290
1cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell#include "glheader.h"
2cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell#include "api_noop.h"
3cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell#include "context.h"
4cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell#include "colormac.h"
5cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell#include "light.h"
6cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell#include "macros.h"
7cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell#include "mmath.h"
8cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell#include "mtypes.h"
9cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell
10cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell
11cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwelltypedef struct {
12cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   GLint unit;
13cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   struct gl_client_array *array;
14cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   void *func;
15cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell} AAtexarray;
16cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell
17cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell
18cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwelltypedef struct {
19cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   struct gl_client_array *array;
20cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   void *func;
21cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell} AAarray;
22cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell
23cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwelltypedef struct {
24cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   AAtexarray texarrays[MAX_TEXTURE_UNITS+1];
25cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   AAarray arrays[10];
26cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   GLuint NewState;
27cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell} AAcontext;
28cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell
29cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell
30cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwellstatic void *colorfuncs[2][7] = {
31cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   { glColor3bv,
32cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell     glColor3ub,
33cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell     glColor3sv,
34cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell     glColor3usv,
35cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell     glColor3iv,
36cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell     glColor3fv,
37cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell     glColor3dv },
38cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell
39cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   { glColor4bv,
40cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell     glColor4ub,
41cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell     glColor4sv,
42cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell     glColor4usv,
43cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell     glColor4iv,
44cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell     glColor4fv,
45cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell     glColor4dv }
46cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell};
47cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell
48cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwellstatic void *vertexfuncs[3][7] = {
49cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   { glVertex3bv,
50cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell     glVertex3ub,
51cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell     glVertex3sv,
52cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell     glVertex3usv,
53cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell     glVertex3iv,
54cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell     glVertex3fv,
55cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell     glVertex3dv },
56cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell
57cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   { glVertex3bv,
58cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell     glVertex3ub,
59cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell     glVertex3sv,
60cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell     glVertex3usv,
61cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell     glVertex3iv,
62cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell     glVertex3fv,
63cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell     glVertex3dv },
64cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell
65cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   { glVertex4bv,
66cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell     glVertex4ub,
67cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell     glVertex4sv,
68cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell     glVertex4usv,
69cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell     glVertex4iv,
70cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell     glVertex4fv,
71cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell     glVertex4dv }
72cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell};
73cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell
74cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell
75cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwellstatic void *multitexfuncs[4][7] = {
76cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   { glMultiTexCoord1bv,
77cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell     glMultiTexCoord1ub,
78cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell     glMultiTexCoord1sv,
79cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell     glMultiTexCoord1usv,
80cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell     glMultiTexCoord1iv,
81cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell     glMultiTexCoord1fv,
82cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell     glMultiTexCoord1dv },
83cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell
84cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   { glMultiTexCoord2bv,
85cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell     glMultiTexCoord2ub,
86cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell     glMultiTexCoord2sv,
87cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell     glMultiTexCoord2usv,
88cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell     glMultiTexCoord2iv,
89cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell     glMultiTexCoord2fv,
90cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell     glMultiTexCoord2dv },
91cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell
92cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   { glMultiTexCoord3bv,
93cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell     glMultiTexCoord3ub,
94cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell     glMultiTexCoord3sv,
95cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell     glMultiTexCoord3usv,
96cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell     glMultiTexCoord3iv,
97cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell     glMultiTexCoord3fv,
98cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell     glMultiTexCoord3dv },
99cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell
100cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   { glMultiTexCoord4bv,
101cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell     glMultiTexCoord4ub,
102cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell     glMultiTexCoord4sv,
103cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell     glMultiTexCoord4usv,
104cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell     glMultiTexCoord4iv,
105cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell     glMultiTexCoord4fv,
106cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell     glMultiTexCoord4dv }
107cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell};
108cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell
109cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwellstatic void *indexfuncs[7] = {
110cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   { glIndexbv,
111cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell     glIndexub,
112cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell     glIndexsv,
113cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell     glIndexusv,
114cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell     glIndexiv,
115cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell     glIndexfv,
116cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell     glIndexdv },
117cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell};
118cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell
119cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwellstatic void *edgeflagfuncs[7] = {
120cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   { glEdgeFlagbv,
121cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell     glEdgeFlagub,
122cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell     glEdgeFlagsv,
123cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell     glEdgeFlagusv,
124cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell     glEdgeFlagiv,
125cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell     glEdgeFlagfv,
126cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell     glEdgeFlagdv },
127cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell};
128cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell
129cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwellstatic void *normalfuncs[7] = {
130cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   { glNormal3bv,
131cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell     glNormal3ub,
132cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell     glNormal3sv,
133cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell     glNormal3usv,
134cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell     glNormal3iv,
135cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell     glNormal3fv,
136cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell     glNormal3dv },
137cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell};
138cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell
139cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwellstatic void *fogcoordfuncs[7] = {
140cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   { glFogCoordbv,
141cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell     glFogCoordub,
142cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell     glFogCoordsv,
143cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell     glFogCoordusv,
144cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell     glFogCoordiv,
145cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell     glFogCoordfv,
146cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell     glFogCoorddv },
147cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell};
148cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell
149cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwellstatic void *secondarycolorfuncs[7] = {
150cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   { glSecondaryColor3bv,
151cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell     glSecondaryColor3ub,
152cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell     glSecondaryColor3sv,
153cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell     glSecondaryColor3usv,
154cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell     glSecondaryColor3iv,
155cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell     glSecondaryColor3fv,
156cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell     glSecondaryColor3dv },
157cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell};
158cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell
159cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell
160cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwellvoid _aa_create_context( GLcontext *ctx )
161cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell{
162cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   ctx->aa_context = MALLOC( sizeof(AAcontext) );
163cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   AA_CONTEXT(ctx)->NewState = ~0;
164cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell}
165cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell
166cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwellstatic void _aa_update_state( GLcontext *ctx )
167cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell{
168cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   AAcontext *actx = AA_CONTEXT(ctx);
169cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   AAtexarray *ta = actx->texarrays;
170cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   AAarray *aa = actx->arrays;
171cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   int i;
172cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell
173cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   for (i = 0 ; i < ctx->Const.MaxTextureUnits ; i++)
174cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell      if (ctx->Array.TexCoord[i].Enabled) {
175cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell	 ta->unit = i;
176cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell	 ta->array = &ctx->Array.TexCoord[i];
177cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell	 ta->func = multitexfuncs[ta->array->Size-1][TYPE_IDX(ta->array->Type)];
178cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell	 ta++;
179cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell      }
180cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell
181cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   ta->func = 0;
182cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell
183cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   if (ctx->Array.Color.Enabled) {
184cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell      aa->array = &ctx->Array.Color;
185cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell      aa->func = colorfuncs[aa->array->Size-3][TYPE_IDX(aa->array->Type)];
186cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell      aa++;
187cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   }
188cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell
189cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   if (ctx->Array.Normal.Enabled) {
190cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell      aa->array = &ctx->Array.Normal;
191cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell      aa->func = normalfuncs[TYPE_IDX(aa->array->Type)];
192cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell      aa++;
193cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   }
194cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell
195cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   if (ctx->Array.Index.Enabled) {
196cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell      aa->array = &ctx->Array.Index;
197cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell      aa->func = indexfuncs[TYPE_IDX(aa->array->Type)];
198cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell      aa++;
199cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   }
200cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell
201cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   if (ctx->Array.EdgeFlag.Enabled) {
202cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell      aa->array = &ctx->Array.Edgeflag;
203cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell      aa->func = edgeflagfuncs[TYPE_IDX(aa->array->Type)];
204cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell      aa++;
205cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   }
206cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell
207cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   if (ctx->Array.FogCoord.Enabled) {
208cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell      aa->array = &ctx->Array.Fogcoord;
209cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell      aa->func = fogcoordfuncs[TYPE_IDX(aa->array->Type)];
210cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell      aa++;
211cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   }
212cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell
213cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   if (ctx->Array.SecondaryColor.Enabled) {
214cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell      aa->array = &ctx->Array.SecondaryColor;
215cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell      aa->func = secondarycolorfuncs[TYPE_IDX(aa->array->Type)];
216cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell      aa++;
217cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   }
218cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell
219cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   /* Must be last
220cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell    */
221cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   if (ctx->Array.Vertex.Enabled) {
222cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell      aa->array = &ctx->Array.Vertex;
223cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell      aa->func = vertexfuncs[aa->array->Size-2][TYPE_IDX(aa->array->Type)];
224cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell      aa++;
225cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   }
226cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell
227cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   aa->func = 0;
228cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   actx->NewState = 0;
229cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell}
230cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell
231cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell
232cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwellstatic void _aa_loopback_array_elt( GLint elt )
233cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell{
234cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   GET_CURRENT_CONTEXT(ctx);
235cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   AAcontext *actx = AA_CONTEXT(ctx);
236cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   AAtexarray *ta;
237cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   AAarray *aa;
238cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell
239cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   for (ta = actx->texarrays ; ta->func ; ta++) {
240cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell      void (*func)( GLint, const void * ) =
241cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell	 (void (*)( GLint, const void * )) ta->func;
242cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell      func( ta->unit, (char *)ta->array->Ptr + elt * ta->array->SizeB );
243cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   }
244cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell
245cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   for (aa = actx->arrays ; aa->func ; aa++) {
246cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell      void (*func)( GLint, const void * ) =
247cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell	 (void (*)( GLint, const void * )) aa->func;
248cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell      func( (char *)aa->array->Ptr + elt * aa->array->SizeB );
249cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   }
250cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell}
251cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell
252cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell
253cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwellvoid _aa_exec_array_elt( GLint elt )
254cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell{
255cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   GET_CURRENT_CONTEXT(ctx);
256cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   AAcontext *actx = AA_CONTEXT(ctx);
257cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell
258cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   if (actx->NewState)
259cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell      _aa_update_state( ctx );
260cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell
261cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   ctx->Exec->ArrayElement = _aa_loopback_array_elt;
262cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   _aa_loopback_array_elt( elt );
263cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell}
264cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell
265cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell/* This works for save as well:
266cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell */
267cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwellvoid _aa_save_array_elt( GLint elt )
268cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell{
269cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   GET_CURRENT_CONTEXT(ctx);
270cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   AAcontext *actx = AA_CONTEXT(ctx);
271cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell
272cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   if (actx->NewState)
273cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell      _aa_update_state( ctx );
274cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell
275cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   ctx->Save->ArrayElement = _aa_loopback_array_elt;
276cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   _aa_loopback_array_elt( elt );
277cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell}
278cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell
279cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell
280cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwellvoid aa_invalidate_state( GLcontext *ctx, GLuint new_state )
281cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell{
282cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   if (AA_CONTEXT(ctx))
283cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell      AA_CONTEXT(ctx)->NewState |= new_state;
284cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell}
285