blob: c94c6c07a6e5168ef40773fbd5b2947f1092db1b [file] [log] [blame]
Gareth Hughes22144ab2001-03-12 00:48:37 +00001/*
2 * Mesa 3-D graphics library
Brian Paul024b5892005-11-25 17:07:10 +00003 * Version: 6.5
Gareth Hughes22144ab2001-03-12 00:48:37 +00004 *
Brian Paul024b5892005-11-25 17:07:10 +00005 * Copyright (C) 1999-2005 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"
Ian Romanick9bdfee32005-07-18 12:31:24 +000036#include "glapioffsets.h"
37#include "dispatch.h"
Keith Whitwellcab974c2000-12-26 05:09:27 +000038
Karl Schultzb72902e2004-01-28 22:24:12 +000039typedef void (GLAPIENTRY *array_func)( const void * );
Keith Whitwellcab974c2000-12-26 05:09:27 +000040
41typedef struct {
Brian Paul0d4393a2004-02-11 22:53:38 +000042 const struct gl_client_array *array;
Ian Romanick9bdfee32005-07-18 12:31:24 +000043 int offset;
Keith Whitwell4b7d6f22001-06-01 22:22:10 +000044} AEarray;
Keith Whitwellcab974c2000-12-26 05:09:27 +000045
Brian Paul0d4393a2004-02-11 22:53:38 +000046typedef void (GLAPIENTRY *attrib_func)( GLuint indx, const void *data );
47
Keith Whitwellcab974c2000-12-26 05:09:27 +000048typedef struct {
Brian Paul0d4393a2004-02-11 22:53:38 +000049 const struct gl_client_array *array;
50 attrib_func func;
51 GLuint index;
52} AEattrib;
53
54typedef struct {
Brian Paul53ad0362004-02-09 00:24:48 +000055 AEarray arrays[32];
Brian Paul0d4393a2004-02-11 22:53:38 +000056 AEattrib attribs[VERT_ATTRIB_MAX + 1];
Keith Whitwellcab974c2000-12-26 05:09:27 +000057 GLuint NewState;
Keith Whitwell4b7d6f22001-06-01 22:22:10 +000058} AEcontext;
Keith Whitwellcab974c2000-12-26 05:09:27 +000059
Keith Whitwell4b7d6f22001-06-01 22:22:10 +000060#define AE_CONTEXT(ctx) ((AEcontext *)(ctx)->aelt_context)
Brian Paul0d4393a2004-02-11 22:53:38 +000061
Ian Romanick9bdfee32005-07-18 12:31:24 +000062
Brian Paul0d4393a2004-02-11 22:53:38 +000063/*
64 * Convert GL_BYTE, GL_UNSIGNED_BYTE, .. GL_DOUBLE into an integer
65 * in the range [0, 7]. Luckily these type tokens are sequentially
Brian Paulf2f33502004-04-23 17:58:06 +000066 * numbered in gl.h, except for GL_DOUBLE.
Brian Paul0d4393a2004-02-11 22:53:38 +000067 */
Brian Paulf2f33502004-04-23 17:58:06 +000068#define TYPE_IDX(t) ( (t) == GL_DOUBLE ? 7 : (t) & 7 )
Keith Whitwellcab974c2000-12-26 05:09:27 +000069
Ian Romanick9bdfee32005-07-18 12:31:24 +000070static const int ColorFuncs[2][8] = {
Adam Jackson94987be2004-10-24 02:05:40 +000071 {
Ian Romanick9bdfee32005-07-18 12:31:24 +000072 _gloffset_Color3bv,
73 _gloffset_Color3ubv,
74 _gloffset_Color3sv,
75 _gloffset_Color3usv,
76 _gloffset_Color3iv,
77 _gloffset_Color3uiv,
78 _gloffset_Color3fv,
79 _gloffset_Color3dv,
Adam Jackson94987be2004-10-24 02:05:40 +000080 },
81 {
Ian Romanick9bdfee32005-07-18 12:31:24 +000082 _gloffset_Color4bv,
83 _gloffset_Color4ubv,
84 _gloffset_Color4sv,
85 _gloffset_Color4usv,
86 _gloffset_Color4iv,
87 _gloffset_Color4uiv,
88 _gloffset_Color4fv,
89 _gloffset_Color4dv,
Adam Jackson94987be2004-10-24 02:05:40 +000090 },
Brian Paul53ad0362004-02-09 00:24:48 +000091};
92
Ian Romanick9bdfee32005-07-18 12:31:24 +000093static const int VertexFuncs[3][8] = {
Adam Jackson94987be2004-10-24 02:05:40 +000094 {
Ian Romanick9bdfee32005-07-18 12:31:24 +000095 -1,
96 -1,
97 _gloffset_Vertex2sv,
98 -1,
99 _gloffset_Vertex2iv,
100 -1,
101 _gloffset_Vertex2fv,
102 _gloffset_Vertex2dv,
Adam Jackson94987be2004-10-24 02:05:40 +0000103 },
104 {
Ian Romanick9bdfee32005-07-18 12:31:24 +0000105 -1,
106 -1,
107 _gloffset_Vertex3sv,
108 -1,
109 _gloffset_Vertex3iv,
110 -1,
111 _gloffset_Vertex3fv,
112 _gloffset_Vertex3dv,
Adam Jackson94987be2004-10-24 02:05:40 +0000113 },
114 {
Ian Romanick9bdfee32005-07-18 12:31:24 +0000115 -1,
116 -1,
117 _gloffset_Vertex4sv,
118 -1,
119 _gloffset_Vertex4iv,
120 -1,
121 _gloffset_Vertex4fv,
122 _gloffset_Vertex4dv,
Adam Jackson94987be2004-10-24 02:05:40 +0000123 },
Brian Paul53ad0362004-02-09 00:24:48 +0000124};
125
Ian Romanick9bdfee32005-07-18 12:31:24 +0000126static const int IndexFuncs[8] = {
127 -1,
128 _gloffset_Indexubv,
129 _gloffset_Indexsv,
130 -1,
131 _gloffset_Indexiv,
132 -1,
133 _gloffset_Indexfv,
134 _gloffset_Indexdv,
Keith Whitwellcab974c2000-12-26 05:09:27 +0000135};
136
Ian Romanick9bdfee32005-07-18 12:31:24 +0000137static const int NormalFuncs[8] = {
138 _gloffset_Normal3bv,
139 -1,
140 _gloffset_Normal3sv,
141 -1,
142 _gloffset_Normal3iv,
143 -1,
144 _gloffset_Normal3fv,
145 _gloffset_Normal3dv,
Adam Jackson94987be2004-10-24 02:05:40 +0000146};
Brian Paul53ad0362004-02-09 00:24:48 +0000147
Brian Paul0f1d98c2006-03-17 04:10:03 +0000148/* Note: _gloffset_* for these may not be a compile-time constant. */
Ian Romanick126c89e2005-08-05 18:13:37 +0000149static int SecondaryColorFuncs[8];
Brian Paul0f1d98c2006-03-17 04:10:03 +0000150static int FogCoordFuncs[8];
Brian Paul53ad0362004-02-09 00:24:48 +0000151
Brian Paul0d4393a2004-02-11 22:53:38 +0000152/**********************************************************************/
153
154/* GL_BYTE attributes */
155
Brian Paulb5b8d222004-11-27 20:07:08 +0000156static void GLAPIENTRY VertexAttrib1NbvNV(GLuint index, const GLbyte *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000157{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000158 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, BYTE_TO_FLOAT(v[0])));
Brian Paul0d4393a2004-02-11 22:53:38 +0000159}
160
Brian Paulb5b8d222004-11-27 20:07:08 +0000161static void GLAPIENTRY VertexAttrib1bvNV(GLuint index, const GLbyte *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000162{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000163 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, v[0]));
Brian Paul0d4393a2004-02-11 22:53:38 +0000164}
165
Brian Paulb5b8d222004-11-27 20:07:08 +0000166static void GLAPIENTRY VertexAttrib2NbvNV(GLuint index, const GLbyte *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000167{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000168 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, BYTE_TO_FLOAT(v[0]), BYTE_TO_FLOAT(v[1])));
Brian Paul0d4393a2004-02-11 22:53:38 +0000169}
170
Brian Paulb5b8d222004-11-27 20:07:08 +0000171static void GLAPIENTRY VertexAttrib2bvNV(GLuint index, const GLbyte *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000172{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000173 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, v[0], v[1]));
Brian Paul0d4393a2004-02-11 22:53:38 +0000174}
175
Brian Paulb5b8d222004-11-27 20:07:08 +0000176static void GLAPIENTRY VertexAttrib3NbvNV(GLuint index, const GLbyte *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000177{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000178 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, BYTE_TO_FLOAT(v[0]),
179 BYTE_TO_FLOAT(v[1]),
180 BYTE_TO_FLOAT(v[2])));
Brian Paul0d4393a2004-02-11 22:53:38 +0000181}
182
Brian Paulb5b8d222004-11-27 20:07:08 +0000183static void GLAPIENTRY VertexAttrib3bvNV(GLuint index, const GLbyte *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000184{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000185 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, v[0], v[1], v[2]));
Brian Paul0d4393a2004-02-11 22:53:38 +0000186}
187
Brian Paulb5b8d222004-11-27 20:07:08 +0000188static void GLAPIENTRY VertexAttrib4NbvNV(GLuint index, const GLbyte *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000189{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000190 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, BYTE_TO_FLOAT(v[0]),
191 BYTE_TO_FLOAT(v[1]),
192 BYTE_TO_FLOAT(v[2]),
193 BYTE_TO_FLOAT(v[3])));
Brian Paul0d4393a2004-02-11 22:53:38 +0000194}
195
Brian Paulb5b8d222004-11-27 20:07:08 +0000196static void GLAPIENTRY VertexAttrib4bvNV(GLuint index, const GLbyte *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000197{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000198 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, v[0], v[1], v[2], v[3]));
Brian Paul0d4393a2004-02-11 22:53:38 +0000199}
200
201/* GL_UNSIGNED_BYTE attributes */
202
Brian Paulb5b8d222004-11-27 20:07:08 +0000203static void GLAPIENTRY VertexAttrib1NubvNV(GLuint index, const GLubyte *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000204{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000205 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, UBYTE_TO_FLOAT(v[0])));
Brian Paul0d4393a2004-02-11 22:53:38 +0000206}
207
Brian Paulb5b8d222004-11-27 20:07:08 +0000208static void GLAPIENTRY VertexAttrib1ubvNV(GLuint index, const GLubyte *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000209{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000210 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, v[0]));
Brian Paul0d4393a2004-02-11 22:53:38 +0000211}
212
Brian Paulb5b8d222004-11-27 20:07:08 +0000213static void GLAPIENTRY VertexAttrib2NubvNV(GLuint index, const GLubyte *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000214{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000215 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, UBYTE_TO_FLOAT(v[0]),
216 UBYTE_TO_FLOAT(v[1])));
Brian Paul0d4393a2004-02-11 22:53:38 +0000217}
218
Brian Paulb5b8d222004-11-27 20:07:08 +0000219static void GLAPIENTRY VertexAttrib2ubvNV(GLuint index, const GLubyte *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000220{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000221 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, v[0], v[1]));
Brian Paul0d4393a2004-02-11 22:53:38 +0000222}
223
Brian Paulb5b8d222004-11-27 20:07:08 +0000224static void GLAPIENTRY VertexAttrib3NubvNV(GLuint index, const GLubyte *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000225{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000226 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, UBYTE_TO_FLOAT(v[0]),
227 UBYTE_TO_FLOAT(v[1]),
228 UBYTE_TO_FLOAT(v[2])));
Brian Paul0d4393a2004-02-11 22:53:38 +0000229}
Brian Paulb5b8d222004-11-27 20:07:08 +0000230static void GLAPIENTRY VertexAttrib3ubvNV(GLuint index, const GLubyte *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000231{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000232 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, v[0], v[1], v[2]));
Brian Paul0d4393a2004-02-11 22:53:38 +0000233}
234
Brian Paulb5b8d222004-11-27 20:07:08 +0000235static void GLAPIENTRY VertexAttrib4NubvNV(GLuint index, const GLubyte *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000236{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000237 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, UBYTE_TO_FLOAT(v[0]),
Brian Paul0d4393a2004-02-11 22:53:38 +0000238 UBYTE_TO_FLOAT(v[1]),
239 UBYTE_TO_FLOAT(v[2]),
Ian Romanick9bdfee32005-07-18 12:31:24 +0000240 UBYTE_TO_FLOAT(v[3])));
Brian Paul0d4393a2004-02-11 22:53:38 +0000241}
242
Brian Paulb5b8d222004-11-27 20:07:08 +0000243static void GLAPIENTRY VertexAttrib4ubvNV(GLuint index, const GLubyte *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000244{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000245 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, v[0], v[1], v[2], v[3]));
Brian Paul0d4393a2004-02-11 22:53:38 +0000246}
247
248/* GL_SHORT attributes */
249
Brian Paulb5b8d222004-11-27 20:07:08 +0000250static void GLAPIENTRY VertexAttrib1NsvNV(GLuint index, const GLshort *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000251{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000252 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, SHORT_TO_FLOAT(v[0])));
Brian Paul0d4393a2004-02-11 22:53:38 +0000253}
254
Brian Paulb5b8d222004-11-27 20:07:08 +0000255static void GLAPIENTRY VertexAttrib1svNV(GLuint index, const GLshort *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000256{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000257 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, v[0]));
Brian Paul0d4393a2004-02-11 22:53:38 +0000258}
259
Brian Paulb5b8d222004-11-27 20:07:08 +0000260static void GLAPIENTRY VertexAttrib2NsvNV(GLuint index, const GLshort *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000261{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000262 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, SHORT_TO_FLOAT(v[0]),
263 SHORT_TO_FLOAT(v[1])));
Brian Paul0d4393a2004-02-11 22:53:38 +0000264}
265
Brian Paulb5b8d222004-11-27 20:07:08 +0000266static void GLAPIENTRY VertexAttrib2svNV(GLuint index, const GLshort *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000267{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000268 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, v[0], v[1]));
Brian Paul0d4393a2004-02-11 22:53:38 +0000269}
270
Brian Paulb5b8d222004-11-27 20:07:08 +0000271static void GLAPIENTRY VertexAttrib3NsvNV(GLuint index, const GLshort *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000272{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000273 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, SHORT_TO_FLOAT(v[0]),
Ian Romanickc1d455f2004-05-27 00:03:53 +0000274 SHORT_TO_FLOAT(v[1]),
Ian Romanick9bdfee32005-07-18 12:31:24 +0000275 SHORT_TO_FLOAT(v[2])));
Brian Paul0d4393a2004-02-11 22:53:38 +0000276}
277
Brian Paulb5b8d222004-11-27 20:07:08 +0000278static void GLAPIENTRY VertexAttrib3svNV(GLuint index, const GLshort *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000279{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000280 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, v[0], v[1], v[2]));
Brian Paul0d4393a2004-02-11 22:53:38 +0000281}
282
Brian Paulb5b8d222004-11-27 20:07:08 +0000283static void GLAPIENTRY VertexAttrib4NsvNV(GLuint index, const GLshort *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000284{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000285 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, SHORT_TO_FLOAT(v[0]),
Ian Romanickc1d455f2004-05-27 00:03:53 +0000286 SHORT_TO_FLOAT(v[1]),
287 SHORT_TO_FLOAT(v[2]),
Ian Romanick9bdfee32005-07-18 12:31:24 +0000288 SHORT_TO_FLOAT(v[3])));
Brian Paul0d4393a2004-02-11 22:53:38 +0000289}
290
Brian Paulb5b8d222004-11-27 20:07:08 +0000291static void GLAPIENTRY VertexAttrib4svNV(GLuint index, const GLshort *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000292{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000293 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, v[0], v[1], v[2], v[3]));
Brian Paul0d4393a2004-02-11 22:53:38 +0000294}
295
296/* GL_UNSIGNED_SHORT attributes */
297
Brian Paulb5b8d222004-11-27 20:07:08 +0000298static void GLAPIENTRY VertexAttrib1NusvNV(GLuint index, const GLushort *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000299{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000300 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, USHORT_TO_FLOAT(v[0])));
Brian Paul0d4393a2004-02-11 22:53:38 +0000301}
302
Brian Paulb5b8d222004-11-27 20:07:08 +0000303static void GLAPIENTRY VertexAttrib1usvNV(GLuint index, const GLushort *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000304{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000305 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, v[0]));
Brian Paul0d4393a2004-02-11 22:53:38 +0000306}
307
Brian Paulb5b8d222004-11-27 20:07:08 +0000308static void GLAPIENTRY VertexAttrib2NusvNV(GLuint index, const GLushort *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000309{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000310 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, USHORT_TO_FLOAT(v[0]),
311 USHORT_TO_FLOAT(v[1])));
Brian Paul0d4393a2004-02-11 22:53:38 +0000312}
313
Brian Paulb5b8d222004-11-27 20:07:08 +0000314static void GLAPIENTRY VertexAttrib2usvNV(GLuint index, const GLushort *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000315{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000316 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, v[0], v[1]));
Brian Paul0d4393a2004-02-11 22:53:38 +0000317}
318
Brian Paulb5b8d222004-11-27 20:07:08 +0000319static void GLAPIENTRY VertexAttrib3NusvNV(GLuint index, const GLushort *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000320{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000321 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, USHORT_TO_FLOAT(v[0]),
322 USHORT_TO_FLOAT(v[1]),
323 USHORT_TO_FLOAT(v[2])));
Brian Paul0d4393a2004-02-11 22:53:38 +0000324}
325
Brian Paulb5b8d222004-11-27 20:07:08 +0000326static void GLAPIENTRY VertexAttrib3usvNV(GLuint index, const GLushort *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000327{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000328 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, v[0], v[1], v[2]));
Brian Paul0d4393a2004-02-11 22:53:38 +0000329}
330
Brian Paulb5b8d222004-11-27 20:07:08 +0000331static void GLAPIENTRY VertexAttrib4NusvNV(GLuint index, const GLushort *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000332{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000333 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, USHORT_TO_FLOAT(v[0]),
334 USHORT_TO_FLOAT(v[1]),
335 USHORT_TO_FLOAT(v[2]),
336 USHORT_TO_FLOAT(v[3])));
Brian Paul0d4393a2004-02-11 22:53:38 +0000337}
338
Brian Paulb5b8d222004-11-27 20:07:08 +0000339static void GLAPIENTRY VertexAttrib4usvNV(GLuint index, const GLushort *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000340{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000341 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, v[0], v[1], v[2], v[3]));
Brian Paul0d4393a2004-02-11 22:53:38 +0000342}
343
344/* GL_INT attributes */
345
Brian Paulb5b8d222004-11-27 20:07:08 +0000346static void GLAPIENTRY VertexAttrib1NivNV(GLuint index, const GLint *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000347{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000348 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, INT_TO_FLOAT(v[0])));
Brian Paul0d4393a2004-02-11 22:53:38 +0000349}
350
Brian Paulb5b8d222004-11-27 20:07:08 +0000351static void GLAPIENTRY VertexAttrib1ivNV(GLuint index, const GLint *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000352{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000353 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, v[0]));
Brian Paul0d4393a2004-02-11 22:53:38 +0000354}
355
Brian Paulb5b8d222004-11-27 20:07:08 +0000356static void GLAPIENTRY VertexAttrib2NivNV(GLuint index, const GLint *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000357{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000358 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, INT_TO_FLOAT(v[0]),
359 INT_TO_FLOAT(v[1])));
Brian Paul0d4393a2004-02-11 22:53:38 +0000360}
361
Brian Paulb5b8d222004-11-27 20:07:08 +0000362static void GLAPIENTRY VertexAttrib2ivNV(GLuint index, const GLint *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000363{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000364 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, v[0], v[1]));
Brian Paul0d4393a2004-02-11 22:53:38 +0000365}
366
Brian Paulb5b8d222004-11-27 20:07:08 +0000367static void GLAPIENTRY VertexAttrib3NivNV(GLuint index, const GLint *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000368{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000369 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, INT_TO_FLOAT(v[0]),
370 INT_TO_FLOAT(v[1]),
371 INT_TO_FLOAT(v[2])));
Brian Paul0d4393a2004-02-11 22:53:38 +0000372}
373
Brian Paulb5b8d222004-11-27 20:07:08 +0000374static void GLAPIENTRY VertexAttrib3ivNV(GLuint index, const GLint *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000375{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000376 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, v[0], v[1], v[2]));
Brian Paul0d4393a2004-02-11 22:53:38 +0000377}
378
Brian Paulb5b8d222004-11-27 20:07:08 +0000379static void GLAPIENTRY VertexAttrib4NivNV(GLuint index, const GLint *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000380{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000381 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, INT_TO_FLOAT(v[0]),
382 INT_TO_FLOAT(v[1]),
383 INT_TO_FLOAT(v[2]),
384 INT_TO_FLOAT(v[3])));
Brian Paul0d4393a2004-02-11 22:53:38 +0000385}
386
Brian Paulb5b8d222004-11-27 20:07:08 +0000387static void GLAPIENTRY VertexAttrib4ivNV(GLuint index, const GLint *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000388{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000389 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, v[0], v[1], v[2], v[3]));
Brian Paul0d4393a2004-02-11 22:53:38 +0000390}
391
392/* GL_UNSIGNED_INT attributes */
393
Brian Paulb5b8d222004-11-27 20:07:08 +0000394static void GLAPIENTRY VertexAttrib1NuivNV(GLuint index, const GLuint *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000395{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000396 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, UINT_TO_FLOAT(v[0])));
Brian Paul0d4393a2004-02-11 22:53:38 +0000397}
398
Brian Paulb5b8d222004-11-27 20:07:08 +0000399static void GLAPIENTRY VertexAttrib1uivNV(GLuint index, const GLuint *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000400{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000401 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, v[0]));
Brian Paul0d4393a2004-02-11 22:53:38 +0000402}
403
Brian Paulb5b8d222004-11-27 20:07:08 +0000404static void GLAPIENTRY VertexAttrib2NuivNV(GLuint index, const GLuint *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000405{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000406 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, UINT_TO_FLOAT(v[0]),
407 UINT_TO_FLOAT(v[1])));
Brian Paul0d4393a2004-02-11 22:53:38 +0000408}
409
Brian Paulb5b8d222004-11-27 20:07:08 +0000410static void GLAPIENTRY VertexAttrib2uivNV(GLuint index, const GLuint *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000411{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000412 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, v[0], v[1]));
Brian Paul0d4393a2004-02-11 22:53:38 +0000413}
414
Brian Paulb5b8d222004-11-27 20:07:08 +0000415static void GLAPIENTRY VertexAttrib3NuivNV(GLuint index, const GLuint *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000416{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000417 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, UINT_TO_FLOAT(v[0]),
418 UINT_TO_FLOAT(v[1]),
419 UINT_TO_FLOAT(v[2])));
Brian Paul0d4393a2004-02-11 22:53:38 +0000420}
421
Brian Paulb5b8d222004-11-27 20:07:08 +0000422static void GLAPIENTRY VertexAttrib3uivNV(GLuint index, const GLuint *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000423{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000424 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, v[0], v[1], v[2]));
Brian Paul0d4393a2004-02-11 22:53:38 +0000425}
426
Brian Paulb5b8d222004-11-27 20:07:08 +0000427static void GLAPIENTRY VertexAttrib4NuivNV(GLuint index, const GLuint *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000428{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000429 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, UINT_TO_FLOAT(v[0]),
430 UINT_TO_FLOAT(v[1]),
431 UINT_TO_FLOAT(v[2]),
432 UINT_TO_FLOAT(v[3])));
Brian Paul0d4393a2004-02-11 22:53:38 +0000433}
434
Brian Paulb5b8d222004-11-27 20:07:08 +0000435static void GLAPIENTRY VertexAttrib4uivNV(GLuint index, const GLuint *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000436{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000437 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, v[0], v[1], v[2], v[3]));
Brian Paul0d4393a2004-02-11 22:53:38 +0000438}
439
440/* GL_FLOAT attributes */
441
Brian Paulb5b8d222004-11-27 20:07:08 +0000442static void GLAPIENTRY VertexAttrib1fvNV(GLuint index, const GLfloat *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000443{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000444 CALL_VertexAttrib1fvNV(GET_DISPATCH(), (index, v));
Brian Paul0d4393a2004-02-11 22:53:38 +0000445}
446
Brian Paulb5b8d222004-11-27 20:07:08 +0000447static void GLAPIENTRY VertexAttrib2fvNV(GLuint index, const GLfloat *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000448{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000449 CALL_VertexAttrib2fvNV(GET_DISPATCH(), (index, v));
Brian Paul0d4393a2004-02-11 22:53:38 +0000450}
451
Brian Paulb5b8d222004-11-27 20:07:08 +0000452static void GLAPIENTRY VertexAttrib3fvNV(GLuint index, const GLfloat *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000453{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000454 CALL_VertexAttrib3fvNV(GET_DISPATCH(), (index, v));
Brian Paul0d4393a2004-02-11 22:53:38 +0000455}
456
Brian Paulb5b8d222004-11-27 20:07:08 +0000457static void GLAPIENTRY VertexAttrib4fvNV(GLuint index, const GLfloat *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000458{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000459 CALL_VertexAttrib4fvNV(GET_DISPATCH(), (index, v));
Brian Paul0d4393a2004-02-11 22:53:38 +0000460}
461
462/* GL_DOUBLE attributes */
463
Brian Paulb5b8d222004-11-27 20:07:08 +0000464static void GLAPIENTRY VertexAttrib1dvNV(GLuint index, const GLdouble *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000465{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000466 CALL_VertexAttrib1dvNV(GET_DISPATCH(), (index, v));
Brian Paul0d4393a2004-02-11 22:53:38 +0000467}
468
Brian Paulb5b8d222004-11-27 20:07:08 +0000469static void GLAPIENTRY VertexAttrib2dvNV(GLuint index, const GLdouble *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000470{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000471 CALL_VertexAttrib2dvNV(GET_DISPATCH(), (index, v));
Brian Paul0d4393a2004-02-11 22:53:38 +0000472}
473
Brian Paulb5b8d222004-11-27 20:07:08 +0000474static void GLAPIENTRY VertexAttrib3dvNV(GLuint index, const GLdouble *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000475{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000476 CALL_VertexAttrib3dvNV(GET_DISPATCH(), (index, v));
Brian Paul0d4393a2004-02-11 22:53:38 +0000477}
478
Brian Paulb5b8d222004-11-27 20:07:08 +0000479static void GLAPIENTRY VertexAttrib4dvNV(GLuint index, const GLdouble *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000480{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000481 CALL_VertexAttrib4dvNV(GET_DISPATCH(), (index, v));
Brian Paul0d4393a2004-02-11 22:53:38 +0000482}
483
484
485/*
486 * Array [size][type] of VertexAttrib functions
487 */
Brian Paulb5b8d222004-11-27 20:07:08 +0000488static attrib_func AttribFuncsNV[2][4][8] = {
Brian Paul0d4393a2004-02-11 22:53:38 +0000489 {
490 /* non-normalized */
491 {
492 /* size 1 */
Brian Paulb5b8d222004-11-27 20:07:08 +0000493 (attrib_func) VertexAttrib1bvNV,
494 (attrib_func) VertexAttrib1ubvNV,
495 (attrib_func) VertexAttrib1svNV,
496 (attrib_func) VertexAttrib1usvNV,
497 (attrib_func) VertexAttrib1ivNV,
498 (attrib_func) VertexAttrib1uivNV,
499 (attrib_func) VertexAttrib1fvNV,
500 (attrib_func) VertexAttrib1dvNV
Brian Paul0d4393a2004-02-11 22:53:38 +0000501 },
502 {
503 /* size 2 */
Brian Paulb5b8d222004-11-27 20:07:08 +0000504 (attrib_func) VertexAttrib2bvNV,
505 (attrib_func) VertexAttrib2ubvNV,
506 (attrib_func) VertexAttrib2svNV,
507 (attrib_func) VertexAttrib2usvNV,
508 (attrib_func) VertexAttrib2ivNV,
509 (attrib_func) VertexAttrib2uivNV,
510 (attrib_func) VertexAttrib2fvNV,
511 (attrib_func) VertexAttrib2dvNV
Brian Paul0d4393a2004-02-11 22:53:38 +0000512 },
513 {
514 /* size 3 */
Brian Paulb5b8d222004-11-27 20:07:08 +0000515 (attrib_func) VertexAttrib3bvNV,
516 (attrib_func) VertexAttrib3ubvNV,
517 (attrib_func) VertexAttrib3svNV,
518 (attrib_func) VertexAttrib3usvNV,
519 (attrib_func) VertexAttrib3ivNV,
520 (attrib_func) VertexAttrib3uivNV,
521 (attrib_func) VertexAttrib3fvNV,
522 (attrib_func) VertexAttrib3dvNV
Brian Paul0d4393a2004-02-11 22:53:38 +0000523 },
524 {
525 /* size 4 */
Brian Paulb5b8d222004-11-27 20:07:08 +0000526 (attrib_func) VertexAttrib4bvNV,
527 (attrib_func) VertexAttrib4ubvNV,
528 (attrib_func) VertexAttrib4svNV,
529 (attrib_func) VertexAttrib4usvNV,
530 (attrib_func) VertexAttrib4ivNV,
531 (attrib_func) VertexAttrib4uivNV,
532 (attrib_func) VertexAttrib4fvNV,
533 (attrib_func) VertexAttrib4dvNV
Brian Paul0d4393a2004-02-11 22:53:38 +0000534 }
535 },
536 {
537 /* normalized (except for float/double) */
538 {
539 /* size 1 */
Brian Paulb5b8d222004-11-27 20:07:08 +0000540 (attrib_func) VertexAttrib1NbvNV,
541 (attrib_func) VertexAttrib1NubvNV,
542 (attrib_func) VertexAttrib1NsvNV,
543 (attrib_func) VertexAttrib1NusvNV,
544 (attrib_func) VertexAttrib1NivNV,
545 (attrib_func) VertexAttrib1NuivNV,
546 (attrib_func) VertexAttrib1fvNV,
547 (attrib_func) VertexAttrib1dvNV
Brian Paul0d4393a2004-02-11 22:53:38 +0000548 },
549 {
550 /* size 2 */
Brian Paulb5b8d222004-11-27 20:07:08 +0000551 (attrib_func) VertexAttrib2NbvNV,
552 (attrib_func) VertexAttrib2NubvNV,
553 (attrib_func) VertexAttrib2NsvNV,
554 (attrib_func) VertexAttrib2NusvNV,
555 (attrib_func) VertexAttrib2NivNV,
556 (attrib_func) VertexAttrib2NuivNV,
557 (attrib_func) VertexAttrib2fvNV,
558 (attrib_func) VertexAttrib2dvNV
Brian Paul0d4393a2004-02-11 22:53:38 +0000559 },
560 {
561 /* size 3 */
Brian Paulb5b8d222004-11-27 20:07:08 +0000562 (attrib_func) VertexAttrib3NbvNV,
563 (attrib_func) VertexAttrib3NubvNV,
564 (attrib_func) VertexAttrib3NsvNV,
565 (attrib_func) VertexAttrib3NusvNV,
566 (attrib_func) VertexAttrib3NivNV,
567 (attrib_func) VertexAttrib3NuivNV,
568 (attrib_func) VertexAttrib3fvNV,
569 (attrib_func) VertexAttrib3dvNV
Brian Paul0d4393a2004-02-11 22:53:38 +0000570 },
571 {
572 /* size 4 */
Brian Paulb5b8d222004-11-27 20:07:08 +0000573 (attrib_func) VertexAttrib4NbvNV,
574 (attrib_func) VertexAttrib4NubvNV,
575 (attrib_func) VertexAttrib4NsvNV,
576 (attrib_func) VertexAttrib4NusvNV,
577 (attrib_func) VertexAttrib4NivNV,
578 (attrib_func) VertexAttrib4NuivNV,
579 (attrib_func) VertexAttrib4fvNV,
580 (attrib_func) VertexAttrib4dvNV
Brian Paul0d4393a2004-02-11 22:53:38 +0000581 }
582 }
583};
584
585/**********************************************************************/
586
Keith Whitwell4b7d6f22001-06-01 22:22:10 +0000587
588GLboolean _ae_create_context( GLcontext *ctx )
Keith Whitwellcab974c2000-12-26 05:09:27 +0000589{
Keith Whitwellae0eaf92003-11-24 15:23:18 +0000590 if (ctx->aelt_context)
591 return GL_TRUE;
592
Brian Paul0f1d98c2006-03-17 04:10:03 +0000593 /* These _gloffset_* values may not be compile-time constants */
Ian Romanick126c89e2005-08-05 18:13:37 +0000594 SecondaryColorFuncs[0] = _gloffset_SecondaryColor3bvEXT;
595 SecondaryColorFuncs[1] = _gloffset_SecondaryColor3ubvEXT;
596 SecondaryColorFuncs[2] = _gloffset_SecondaryColor3svEXT;
597 SecondaryColorFuncs[3] = _gloffset_SecondaryColor3usvEXT;
598 SecondaryColorFuncs[4] = _gloffset_SecondaryColor3ivEXT;
599 SecondaryColorFuncs[5] = _gloffset_SecondaryColor3uivEXT;
600 SecondaryColorFuncs[6] = _gloffset_SecondaryColor3fvEXT;
601 SecondaryColorFuncs[7] = _gloffset_SecondaryColor3dvEXT;
602
603 FogCoordFuncs[6] = _gloffset_FogCoordfvEXT;
604 FogCoordFuncs[7] = _gloffset_FogCoorddvEXT;
Ian Romanick126c89e2005-08-05 18:13:37 +0000605
Keith Whitwell4b7d6f22001-06-01 22:22:10 +0000606 ctx->aelt_context = MALLOC( sizeof(AEcontext) );
Gareth Hughes1fb0a432001-12-28 06:28:10 +0000607 if (!ctx->aelt_context)
Keith Whitwell4b7d6f22001-06-01 22:22:10 +0000608 return GL_FALSE;
609
610 AE_CONTEXT(ctx)->NewState = ~0;
611 return GL_TRUE;
Keith Whitwellcab974c2000-12-26 05:09:27 +0000612}
613
Keith Whitwell4b7d6f22001-06-01 22:22:10 +0000614
615void _ae_destroy_context( GLcontext *ctx )
Keith Whitwellcab974c2000-12-26 05:09:27 +0000616{
Keith Whitwell4b7d6f22001-06-01 22:22:10 +0000617 if ( AE_CONTEXT( ctx ) ) {
618 FREE( ctx->aelt_context );
Keith Whitwella0c85242005-02-11 09:34:05 +0000619 ctx->aelt_context = NULL;
Keith Whitwell4b7d6f22001-06-01 22:22:10 +0000620 }
621}
622
623
Brian Paul0d4393a2004-02-11 22:53:38 +0000624/**
625 * Make a list of per-vertex functions to call for each glArrayElement call.
Brian Paul1e3d8682004-02-24 02:49:43 +0000626 * These functions access the array data (i.e. glVertex, glColor, glNormal,
627 * etc).
628 * Note: this may be called during display list construction.
Brian Paul0d4393a2004-02-11 22:53:38 +0000629 */
Keith Whitwell4b7d6f22001-06-01 22:22:10 +0000630static void _ae_update_state( GLcontext *ctx )
631{
632 AEcontext *actx = AE_CONTEXT(ctx);
Keith Whitwell4b7d6f22001-06-01 22:22:10 +0000633 AEarray *aa = actx->arrays;
Brian Paul0d4393a2004-02-11 22:53:38 +0000634 AEattrib *at = actx->attribs;
Brian Pauldb07de02002-04-19 00:23:08 +0000635 GLuint i;
Keith Whitwellcab974c2000-12-26 05:09:27 +0000636
Brian Paul1e3d8682004-02-24 02:49:43 +0000637 /* conventional vertex arrays */
638 if (ctx->Array.Index.Enabled) {
Keith Whitwellcab974c2000-12-26 05:09:27 +0000639 aa->array = &ctx->Array.Index;
Ian Romanick9bdfee32005-07-18 12:31:24 +0000640 aa->offset = IndexFuncs[TYPE_IDX(aa->array->Type)];
Keith Whitwellcab974c2000-12-26 05:09:27 +0000641 aa++;
642 }
Keith Whitwellcab974c2000-12-26 05:09:27 +0000643 if (ctx->Array.EdgeFlag.Enabled) {
Keith Whitwell4b7d6f22001-06-01 22:22:10 +0000644 aa->array = &ctx->Array.EdgeFlag;
Ian Romanick9bdfee32005-07-18 12:31:24 +0000645 aa->offset = _gloffset_EdgeFlagv;
Keith Whitwellcab974c2000-12-26 05:09:27 +0000646 aa++;
647 }
Brian Paul1e3d8682004-02-24 02:49:43 +0000648 if (ctx->Array.Normal.Enabled) {
649 aa->array = &ctx->Array.Normal;
Ian Romanick9bdfee32005-07-18 12:31:24 +0000650 aa->offset = NormalFuncs[TYPE_IDX(aa->array->Type)];
Brian Paul1e3d8682004-02-24 02:49:43 +0000651 aa++;
652 }
653 if (ctx->Array.Color.Enabled) {
654 aa->array = &ctx->Array.Color;
Ian Romanick9bdfee32005-07-18 12:31:24 +0000655 aa->offset = ColorFuncs[aa->array->Size-3][TYPE_IDX(aa->array->Type)];
Brian Paul1e3d8682004-02-24 02:49:43 +0000656 aa++;
657 }
658 if (ctx->Array.SecondaryColor.Enabled) {
659 aa->array = &ctx->Array.SecondaryColor;
Ian Romanick9bdfee32005-07-18 12:31:24 +0000660 aa->offset = SecondaryColorFuncs[TYPE_IDX(aa->array->Type)];
Brian Paul1e3d8682004-02-24 02:49:43 +0000661 aa++;
662 }
663 if (ctx->Array.FogCoord.Enabled) {
664 aa->array = &ctx->Array.FogCoord;
Ian Romanick9bdfee32005-07-18 12:31:24 +0000665 aa->offset = FogCoordFuncs[TYPE_IDX(aa->array->Type)];
Brian Paul1e3d8682004-02-24 02:49:43 +0000666 aa++;
667 }
668 for (i = 0; i < ctx->Const.MaxTextureCoordUnits; i++) {
Adam Jackson37e86252006-01-19 18:00:38 +0000669 if (ctx->Array.TexCoord[i].Enabled && ctx->Array.TexCoord[i].Ptr) {
Brian Paul1e3d8682004-02-24 02:49:43 +0000670 /* NOTE: we use generic glVertexAttrib functions here.
671 * If we ever de-alias conventional/generic vertex attribs this
672 * will have to change.
673 */
674 struct gl_client_array *attribArray = &ctx->Array.TexCoord[i];
675 at->array = attribArray;
Brian Paulb5b8d222004-11-27 20:07:08 +0000676 at->func = AttribFuncsNV[at->array->Normalized][at->array->Size-1][TYPE_IDX(at->array->Type)];
Brian Paul9d1ff8c2004-02-24 14:59:26 +0000677 at->index = VERT_ATTRIB_TEX0 + i;
Brian Paul1e3d8682004-02-24 02:49:43 +0000678 at++;
Brian Paul0d4393a2004-02-11 22:53:38 +0000679 }
Brian Paul1e3d8682004-02-24 02:49:43 +0000680 }
Roland Scheideggerfaaf78a2004-02-11 01:06:03 +0000681
Brian Paul1e3d8682004-02-24 02:49:43 +0000682 /* generic vertex attribute arrays */
683 for (i = 1; i < VERT_ATTRIB_MAX; i++) { /* skip zero! */
Adam Jackson37e86252006-01-19 18:00:38 +0000684 if (ctx->Array.VertexAttrib[i].Enabled &&
685 ctx->Array.VertexAttrib[i].Ptr) {
Brian Paul1e3d8682004-02-24 02:49:43 +0000686 struct gl_client_array *attribArray = &ctx->Array.VertexAttrib[i];
Brian Paul0d4393a2004-02-11 22:53:38 +0000687 at->array = attribArray;
688 /* Note: we can't grab the _glapi_Dispatch->VertexAttrib1fvNV
689 * function pointer here (for float arrays) since the pointer may
690 * change from one execution of _ae_loopback_array_elt() to
691 * the next. Doing so caused UT to break.
692 */
Brian Paulb5b8d222004-11-27 20:07:08 +0000693 at->func = AttribFuncsNV[at->array->Normalized][at->array->Size-1][TYPE_IDX(at->array->Type)];
Brian Paul1e3d8682004-02-24 02:49:43 +0000694 at->index = i;
Brian Paul0d4393a2004-02-11 22:53:38 +0000695 at++;
696 }
Roland Scheideggerfaaf78a2004-02-11 01:06:03 +0000697 }
Brian Paul1e3d8682004-02-24 02:49:43 +0000698
699 /* finally, vertex position */
700 if (ctx->Array.VertexAttrib[0].Enabled) {
701 /* Use glVertex(v) instead of glVertexAttrib(0, v) to be sure it's
702 * issued as the last (proviking) attribute).
703 */
704 aa->array = &ctx->Array.VertexAttrib[0];
705 assert(aa->array->Size >= 2); /* XXX fix someday? */
Ian Romanick9bdfee32005-07-18 12:31:24 +0000706 aa->offset = VertexFuncs[aa->array->Size-2][TYPE_IDX(aa->array->Type)];
Brian Paul1e3d8682004-02-24 02:49:43 +0000707 aa++;
708 }
709 else if (ctx->Array.Vertex.Enabled) {
710 aa->array = &ctx->Array.Vertex;
Ian Romanick9bdfee32005-07-18 12:31:24 +0000711 aa->offset = VertexFuncs[aa->array->Size-2][TYPE_IDX(aa->array->Type)];
Brian Paul1e3d8682004-02-24 02:49:43 +0000712 aa++;
713 }
714
Brian Paul0d4393a2004-02-11 22:53:38 +0000715 ASSERT(at - actx->attribs <= VERT_ATTRIB_MAX);
716 ASSERT(aa - actx->arrays < 32);
717 at->func = NULL; /* terminate the list */
Ian Romanick9bdfee32005-07-18 12:31:24 +0000718 aa->offset = -1; /* terminate the list */
Roland Scheideggerfaaf78a2004-02-11 01:06:03 +0000719
Keith Whitwellcab974c2000-12-26 05:09:27 +0000720 actx->NewState = 0;
721}
722
723
Brian Paul1e3d8682004-02-24 02:49:43 +0000724/**
725 * Called via glArrayElement() and glDrawArrays().
726 * Issue the glNormal, glVertex, glColor, glVertexAttrib, etc functions
727 * for all enabled vertex arrays (for elt-th element).
728 * Note: this may be called during display list construction.
729 */
Karl Schultzd6745692003-12-04 20:23:44 +0000730void GLAPIENTRY _ae_loopback_array_elt( GLint elt )
Keith Whitwellcab974c2000-12-26 05:09:27 +0000731{
732 GET_CURRENT_CONTEXT(ctx);
Brian Paul0d4393a2004-02-11 22:53:38 +0000733 const AEcontext *actx = AE_CONTEXT(ctx);
734 const AEarray *aa;
735 const AEattrib *at;
Ian Romanick9bdfee32005-07-18 12:31:24 +0000736 const struct _glapi_table * const disp = GET_DISPATCH();
737
Keith Whitwell4b7d6f22001-06-01 22:22:10 +0000738
739 if (actx->NewState)
740 _ae_update_state( ctx );
Keith Whitwellcab974c2000-12-26 05:09:27 +0000741
Brian Paul0d4393a2004-02-11 22:53:38 +0000742 /* generic attributes */
743 for (at = actx->attribs; at->func; at++) {
Brian Paul024b5892005-11-25 17:07:10 +0000744 const GLubyte *src
745 = ADD_POINTERS(at->array->BufferObj->Data, at->array->Ptr)
746 + elt * at->array->StrideB;
Brian Paul0d4393a2004-02-11 22:53:38 +0000747 at->func( at->index, src );
Brian Paul53ad0362004-02-09 00:24:48 +0000748 }
749
Brian Paul0d4393a2004-02-11 22:53:38 +0000750 /* conventional arrays */
Ian Romanick9bdfee32005-07-18 12:31:24 +0000751 for (aa = actx->arrays; aa->offset != -1 ; aa++) {
Brian Paul024b5892005-11-25 17:07:10 +0000752 const GLubyte *src
753 = ADD_POINTERS(aa->array->BufferObj->Data, aa->array->Ptr)
754 + elt * aa->array->StrideB;
Ian Romanick9bdfee32005-07-18 12:31:24 +0000755 CALL_by_offset( disp, (array_func), aa->offset,
756 ((const void *) src) );
Keith Whitwellcab974c2000-12-26 05:09:27 +0000757 }
Keith Whitwellcab974c2000-12-26 05:09:27 +0000758}
759
760
Keith Whitwell4b7d6f22001-06-01 22:22:10 +0000761void _ae_invalidate_state( GLcontext *ctx, GLuint new_state )
Keith Whitwellcab974c2000-12-26 05:09:27 +0000762{
Keith Whitwell4b7d6f22001-06-01 22:22:10 +0000763 AE_CONTEXT(ctx)->NewState |= new_state;
Keith Whitwellcab974c2000-12-26 05:09:27 +0000764}