blob: 3c2d43005a4e0b1f88259afcc3b352786103c7cc [file] [log] [blame]
Gareth Hughes22144ab2001-03-12 00:48:37 +00001/*
2 * Mesa 3-D graphics library
Brian Paul0aa8a102004-02-08 02:03:41 +00003 * Version: 6.1
Gareth Hughes22144ab2001-03-12 00:48:37 +00004 *
Brian Paul0aa8a102004-02-08 02:03:41 +00005 * Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
Gareth Hughes22144ab2001-03-12 00:48:37 +00006 *
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:
13 *
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
16 *
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.
23 */
24
Keith Whitwellfc00cbe2001-12-20 15:30:45 +000025/* Author:
Brian Paul05a4b372002-10-29 20:28:36 +000026 * Keith Whitwell <keith@tungstengraphics.com>
Keith Whitwellfc00cbe2001-12-20 15:30:45 +000027 */
28
Keith Whitwellcab974c2000-12-26 05:09:27 +000029#include "glheader.h"
Keith Whitwell4b7d6f22001-06-01 22:22:10 +000030#include "api_arrayelt.h"
Keith Whitwellcab974c2000-12-26 05:09:27 +000031#include "context.h"
Keith Whitwellfc00cbe2001-12-20 15:30:45 +000032#include "glapi.h"
Brian Paul3c634522002-10-24 23:57:19 +000033#include "imports.h"
Keith Whitwellcab974c2000-12-26 05:09:27 +000034#include "macros.h"
Keith Whitwellcab974c2000-12-26 05:09:27 +000035#include "mtypes.h"
36
Karl Schultzb72902e2004-01-28 22:24:12 +000037typedef void (GLAPIENTRY *array_func)( const void * );
Keith Whitwellcab974c2000-12-26 05:09:27 +000038
39typedef struct {
Brian Paul0aa8a102004-02-08 02:03:41 +000040 const struct gl_client_array *array;
Gareth Hughes1fb0a432001-12-28 06:28:10 +000041 array_func func;
Keith Whitwell4b7d6f22001-06-01 22:22:10 +000042} AEarray;
Keith Whitwellcab974c2000-12-26 05:09:27 +000043
Brian Paul0aa8a102004-02-08 02:03:41 +000044typedef void (GLAPIENTRY *attrib_func)( GLuint indx, const void *data, GLboolean normalized, GLuint size );
45
Keith Whitwellcab974c2000-12-26 05:09:27 +000046typedef struct {
Brian Paul0aa8a102004-02-08 02:03:41 +000047 const struct gl_client_array *array;
48 attrib_func func;
49 GLuint index;
50} AEattrib;
51
52typedef struct {
53 AEarray arrays[3]; /* color index, edge flag, null terminator */
54 AEattrib attribs[VERT_ATTRIB_MAX + 1];
Keith Whitwellcab974c2000-12-26 05:09:27 +000055 GLuint NewState;
Keith Whitwell4b7d6f22001-06-01 22:22:10 +000056} AEcontext;
Keith Whitwellcab974c2000-12-26 05:09:27 +000057
Keith Whitwell4b7d6f22001-06-01 22:22:10 +000058#define AE_CONTEXT(ctx) ((AEcontext *)(ctx)->aelt_context)
Brian Paul0aa8a102004-02-08 02:03:41 +000059
60/*
61 * Convert GL_BYTE, GL_UNSIGNED_BYTE, .. GL_DOUBLE into an integer
62 * in the range [0, 7]. Luckily these type tokens are sequentially
63 * numbered in gl.h
64 */
Keith Whitwell4b7d6f22001-06-01 22:22:10 +000065#define TYPE_IDX(t) ((t) & 0xf)
Keith Whitwellcab974c2000-12-26 05:09:27 +000066
Karl Schultzb72902e2004-01-28 22:24:12 +000067static void (GLAPIENTRY *indexfuncs[8])( const void * ) = {
Keith Whitwell4b7d6f22001-06-01 22:22:10 +000068 0,
Gareth Hughes1fb0a432001-12-28 06:28:10 +000069 (array_func)glIndexubv,
70 (array_func)glIndexsv,
Keith Whitwell4b7d6f22001-06-01 22:22:10 +000071 0,
Gareth Hughes1fb0a432001-12-28 06:28:10 +000072 (array_func)glIndexiv,
Keith Whitwell4b7d6f22001-06-01 22:22:10 +000073 0,
Gareth Hughes1fb0a432001-12-28 06:28:10 +000074 (array_func)glIndexfv,
75 (array_func)glIndexdv
Keith Whitwellcab974c2000-12-26 05:09:27 +000076};
77
78
Brian Paul0aa8a102004-02-08 02:03:41 +000079/**********************************************************************/
80
81/* 1, 2, 3 or 4 GL_BYTE attribute */
82static void VertexAttribbv(GLuint index, const GLbyte *v,
83 GLboolean normalized, GLuint size)
84{
85 switch (size) {
86 case 1:
87 if (normalized)
88 _glapi_Dispatch->VertexAttrib4fNV(index, BYTE_TO_FLOAT(v[0]),
89 0, 0, 1);
90 else
91 _glapi_Dispatch->VertexAttrib4fNV(index, v[0], 0, 0, 1);
92 return;
93 case 2:
94 if (normalized)
95 _glapi_Dispatch->VertexAttrib4fNV(index, BYTE_TO_FLOAT(v[0]),
96 BYTE_TO_FLOAT(v[1]), 0, 1);
97 else
98 _glapi_Dispatch->VertexAttrib4fNV(index, v[0], v[1], 0, 1);
99 return;
100 case 3:
101 if (normalized)
102 _glapi_Dispatch->VertexAttrib4fNV(index, BYTE_TO_FLOAT(v[0]),
103 BYTE_TO_FLOAT(v[1]),
104 BYTE_TO_FLOAT(v[2]), 1);
105 else
106 _glapi_Dispatch->VertexAttrib4fNV(index, v[0], v[1], v[2], 1);
107 return;
108 case 4:
109 if (normalized)
110 _glapi_Dispatch->VertexAttrib4fNV(index, BYTE_TO_FLOAT(v[0]),
111 BYTE_TO_FLOAT(v[1]),
112 BYTE_TO_FLOAT(v[2]),
113 BYTE_TO_FLOAT(v[3]));
114 else
115 _glapi_Dispatch->VertexAttrib4fNV(index, v[0], v[1], v[2], v[3]);
116 return;
117 default:
118 _mesa_problem(NULL, "Bad size in VertexAttribbv");
119 }
120}
121
122/* 1, 2, 3 or 4 GL_UNSIGNED_BYTE attribute */
123static void VertexAttribubv(GLuint index, const GLubyte *v,
124 GLboolean normalized, GLuint size)
125{
126 switch (size) {
127 case 1:
128 if (normalized)
129 _glapi_Dispatch->VertexAttrib4fNV(index, UBYTE_TO_FLOAT(v[0]),
130 0, 0, 1);
131 else
132 _glapi_Dispatch->VertexAttrib4fNV(index, v[0], 0, 0, 1);
133 return;
134 case 2:
135 if (normalized)
136 _glapi_Dispatch->VertexAttrib4fNV(index, UBYTE_TO_FLOAT(v[0]),
137 UBYTE_TO_FLOAT(v[1]), 0, 1);
138 else
139 _glapi_Dispatch->VertexAttrib4fNV(index, v[0], v[1], 0, 1);
140 return;
141 case 3:
142 if (normalized)
143 _glapi_Dispatch->VertexAttrib4fNV(index, UBYTE_TO_FLOAT(v[0]),
144 UBYTE_TO_FLOAT(v[1]),
145 UBYTE_TO_FLOAT(v[2]), 1);
146 else
147 _glapi_Dispatch->VertexAttrib4fNV(index, v[0], v[1], v[2], 1);
148 return;
149 case 4:
150 if (normalized)
151 _glapi_Dispatch->VertexAttrib4fNV(index, UBYTE_TO_FLOAT(v[0]),
152 UBYTE_TO_FLOAT(v[1]),
153 UBYTE_TO_FLOAT(v[2]),
154 UBYTE_TO_FLOAT(v[3]));
155 else
156 _glapi_Dispatch->VertexAttrib4fNV(index, v[0], v[1], v[2], v[3]);
157 return;
158 default:
159 _mesa_problem(NULL, "Bad size in VertexAttribubv");
160 }
161}
162
163/* 1, 2, 3 or 4 GL_SHORT attribute */
164static void VertexAttribsv(GLuint index, const GLshort *v,
165 GLboolean normalized, GLuint size)
166{
167 switch (size) {
168 case 1:
169 if (normalized)
170 _glapi_Dispatch->VertexAttrib4fNV(index, SHORT_TO_FLOAT(v[0]),
171 0, 0, 1);
172 else
173 _glapi_Dispatch->VertexAttrib4fNV(index, v[0], 0, 0, 1);
174 return;
175 case 2:
176 if (normalized)
177 _glapi_Dispatch->VertexAttrib4fNV(index, SHORT_TO_FLOAT(v[0]),
178 SHORT_TO_FLOAT(v[1]), 0, 1);
179 else
180 _glapi_Dispatch->VertexAttrib4fNV(index, v[0], v[1], 0, 1);
181 return;
182 case 3:
183 if (normalized)
184 _glapi_Dispatch->VertexAttrib4fNV(index, SHORT_TO_FLOAT(v[0]),
185 SHORT_TO_FLOAT(v[1]),
186 SHORT_TO_FLOAT(v[2]), 1);
187 else
188 _glapi_Dispatch->VertexAttrib4fNV(index, v[0], v[1], v[2], 1);
189 return;
190 case 4:
191 if (normalized)
192 _glapi_Dispatch->VertexAttrib4fNV(index, SHORT_TO_FLOAT(v[0]),
193 SHORT_TO_FLOAT(v[1]),
194 SHORT_TO_FLOAT(v[2]),
195 SHORT_TO_FLOAT(v[3]));
196 else
197 _glapi_Dispatch->VertexAttrib4fNV(index, v[0], v[1], v[2], v[3]);
198 return;
199 default:
200 _mesa_problem(NULL, "Bad size in VertexAttribsv");
201 }
202}
203
204
205/* 1, 2, 3 or 4 GL_UNSIGNED_SHORT attribute */
206static void VertexAttribusv(GLuint index, const GLushort *v,
207 GLboolean normalized, GLuint size)
208{
209 switch (size) {
210 case 1:
211 if (normalized)
212 _glapi_Dispatch->VertexAttrib4fNV(index, USHORT_TO_FLOAT(v[0]),
213 0, 0, 1);
214 else
215 _glapi_Dispatch->VertexAttrib4fNV(index, v[0], 0, 0, 1);
216 return;
217 case 2:
218 if (normalized)
219 _glapi_Dispatch->VertexAttrib4fNV(index, USHORT_TO_FLOAT(v[0]),
220 USHORT_TO_FLOAT(v[1]), 0, 1);
221 else
222 _glapi_Dispatch->VertexAttrib4fNV(index, v[0], v[1], 0, 1);
223 return;
224 case 3:
225 if (normalized)
226 _glapi_Dispatch->VertexAttrib4fNV(index, USHORT_TO_FLOAT(v[0]),
227 USHORT_TO_FLOAT(v[1]),
228 USHORT_TO_FLOAT(v[2]), 1);
229 else
230 _glapi_Dispatch->VertexAttrib4fNV(index, v[0], v[1], v[2], 1);
231 return;
232 case 4:
233 if (normalized)
234 _glapi_Dispatch->VertexAttrib4fNV(index, USHORT_TO_FLOAT(v[0]),
235 USHORT_TO_FLOAT(v[1]),
236 USHORT_TO_FLOAT(v[2]),
237 USHORT_TO_FLOAT(v[3]));
238 else
239 _glapi_Dispatch->VertexAttrib4fNV(index, v[0], v[1], v[2], v[3]);
240 return;
241 default:
242 _mesa_problem(NULL, "Bad size in VertexAttribusv");
243 }
244}
245
246/* 1, 2, 3 or 4 GL_INT attribute */
247static void VertexAttribiv(GLuint index, const GLint *v,
248 GLboolean normalized, GLuint size)
249{
250 switch (size) {
251 case 1:
252 if (normalized)
253 _glapi_Dispatch->VertexAttrib4fNV(index, INT_TO_FLOAT(v[0]),
254 0, 0, 1);
255 else
256 _glapi_Dispatch->VertexAttrib4fNV(index, v[0], 0, 0, 1);
257 return;
258 case 2:
259 if (normalized)
260 _glapi_Dispatch->VertexAttrib4fNV(index, INT_TO_FLOAT(v[0]),
261 INT_TO_FLOAT(v[1]), 0, 1);
262 else
263 _glapi_Dispatch->VertexAttrib4fNV(index, v[0], v[1], 0, 1);
264 return;
265 case 3:
266 if (normalized)
267 _glapi_Dispatch->VertexAttrib4fNV(index, INT_TO_FLOAT(v[0]),
268 INT_TO_FLOAT(v[1]),
269 INT_TO_FLOAT(v[2]), 1);
270 else
271 _glapi_Dispatch->VertexAttrib4fNV(index, v[0], v[1], v[2], 1);
272 return;
273 case 4:
274 if (normalized)
275 _glapi_Dispatch->VertexAttrib4fNV(index, INT_TO_FLOAT(v[0]),
276 INT_TO_FLOAT(v[1]),
277 INT_TO_FLOAT(v[2]),
278 INT_TO_FLOAT(v[3]));
279 else
280 _glapi_Dispatch->VertexAttrib4fNV(index, v[0], v[1], v[2], v[3]);
281 return;
282 default:
283 _mesa_problem(NULL, "Bad size in VertexAttribiv");
284 }
285}
286
287/* 1, 2, 3 or 4 GL_UNSIGNED_INT attribute */
288static void VertexAttribuiv(GLuint index, const GLuint *v,
289 GLboolean normalized, GLuint size)
290{
291 switch (size) {
292 case 1:
293 if (normalized)
294 _glapi_Dispatch->VertexAttrib4fNV(index, UINT_TO_FLOAT(v[0]),
295 0, 0, 1);
296 else
297 _glapi_Dispatch->VertexAttrib4fNV(index, v[0], 0, 0, 1);
298 return;
299 case 2:
300 if (normalized)
301 _glapi_Dispatch->VertexAttrib4fNV(index, UINT_TO_FLOAT(v[0]),
302 UINT_TO_FLOAT(v[1]), 0, 1);
303 else
304 _glapi_Dispatch->VertexAttrib4fNV(index, v[0], v[1], 0, 1);
305 return;
306 case 3:
307 if (normalized)
308 _glapi_Dispatch->VertexAttrib4fNV(index, UINT_TO_FLOAT(v[0]),
309 UINT_TO_FLOAT(v[1]),
310 UINT_TO_FLOAT(v[2]), 1);
311 else
312 _glapi_Dispatch->VertexAttrib4fNV(index, v[0], v[1], v[2], 1);
313 return;
314 case 4:
315 if (normalized)
316 _glapi_Dispatch->VertexAttrib4fNV(index, UINT_TO_FLOAT(v[0]),
317 UINT_TO_FLOAT(v[1]),
318 UINT_TO_FLOAT(v[2]),
319 UINT_TO_FLOAT(v[3]));
320 else
321 _glapi_Dispatch->VertexAttrib4fNV(index, v[0], v[1], v[2], v[3]);
322 return;
323 default:
324 _mesa_problem(NULL, "Bad size in VertexAttribuiv");
325 }
326}
327
328/* 1, 2, 3 or 4 GL_FLOAT attribute */
329static void VertexAttribfv(GLuint index, const GLfloat *v,
330 GLboolean normalized, GLuint size)
331{
332 (void) normalized;
333 switch (size) {
334 case 1:
335 _glapi_Dispatch->VertexAttrib1fvNV(index, v);
336 return;
337 case 2:
338 _glapi_Dispatch->VertexAttrib2fvNV(index, v);
339 return;
340 case 3:
341 _glapi_Dispatch->VertexAttrib3fvNV(index, v);
342 return;
343 case 4:
344 _glapi_Dispatch->VertexAttrib4fvNV(index, v);
345 return;
346 default:
347 _mesa_problem(NULL, "Bad size in VertexAttribfv");
348 }
349}
350
351/* 1, 2, 3 or 4 GL_DOUBLE attribute */
352static void VertexAttribdv(GLuint index, const GLdouble *v,
353 GLboolean normalized, GLuint size)
354{
355 (void) normalized;
356 switch (size) {
357 case 1:
358 _glapi_Dispatch->VertexAttrib1dvNV(index, v);
359 return;
360 case 2:
361 _glapi_Dispatch->VertexAttrib2dvNV(index, v);
362 return;
363 case 3:
364 _glapi_Dispatch->VertexAttrib3dvNV(index, v);
365 return;
366 case 4:
367 _glapi_Dispatch->VertexAttrib4dvNV(index, v);
368 return;
369 default:
370 _mesa_problem(NULL, "Bad size in VertexAttribdv");
371 }
372}
373
374/*
375 * Array [size][type] of VertexAttrib functions
376 */
377static void (GLAPIENTRY *attribfuncs[8])( GLuint, const void *, GLboolean, GLuint ) = {
378 (attrib_func) VertexAttribbv,
379 (attrib_func) VertexAttribubv,
380 (attrib_func) VertexAttribsv,
381 (attrib_func) VertexAttribusv,
382 (attrib_func) VertexAttribiv,
383 (attrib_func) VertexAttribuiv,
384 (attrib_func) VertexAttribfv,
385 (attrib_func) VertexAttribdv
Keith Whitwell4b7d6f22001-06-01 22:22:10 +0000386};
387
Brian Paul0aa8a102004-02-08 02:03:41 +0000388/**********************************************************************/
Brian Paul03c0c2e2002-01-14 16:06:35 +0000389
Keith Whitwell4b7d6f22001-06-01 22:22:10 +0000390
391GLboolean _ae_create_context( GLcontext *ctx )
Keith Whitwellcab974c2000-12-26 05:09:27 +0000392{
Keith Whitwellae0eaf92003-11-24 15:23:18 +0000393 if (ctx->aelt_context)
394 return GL_TRUE;
395
Keith Whitwell4b7d6f22001-06-01 22:22:10 +0000396 ctx->aelt_context = MALLOC( sizeof(AEcontext) );
Gareth Hughes1fb0a432001-12-28 06:28:10 +0000397 if (!ctx->aelt_context)
Keith Whitwell4b7d6f22001-06-01 22:22:10 +0000398 return GL_FALSE;
399
400 AE_CONTEXT(ctx)->NewState = ~0;
401 return GL_TRUE;
Keith Whitwellcab974c2000-12-26 05:09:27 +0000402}
403
Keith Whitwell4b7d6f22001-06-01 22:22:10 +0000404
405void _ae_destroy_context( GLcontext *ctx )
Keith Whitwellcab974c2000-12-26 05:09:27 +0000406{
Keith Whitwell4b7d6f22001-06-01 22:22:10 +0000407 if ( AE_CONTEXT( ctx ) ) {
408 FREE( ctx->aelt_context );
409 ctx->aelt_context = 0;
410 }
411}
412
413
Brian Paul0aa8a102004-02-08 02:03:41 +0000414/*
415 * Return pointer to the conventional vertex array which corresponds
416 * to the given vertex attribute index.
417 */
418static struct gl_client_array *
419conventional_array(GLcontext *ctx, GLuint index)
420{
421 ASSERT(index < VERT_ATTRIB_MAX);
422 switch (index) {
423 case VERT_ATTRIB_POS:
424 return &ctx->Array.Vertex;
425 case VERT_ATTRIB_NORMAL:
426 return &ctx->Array.Normal;
427 case VERT_ATTRIB_COLOR0:
428 return &ctx->Array.Color;
429 case VERT_ATTRIB_COLOR1:
430 return &ctx->Array.SecondaryColor;
431 case VERT_ATTRIB_FOG:
432 return &ctx->Array.FogCoord;
433 case VERT_ATTRIB_TEX0:
434 case VERT_ATTRIB_TEX1:
435 case VERT_ATTRIB_TEX2:
436 case VERT_ATTRIB_TEX3:
437 case VERT_ATTRIB_TEX4:
438 case VERT_ATTRIB_TEX5:
439 case VERT_ATTRIB_TEX6:
440 case VERT_ATTRIB_TEX7:
441 return &ctx->Array.TexCoord[index - VERT_ATTRIB_TEX0];
442 default:
443 return NULL;
444 }
445}
446
447
448/**
449 * Make a list of functions to call per glArrayElement call which will
450 * access the vertex array data.
451 * Most vertex attributes are handled via glVertexAttrib4fvNV.
452 */
Keith Whitwell4b7d6f22001-06-01 22:22:10 +0000453static void _ae_update_state( GLcontext *ctx )
454{
455 AEcontext *actx = AE_CONTEXT(ctx);
Keith Whitwell4b7d6f22001-06-01 22:22:10 +0000456 AEarray *aa = actx->arrays;
Brian Paul0aa8a102004-02-08 02:03:41 +0000457 AEattrib *at = actx->attribs;
Brian Pauldb07de02002-04-19 00:23:08 +0000458 GLuint i;
Keith Whitwellcab974c2000-12-26 05:09:27 +0000459
Brian Paul0aa8a102004-02-08 02:03:41 +0000460 /* yuck, no generic array to correspond to color index or edge flag */
Keith Whitwellcab974c2000-12-26 05:09:27 +0000461 if (ctx->Array.Index.Enabled) {
462 aa->array = &ctx->Array.Index;
463 aa->func = indexfuncs[TYPE_IDX(aa->array->Type)];
464 aa++;
465 }
Keith Whitwellcab974c2000-12-26 05:09:27 +0000466 if (ctx->Array.EdgeFlag.Enabled) {
Keith Whitwell4b7d6f22001-06-01 22:22:10 +0000467 aa->array = &ctx->Array.EdgeFlag;
Brian Paul0aa8a102004-02-08 02:03:41 +0000468 aa->func = (array_func) glEdgeFlagv;
Keith Whitwellcab974c2000-12-26 05:09:27 +0000469 aa++;
470 }
Brian Paul0aa8a102004-02-08 02:03:41 +0000471 aa->func = NULL; /* terminate the list */
Keith Whitwellcab974c2000-12-26 05:09:27 +0000472
Brian Paul0aa8a102004-02-08 02:03:41 +0000473 /* all other arrays handled here */
474 for (i = 0; i < VERT_ATTRIB_MAX; i++) {
475 /* Note: we count down to zero so glVertex (attrib 0) is last!!! */
476 const GLuint index = VERT_ATTRIB_MAX - i - 1;
477 struct gl_client_array *array = conventional_array(ctx, index);
478
479 /* check for overriding generic vertex attribute */
480 if (ctx->VertexProgram.Enabled
481 && ctx->Array.VertexAttrib[index].Enabled) {
482 array = &ctx->Array.VertexAttrib[index];
483 }
484
485 /* if array's enabled, add it to the list */
486 if (array && array->Enabled) {
487 at->array = array;
488 at->func = attribfuncs[TYPE_IDX(array->Type)];
489 at->index = index;
490 at++;
491 }
Keith Whitwellcab974c2000-12-26 05:09:27 +0000492 }
Brian Paul0aa8a102004-02-08 02:03:41 +0000493 ASSERT(at - actx->attribs <= VERT_ATTRIB_MAX);
494 at->func = NULL; /* terminate the list */
Keith Whitwellcab974c2000-12-26 05:09:27 +0000495
Keith Whitwellcab974c2000-12-26 05:09:27 +0000496 actx->NewState = 0;
497}
498
499
Karl Schultzd6745692003-12-04 20:23:44 +0000500void GLAPIENTRY _ae_loopback_array_elt( GLint elt )
Keith Whitwellcab974c2000-12-26 05:09:27 +0000501{
502 GET_CURRENT_CONTEXT(ctx);
Brian Paul0aa8a102004-02-08 02:03:41 +0000503 const AEcontext *actx = AE_CONTEXT(ctx);
504 const AEarray *aa;
505 const AEattrib *at;
Keith Whitwell4b7d6f22001-06-01 22:22:10 +0000506
507 if (actx->NewState)
508 _ae_update_state( ctx );
Keith Whitwellcab974c2000-12-26 05:09:27 +0000509
Brian Paul0aa8a102004-02-08 02:03:41 +0000510 /* color index and edge flags */
511 for (aa = actx->arrays; aa->func ; aa++) {
512 const GLubyte *src = aa->array->BufferObj->Data
513 + (GLuint) aa->array->Ptr
514 + elt * aa->array->StrideB;
515 aa->func( src );
Keith Whitwellcab974c2000-12-26 05:09:27 +0000516 }
517
Brian Paul0aa8a102004-02-08 02:03:41 +0000518 /* all other attributes */
519 for (at = actx->attribs; at->func; at++) {
520 const GLubyte *src = at->array->BufferObj->Data
521 + (GLuint) at->array->Ptr
522 + elt * at->array->StrideB;
523 at->func( at->index, src, at->array->Normalized, at->array->Size );
Keith Whitwellcab974c2000-12-26 05:09:27 +0000524 }
525}
526
527
Keith Whitwell4b7d6f22001-06-01 22:22:10 +0000528
529void _ae_invalidate_state( GLcontext *ctx, GLuint new_state )
Keith Whitwellcab974c2000-12-26 05:09:27 +0000530{
Keith Whitwell4b7d6f22001-06-01 22:22:10 +0000531 AE_CONTEXT(ctx)->NewState |= new_state;
Keith Whitwellcab974c2000-12-26 05:09:27 +0000532}