blob: 9c65ae5b9a1a28d8d4337fe4a0eb730a423aa6e1 [file] [log] [blame]
Gareth Hughes22144ab2001-03-12 00:48:37 +00001/*
2 * Mesa 3-D graphics library
Brian Paul095c6692006-04-25 00:21:32 +00003 * Version: 6.5.1
Gareth Hughes22144ab2001-03-12 00:48:37 +00004 *
Brian Pauleec33cc2006-03-17 04:13:29 +00005 * Copyright (C) 1999-2006 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"
Brian Paul3c634522002-10-24 23:57:19 +000032#include "imports.h"
Keith Whitwellcab974c2000-12-26 05:09:27 +000033#include "macros.h"
Ian Romanick9bdfee32005-07-18 12:31:24 +000034#include "glapioffsets.h"
35#include "dispatch.h"
Keith Whitwellcab974c2000-12-26 05:09:27 +000036
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 Paul0d4393a2004-02-11 22:53:38 +000040 const struct gl_client_array *array;
Ian Romanick9bdfee32005-07-18 12:31:24 +000041 int offset;
Keith Whitwell4b7d6f22001-06-01 22:22:10 +000042} AEarray;
Keith Whitwellcab974c2000-12-26 05:09:27 +000043
Brian Paul0d4393a2004-02-11 22:53:38 +000044typedef void (GLAPIENTRY *attrib_func)( GLuint indx, const void *data );
45
Keith Whitwellcab974c2000-12-26 05:09:27 +000046typedef struct {
Brian Paul0d4393a2004-02-11 22:53:38 +000047 const struct gl_client_array *array;
48 attrib_func func;
49 GLuint index;
50} AEattrib;
51
52typedef struct {
Brian Paul53ad0362004-02-09 00:24:48 +000053 AEarray arrays[32];
Brian Paul0d4393a2004-02-11 22:53:38 +000054 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 Paul0d4393a2004-02-11 22:53:38 +000059
Ian Romanick9bdfee32005-07-18 12:31:24 +000060
Brian Paul0d4393a2004-02-11 22:53:38 +000061/*
62 * Convert GL_BYTE, GL_UNSIGNED_BYTE, .. GL_DOUBLE into an integer
63 * in the range [0, 7]. Luckily these type tokens are sequentially
Brian Paulf2f33502004-04-23 17:58:06 +000064 * numbered in gl.h, except for GL_DOUBLE.
Brian Paul0d4393a2004-02-11 22:53:38 +000065 */
Brian Paulf2f33502004-04-23 17:58:06 +000066#define TYPE_IDX(t) ( (t) == GL_DOUBLE ? 7 : (t) & 7 )
Keith Whitwellcab974c2000-12-26 05:09:27 +000067
Ian Romanick9bdfee32005-07-18 12:31:24 +000068static const int ColorFuncs[2][8] = {
Adam Jackson94987be2004-10-24 02:05:40 +000069 {
Ian Romanick9bdfee32005-07-18 12:31:24 +000070 _gloffset_Color3bv,
71 _gloffset_Color3ubv,
72 _gloffset_Color3sv,
73 _gloffset_Color3usv,
74 _gloffset_Color3iv,
75 _gloffset_Color3uiv,
76 _gloffset_Color3fv,
77 _gloffset_Color3dv,
Adam Jackson94987be2004-10-24 02:05:40 +000078 },
79 {
Ian Romanick9bdfee32005-07-18 12:31:24 +000080 _gloffset_Color4bv,
81 _gloffset_Color4ubv,
82 _gloffset_Color4sv,
83 _gloffset_Color4usv,
84 _gloffset_Color4iv,
85 _gloffset_Color4uiv,
86 _gloffset_Color4fv,
87 _gloffset_Color4dv,
Adam Jackson94987be2004-10-24 02:05:40 +000088 },
Brian Paul53ad0362004-02-09 00:24:48 +000089};
90
Ian Romanick9bdfee32005-07-18 12:31:24 +000091static const int VertexFuncs[3][8] = {
Adam Jackson94987be2004-10-24 02:05:40 +000092 {
Ian Romanick9bdfee32005-07-18 12:31:24 +000093 -1,
94 -1,
95 _gloffset_Vertex2sv,
96 -1,
97 _gloffset_Vertex2iv,
98 -1,
99 _gloffset_Vertex2fv,
100 _gloffset_Vertex2dv,
Adam Jackson94987be2004-10-24 02:05:40 +0000101 },
102 {
Ian Romanick9bdfee32005-07-18 12:31:24 +0000103 -1,
104 -1,
105 _gloffset_Vertex3sv,
106 -1,
107 _gloffset_Vertex3iv,
108 -1,
109 _gloffset_Vertex3fv,
110 _gloffset_Vertex3dv,
Adam Jackson94987be2004-10-24 02:05:40 +0000111 },
112 {
Ian Romanick9bdfee32005-07-18 12:31:24 +0000113 -1,
114 -1,
115 _gloffset_Vertex4sv,
116 -1,
117 _gloffset_Vertex4iv,
118 -1,
119 _gloffset_Vertex4fv,
120 _gloffset_Vertex4dv,
Adam Jackson94987be2004-10-24 02:05:40 +0000121 },
Brian Paul53ad0362004-02-09 00:24:48 +0000122};
123
Ian Romanick9bdfee32005-07-18 12:31:24 +0000124static const int IndexFuncs[8] = {
125 -1,
126 _gloffset_Indexubv,
127 _gloffset_Indexsv,
128 -1,
129 _gloffset_Indexiv,
130 -1,
131 _gloffset_Indexfv,
132 _gloffset_Indexdv,
Keith Whitwellcab974c2000-12-26 05:09:27 +0000133};
134
Ian Romanick9bdfee32005-07-18 12:31:24 +0000135static const int NormalFuncs[8] = {
136 _gloffset_Normal3bv,
137 -1,
138 _gloffset_Normal3sv,
139 -1,
140 _gloffset_Normal3iv,
141 -1,
142 _gloffset_Normal3fv,
143 _gloffset_Normal3dv,
Adam Jackson94987be2004-10-24 02:05:40 +0000144};
Brian Paul53ad0362004-02-09 00:24:48 +0000145
Brian Paul0f1d98c2006-03-17 04:10:03 +0000146/* Note: _gloffset_* for these may not be a compile-time constant. */
Ian Romanick126c89e2005-08-05 18:13:37 +0000147static int SecondaryColorFuncs[8];
Brian Paul0f1d98c2006-03-17 04:10:03 +0000148static int FogCoordFuncs[8];
Brian Paul53ad0362004-02-09 00:24:48 +0000149
Brian Paul095c6692006-04-25 00:21:32 +0000150
151/**
152 ** GL_NV_vertex_program
153 **/
Brian Paul0d4393a2004-02-11 22:53:38 +0000154
155/* GL_BYTE attributes */
156
Brian Paulb5b8d222004-11-27 20:07:08 +0000157static void GLAPIENTRY VertexAttrib1NbvNV(GLuint index, const GLbyte *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000158{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000159 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, BYTE_TO_FLOAT(v[0])));
Brian Paul0d4393a2004-02-11 22:53:38 +0000160}
161
Brian Paulb5b8d222004-11-27 20:07:08 +0000162static void GLAPIENTRY VertexAttrib1bvNV(GLuint index, const GLbyte *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000163{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000164 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, v[0]));
Brian Paul0d4393a2004-02-11 22:53:38 +0000165}
166
Brian Paulb5b8d222004-11-27 20:07:08 +0000167static void GLAPIENTRY VertexAttrib2NbvNV(GLuint index, const GLbyte *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000168{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000169 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, BYTE_TO_FLOAT(v[0]), BYTE_TO_FLOAT(v[1])));
Brian Paul0d4393a2004-02-11 22:53:38 +0000170}
171
Brian Paulb5b8d222004-11-27 20:07:08 +0000172static void GLAPIENTRY VertexAttrib2bvNV(GLuint index, const GLbyte *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000173{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000174 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, v[0], v[1]));
Brian Paul0d4393a2004-02-11 22:53:38 +0000175}
176
Brian Paulb5b8d222004-11-27 20:07:08 +0000177static void GLAPIENTRY VertexAttrib3NbvNV(GLuint index, const GLbyte *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000178{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000179 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, BYTE_TO_FLOAT(v[0]),
180 BYTE_TO_FLOAT(v[1]),
181 BYTE_TO_FLOAT(v[2])));
Brian Paul0d4393a2004-02-11 22:53:38 +0000182}
183
Brian Paulb5b8d222004-11-27 20:07:08 +0000184static void GLAPIENTRY VertexAttrib3bvNV(GLuint index, const GLbyte *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000185{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000186 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, v[0], v[1], v[2]));
Brian Paul0d4393a2004-02-11 22:53:38 +0000187}
188
Brian Paulb5b8d222004-11-27 20:07:08 +0000189static void GLAPIENTRY VertexAttrib4NbvNV(GLuint index, const GLbyte *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000190{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000191 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, BYTE_TO_FLOAT(v[0]),
192 BYTE_TO_FLOAT(v[1]),
193 BYTE_TO_FLOAT(v[2]),
194 BYTE_TO_FLOAT(v[3])));
Brian Paul0d4393a2004-02-11 22:53:38 +0000195}
196
Brian Paulb5b8d222004-11-27 20:07:08 +0000197static void GLAPIENTRY VertexAttrib4bvNV(GLuint index, const GLbyte *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000198{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000199 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, v[0], v[1], v[2], v[3]));
Brian Paul0d4393a2004-02-11 22:53:38 +0000200}
201
202/* GL_UNSIGNED_BYTE attributes */
203
Brian Paulb5b8d222004-11-27 20:07:08 +0000204static void GLAPIENTRY VertexAttrib1NubvNV(GLuint index, const GLubyte *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000205{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000206 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, UBYTE_TO_FLOAT(v[0])));
Brian Paul0d4393a2004-02-11 22:53:38 +0000207}
208
Brian Paulb5b8d222004-11-27 20:07:08 +0000209static void GLAPIENTRY VertexAttrib1ubvNV(GLuint index, const GLubyte *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000210{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000211 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, v[0]));
Brian Paul0d4393a2004-02-11 22:53:38 +0000212}
213
Brian Paulb5b8d222004-11-27 20:07:08 +0000214static void GLAPIENTRY VertexAttrib2NubvNV(GLuint index, const GLubyte *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000215{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000216 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, UBYTE_TO_FLOAT(v[0]),
217 UBYTE_TO_FLOAT(v[1])));
Brian Paul0d4393a2004-02-11 22:53:38 +0000218}
219
Brian Paulb5b8d222004-11-27 20:07:08 +0000220static void GLAPIENTRY VertexAttrib2ubvNV(GLuint index, const GLubyte *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000221{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000222 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, v[0], v[1]));
Brian Paul0d4393a2004-02-11 22:53:38 +0000223}
224
Brian Paulb5b8d222004-11-27 20:07:08 +0000225static void GLAPIENTRY VertexAttrib3NubvNV(GLuint index, const GLubyte *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000226{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000227 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, UBYTE_TO_FLOAT(v[0]),
228 UBYTE_TO_FLOAT(v[1]),
229 UBYTE_TO_FLOAT(v[2])));
Brian Paul0d4393a2004-02-11 22:53:38 +0000230}
Brian Paulb5b8d222004-11-27 20:07:08 +0000231static void GLAPIENTRY VertexAttrib3ubvNV(GLuint index, const GLubyte *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000232{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000233 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, v[0], v[1], v[2]));
Brian Paul0d4393a2004-02-11 22:53:38 +0000234}
235
Brian Paulb5b8d222004-11-27 20:07:08 +0000236static void GLAPIENTRY VertexAttrib4NubvNV(GLuint index, const GLubyte *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000237{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000238 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, UBYTE_TO_FLOAT(v[0]),
Brian Paul0d4393a2004-02-11 22:53:38 +0000239 UBYTE_TO_FLOAT(v[1]),
240 UBYTE_TO_FLOAT(v[2]),
Ian Romanick9bdfee32005-07-18 12:31:24 +0000241 UBYTE_TO_FLOAT(v[3])));
Brian Paul0d4393a2004-02-11 22:53:38 +0000242}
243
Brian Paulb5b8d222004-11-27 20:07:08 +0000244static void GLAPIENTRY VertexAttrib4ubvNV(GLuint index, const GLubyte *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000245{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000246 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, v[0], v[1], v[2], v[3]));
Brian Paul0d4393a2004-02-11 22:53:38 +0000247}
248
249/* GL_SHORT attributes */
250
Brian Paulb5b8d222004-11-27 20:07:08 +0000251static void GLAPIENTRY VertexAttrib1NsvNV(GLuint index, const GLshort *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000252{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000253 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, SHORT_TO_FLOAT(v[0])));
Brian Paul0d4393a2004-02-11 22:53:38 +0000254}
255
Brian Paulb5b8d222004-11-27 20:07:08 +0000256static void GLAPIENTRY VertexAttrib1svNV(GLuint index, const GLshort *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000257{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000258 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, v[0]));
Brian Paul0d4393a2004-02-11 22:53:38 +0000259}
260
Brian Paulb5b8d222004-11-27 20:07:08 +0000261static void GLAPIENTRY VertexAttrib2NsvNV(GLuint index, const GLshort *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000262{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000263 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, SHORT_TO_FLOAT(v[0]),
264 SHORT_TO_FLOAT(v[1])));
Brian Paul0d4393a2004-02-11 22:53:38 +0000265}
266
Brian Paulb5b8d222004-11-27 20:07:08 +0000267static void GLAPIENTRY VertexAttrib2svNV(GLuint index, const GLshort *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000268{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000269 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, v[0], v[1]));
Brian Paul0d4393a2004-02-11 22:53:38 +0000270}
271
Brian Paulb5b8d222004-11-27 20:07:08 +0000272static void GLAPIENTRY VertexAttrib3NsvNV(GLuint index, const GLshort *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000273{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000274 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, SHORT_TO_FLOAT(v[0]),
Ian Romanickc1d455f2004-05-27 00:03:53 +0000275 SHORT_TO_FLOAT(v[1]),
Ian Romanick9bdfee32005-07-18 12:31:24 +0000276 SHORT_TO_FLOAT(v[2])));
Brian Paul0d4393a2004-02-11 22:53:38 +0000277}
278
Brian Paulb5b8d222004-11-27 20:07:08 +0000279static void GLAPIENTRY VertexAttrib3svNV(GLuint index, const GLshort *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000280{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000281 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, v[0], v[1], v[2]));
Brian Paul0d4393a2004-02-11 22:53:38 +0000282}
283
Brian Paulb5b8d222004-11-27 20:07:08 +0000284static void GLAPIENTRY VertexAttrib4NsvNV(GLuint index, const GLshort *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000285{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000286 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, SHORT_TO_FLOAT(v[0]),
Ian Romanickc1d455f2004-05-27 00:03:53 +0000287 SHORT_TO_FLOAT(v[1]),
288 SHORT_TO_FLOAT(v[2]),
Ian Romanick9bdfee32005-07-18 12:31:24 +0000289 SHORT_TO_FLOAT(v[3])));
Brian Paul0d4393a2004-02-11 22:53:38 +0000290}
291
Brian Paulb5b8d222004-11-27 20:07:08 +0000292static void GLAPIENTRY VertexAttrib4svNV(GLuint index, const GLshort *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000293{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000294 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, v[0], v[1], v[2], v[3]));
Brian Paul0d4393a2004-02-11 22:53:38 +0000295}
296
297/* GL_UNSIGNED_SHORT attributes */
298
Brian Paulb5b8d222004-11-27 20:07:08 +0000299static void GLAPIENTRY VertexAttrib1NusvNV(GLuint index, const GLushort *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000300{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000301 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, USHORT_TO_FLOAT(v[0])));
Brian Paul0d4393a2004-02-11 22:53:38 +0000302}
303
Brian Paulb5b8d222004-11-27 20:07:08 +0000304static void GLAPIENTRY VertexAttrib1usvNV(GLuint index, const GLushort *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000305{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000306 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, v[0]));
Brian Paul0d4393a2004-02-11 22:53:38 +0000307}
308
Brian Paulb5b8d222004-11-27 20:07:08 +0000309static void GLAPIENTRY VertexAttrib2NusvNV(GLuint index, const GLushort *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000310{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000311 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, USHORT_TO_FLOAT(v[0]),
312 USHORT_TO_FLOAT(v[1])));
Brian Paul0d4393a2004-02-11 22:53:38 +0000313}
314
Brian Paulb5b8d222004-11-27 20:07:08 +0000315static void GLAPIENTRY VertexAttrib2usvNV(GLuint index, const GLushort *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000316{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000317 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, v[0], v[1]));
Brian Paul0d4393a2004-02-11 22:53:38 +0000318}
319
Brian Paulb5b8d222004-11-27 20:07:08 +0000320static void GLAPIENTRY VertexAttrib3NusvNV(GLuint index, const GLushort *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000321{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000322 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, USHORT_TO_FLOAT(v[0]),
323 USHORT_TO_FLOAT(v[1]),
324 USHORT_TO_FLOAT(v[2])));
Brian Paul0d4393a2004-02-11 22:53:38 +0000325}
326
Brian Paulb5b8d222004-11-27 20:07:08 +0000327static void GLAPIENTRY VertexAttrib3usvNV(GLuint index, const GLushort *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000328{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000329 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, v[0], v[1], v[2]));
Brian Paul0d4393a2004-02-11 22:53:38 +0000330}
331
Brian Paulb5b8d222004-11-27 20:07:08 +0000332static void GLAPIENTRY VertexAttrib4NusvNV(GLuint index, const GLushort *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000333{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000334 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, USHORT_TO_FLOAT(v[0]),
335 USHORT_TO_FLOAT(v[1]),
336 USHORT_TO_FLOAT(v[2]),
337 USHORT_TO_FLOAT(v[3])));
Brian Paul0d4393a2004-02-11 22:53:38 +0000338}
339
Brian Paulb5b8d222004-11-27 20:07:08 +0000340static void GLAPIENTRY VertexAttrib4usvNV(GLuint index, const GLushort *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000341{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000342 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, v[0], v[1], v[2], v[3]));
Brian Paul0d4393a2004-02-11 22:53:38 +0000343}
344
345/* GL_INT attributes */
346
Brian Paulb5b8d222004-11-27 20:07:08 +0000347static void GLAPIENTRY VertexAttrib1NivNV(GLuint index, const GLint *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000348{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000349 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, INT_TO_FLOAT(v[0])));
Brian Paul0d4393a2004-02-11 22:53:38 +0000350}
351
Brian Paulb5b8d222004-11-27 20:07:08 +0000352static void GLAPIENTRY VertexAttrib1ivNV(GLuint index, const GLint *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000353{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000354 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, v[0]));
Brian Paul0d4393a2004-02-11 22:53:38 +0000355}
356
Brian Paulb5b8d222004-11-27 20:07:08 +0000357static void GLAPIENTRY VertexAttrib2NivNV(GLuint index, const GLint *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000358{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000359 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, INT_TO_FLOAT(v[0]),
360 INT_TO_FLOAT(v[1])));
Brian Paul0d4393a2004-02-11 22:53:38 +0000361}
362
Brian Paulb5b8d222004-11-27 20:07:08 +0000363static void GLAPIENTRY VertexAttrib2ivNV(GLuint index, const GLint *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000364{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000365 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, v[0], v[1]));
Brian Paul0d4393a2004-02-11 22:53:38 +0000366}
367
Brian Paulb5b8d222004-11-27 20:07:08 +0000368static void GLAPIENTRY VertexAttrib3NivNV(GLuint index, const GLint *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000369{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000370 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, INT_TO_FLOAT(v[0]),
371 INT_TO_FLOAT(v[1]),
372 INT_TO_FLOAT(v[2])));
Brian Paul0d4393a2004-02-11 22:53:38 +0000373}
374
Brian Paulb5b8d222004-11-27 20:07:08 +0000375static void GLAPIENTRY VertexAttrib3ivNV(GLuint index, const GLint *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000376{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000377 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, v[0], v[1], v[2]));
Brian Paul0d4393a2004-02-11 22:53:38 +0000378}
379
Brian Paulb5b8d222004-11-27 20:07:08 +0000380static void GLAPIENTRY VertexAttrib4NivNV(GLuint index, const GLint *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000381{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000382 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, INT_TO_FLOAT(v[0]),
383 INT_TO_FLOAT(v[1]),
384 INT_TO_FLOAT(v[2]),
385 INT_TO_FLOAT(v[3])));
Brian Paul0d4393a2004-02-11 22:53:38 +0000386}
387
Brian Paulb5b8d222004-11-27 20:07:08 +0000388static void GLAPIENTRY VertexAttrib4ivNV(GLuint index, const GLint *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000389{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000390 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, v[0], v[1], v[2], v[3]));
Brian Paul0d4393a2004-02-11 22:53:38 +0000391}
392
393/* GL_UNSIGNED_INT attributes */
394
Brian Paulb5b8d222004-11-27 20:07:08 +0000395static void GLAPIENTRY VertexAttrib1NuivNV(GLuint index, const GLuint *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000396{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000397 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, UINT_TO_FLOAT(v[0])));
Brian Paul0d4393a2004-02-11 22:53:38 +0000398}
399
Brian Paulb5b8d222004-11-27 20:07:08 +0000400static void GLAPIENTRY VertexAttrib1uivNV(GLuint index, const GLuint *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000401{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000402 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, v[0]));
Brian Paul0d4393a2004-02-11 22:53:38 +0000403}
404
Brian Paulb5b8d222004-11-27 20:07:08 +0000405static void GLAPIENTRY VertexAttrib2NuivNV(GLuint index, const GLuint *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000406{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000407 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, UINT_TO_FLOAT(v[0]),
408 UINT_TO_FLOAT(v[1])));
Brian Paul0d4393a2004-02-11 22:53:38 +0000409}
410
Brian Paulb5b8d222004-11-27 20:07:08 +0000411static void GLAPIENTRY VertexAttrib2uivNV(GLuint index, const GLuint *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000412{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000413 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, v[0], v[1]));
Brian Paul0d4393a2004-02-11 22:53:38 +0000414}
415
Brian Paulb5b8d222004-11-27 20:07:08 +0000416static void GLAPIENTRY VertexAttrib3NuivNV(GLuint index, const GLuint *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000417{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000418 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, UINT_TO_FLOAT(v[0]),
419 UINT_TO_FLOAT(v[1]),
420 UINT_TO_FLOAT(v[2])));
Brian Paul0d4393a2004-02-11 22:53:38 +0000421}
422
Brian Paulb5b8d222004-11-27 20:07:08 +0000423static void GLAPIENTRY VertexAttrib3uivNV(GLuint index, const GLuint *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000424{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000425 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, v[0], v[1], v[2]));
Brian Paul0d4393a2004-02-11 22:53:38 +0000426}
427
Brian Paulb5b8d222004-11-27 20:07:08 +0000428static void GLAPIENTRY VertexAttrib4NuivNV(GLuint index, const GLuint *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000429{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000430 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, UINT_TO_FLOAT(v[0]),
431 UINT_TO_FLOAT(v[1]),
432 UINT_TO_FLOAT(v[2]),
433 UINT_TO_FLOAT(v[3])));
Brian Paul0d4393a2004-02-11 22:53:38 +0000434}
435
Brian Paulb5b8d222004-11-27 20:07:08 +0000436static void GLAPIENTRY VertexAttrib4uivNV(GLuint index, const GLuint *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000437{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000438 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, v[0], v[1], v[2], v[3]));
Brian Paul0d4393a2004-02-11 22:53:38 +0000439}
440
441/* GL_FLOAT attributes */
442
Brian Paulb5b8d222004-11-27 20:07:08 +0000443static void GLAPIENTRY VertexAttrib1fvNV(GLuint index, const GLfloat *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000444{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000445 CALL_VertexAttrib1fvNV(GET_DISPATCH(), (index, v));
Brian Paul0d4393a2004-02-11 22:53:38 +0000446}
447
Brian Paulb5b8d222004-11-27 20:07:08 +0000448static void GLAPIENTRY VertexAttrib2fvNV(GLuint index, const GLfloat *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000449{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000450 CALL_VertexAttrib2fvNV(GET_DISPATCH(), (index, v));
Brian Paul0d4393a2004-02-11 22:53:38 +0000451}
452
Brian Paulb5b8d222004-11-27 20:07:08 +0000453static void GLAPIENTRY VertexAttrib3fvNV(GLuint index, const GLfloat *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000454{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000455 CALL_VertexAttrib3fvNV(GET_DISPATCH(), (index, v));
Brian Paul0d4393a2004-02-11 22:53:38 +0000456}
457
Brian Paulb5b8d222004-11-27 20:07:08 +0000458static void GLAPIENTRY VertexAttrib4fvNV(GLuint index, const GLfloat *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000459{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000460 CALL_VertexAttrib4fvNV(GET_DISPATCH(), (index, v));
Brian Paul0d4393a2004-02-11 22:53:38 +0000461}
462
463/* GL_DOUBLE attributes */
464
Brian Paulb5b8d222004-11-27 20:07:08 +0000465static void GLAPIENTRY VertexAttrib1dvNV(GLuint index, const GLdouble *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000466{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000467 CALL_VertexAttrib1dvNV(GET_DISPATCH(), (index, v));
Brian Paul0d4393a2004-02-11 22:53:38 +0000468}
469
Brian Paulb5b8d222004-11-27 20:07:08 +0000470static void GLAPIENTRY VertexAttrib2dvNV(GLuint index, const GLdouble *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000471{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000472 CALL_VertexAttrib2dvNV(GET_DISPATCH(), (index, v));
Brian Paul0d4393a2004-02-11 22:53:38 +0000473}
474
Brian Paulb5b8d222004-11-27 20:07:08 +0000475static void GLAPIENTRY VertexAttrib3dvNV(GLuint index, const GLdouble *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000476{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000477 CALL_VertexAttrib3dvNV(GET_DISPATCH(), (index, v));
Brian Paul0d4393a2004-02-11 22:53:38 +0000478}
479
Brian Paulb5b8d222004-11-27 20:07:08 +0000480static void GLAPIENTRY VertexAttrib4dvNV(GLuint index, const GLdouble *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000481{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000482 CALL_VertexAttrib4dvNV(GET_DISPATCH(), (index, v));
Brian Paul0d4393a2004-02-11 22:53:38 +0000483}
484
485
486/*
487 * Array [size][type] of VertexAttrib functions
488 */
Brian Paulb5b8d222004-11-27 20:07:08 +0000489static attrib_func AttribFuncsNV[2][4][8] = {
Brian Paul0d4393a2004-02-11 22:53:38 +0000490 {
491 /* non-normalized */
492 {
493 /* size 1 */
Brian Paulb5b8d222004-11-27 20:07:08 +0000494 (attrib_func) VertexAttrib1bvNV,
495 (attrib_func) VertexAttrib1ubvNV,
496 (attrib_func) VertexAttrib1svNV,
497 (attrib_func) VertexAttrib1usvNV,
498 (attrib_func) VertexAttrib1ivNV,
499 (attrib_func) VertexAttrib1uivNV,
500 (attrib_func) VertexAttrib1fvNV,
501 (attrib_func) VertexAttrib1dvNV
Brian Paul0d4393a2004-02-11 22:53:38 +0000502 },
503 {
504 /* size 2 */
Brian Paulb5b8d222004-11-27 20:07:08 +0000505 (attrib_func) VertexAttrib2bvNV,
506 (attrib_func) VertexAttrib2ubvNV,
507 (attrib_func) VertexAttrib2svNV,
508 (attrib_func) VertexAttrib2usvNV,
509 (attrib_func) VertexAttrib2ivNV,
510 (attrib_func) VertexAttrib2uivNV,
511 (attrib_func) VertexAttrib2fvNV,
512 (attrib_func) VertexAttrib2dvNV
Brian Paul0d4393a2004-02-11 22:53:38 +0000513 },
514 {
515 /* size 3 */
Brian Paulb5b8d222004-11-27 20:07:08 +0000516 (attrib_func) VertexAttrib3bvNV,
517 (attrib_func) VertexAttrib3ubvNV,
518 (attrib_func) VertexAttrib3svNV,
519 (attrib_func) VertexAttrib3usvNV,
520 (attrib_func) VertexAttrib3ivNV,
521 (attrib_func) VertexAttrib3uivNV,
522 (attrib_func) VertexAttrib3fvNV,
523 (attrib_func) VertexAttrib3dvNV
Brian Paul0d4393a2004-02-11 22:53:38 +0000524 },
525 {
526 /* size 4 */
Brian Paulb5b8d222004-11-27 20:07:08 +0000527 (attrib_func) VertexAttrib4bvNV,
528 (attrib_func) VertexAttrib4ubvNV,
529 (attrib_func) VertexAttrib4svNV,
530 (attrib_func) VertexAttrib4usvNV,
531 (attrib_func) VertexAttrib4ivNV,
532 (attrib_func) VertexAttrib4uivNV,
533 (attrib_func) VertexAttrib4fvNV,
534 (attrib_func) VertexAttrib4dvNV
Brian Paul0d4393a2004-02-11 22:53:38 +0000535 }
536 },
537 {
538 /* normalized (except for float/double) */
539 {
540 /* size 1 */
Brian Paulb5b8d222004-11-27 20:07:08 +0000541 (attrib_func) VertexAttrib1NbvNV,
542 (attrib_func) VertexAttrib1NubvNV,
543 (attrib_func) VertexAttrib1NsvNV,
544 (attrib_func) VertexAttrib1NusvNV,
545 (attrib_func) VertexAttrib1NivNV,
546 (attrib_func) VertexAttrib1NuivNV,
547 (attrib_func) VertexAttrib1fvNV,
548 (attrib_func) VertexAttrib1dvNV
Brian Paul0d4393a2004-02-11 22:53:38 +0000549 },
550 {
551 /* size 2 */
Brian Paulb5b8d222004-11-27 20:07:08 +0000552 (attrib_func) VertexAttrib2NbvNV,
553 (attrib_func) VertexAttrib2NubvNV,
554 (attrib_func) VertexAttrib2NsvNV,
555 (attrib_func) VertexAttrib2NusvNV,
556 (attrib_func) VertexAttrib2NivNV,
557 (attrib_func) VertexAttrib2NuivNV,
558 (attrib_func) VertexAttrib2fvNV,
559 (attrib_func) VertexAttrib2dvNV
Brian Paul0d4393a2004-02-11 22:53:38 +0000560 },
561 {
562 /* size 3 */
Brian Paulb5b8d222004-11-27 20:07:08 +0000563 (attrib_func) VertexAttrib3NbvNV,
564 (attrib_func) VertexAttrib3NubvNV,
565 (attrib_func) VertexAttrib3NsvNV,
566 (attrib_func) VertexAttrib3NusvNV,
567 (attrib_func) VertexAttrib3NivNV,
568 (attrib_func) VertexAttrib3NuivNV,
569 (attrib_func) VertexAttrib3fvNV,
570 (attrib_func) VertexAttrib3dvNV
Brian Paul0d4393a2004-02-11 22:53:38 +0000571 },
572 {
573 /* size 4 */
Brian Paulb5b8d222004-11-27 20:07:08 +0000574 (attrib_func) VertexAttrib4NbvNV,
575 (attrib_func) VertexAttrib4NubvNV,
576 (attrib_func) VertexAttrib4NsvNV,
577 (attrib_func) VertexAttrib4NusvNV,
578 (attrib_func) VertexAttrib4NivNV,
579 (attrib_func) VertexAttrib4NuivNV,
580 (attrib_func) VertexAttrib4fvNV,
581 (attrib_func) VertexAttrib4dvNV
Brian Paul0d4393a2004-02-11 22:53:38 +0000582 }
583 }
584};
585
Brian Paul095c6692006-04-25 00:21:32 +0000586
587/**
588 ** GL_ARB_vertex_program
589 **/
590
591/* GL_BYTE attributes */
592
593static void GLAPIENTRY VertexAttrib1NbvARB(GLuint index, const GLbyte *v)
594{
595 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, BYTE_TO_FLOAT(v[0])));
596}
597
598static void GLAPIENTRY VertexAttrib1bvARB(GLuint index, const GLbyte *v)
599{
600 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, v[0]));
601}
602
603static void GLAPIENTRY VertexAttrib2NbvARB(GLuint index, const GLbyte *v)
604{
605 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index, BYTE_TO_FLOAT(v[0]), BYTE_TO_FLOAT(v[1])));
606}
607
608static void GLAPIENTRY VertexAttrib2bvARB(GLuint index, const GLbyte *v)
609{
610 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index, v[0], v[1]));
611}
612
613static void GLAPIENTRY VertexAttrib3NbvARB(GLuint index, const GLbyte *v)
614{
615 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index, BYTE_TO_FLOAT(v[0]),
616 BYTE_TO_FLOAT(v[1]),
617 BYTE_TO_FLOAT(v[2])));
618}
619
620static void GLAPIENTRY VertexAttrib3bvARB(GLuint index, const GLbyte *v)
621{
622 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index, v[0], v[1], v[2]));
623}
624
625static void GLAPIENTRY VertexAttrib4NbvARB(GLuint index, const GLbyte *v)
626{
627 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index, BYTE_TO_FLOAT(v[0]),
628 BYTE_TO_FLOAT(v[1]),
629 BYTE_TO_FLOAT(v[2]),
630 BYTE_TO_FLOAT(v[3])));
631}
632
633static void GLAPIENTRY VertexAttrib4bvARB(GLuint index, const GLbyte *v)
634{
635 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index, v[0], v[1], v[2], v[3]));
636}
637
638/* GL_UNSIGNED_BYTE attributes */
639
640static void GLAPIENTRY VertexAttrib1NubvARB(GLuint index, const GLubyte *v)
641{
642 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, UBYTE_TO_FLOAT(v[0])));
643}
644
645static void GLAPIENTRY VertexAttrib1ubvARB(GLuint index, const GLubyte *v)
646{
647 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, v[0]));
648}
649
650static void GLAPIENTRY VertexAttrib2NubvARB(GLuint index, const GLubyte *v)
651{
652 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index, UBYTE_TO_FLOAT(v[0]),
653 UBYTE_TO_FLOAT(v[1])));
654}
655
656static void GLAPIENTRY VertexAttrib2ubvARB(GLuint index, const GLubyte *v)
657{
658 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index, v[0], v[1]));
659}
660
661static void GLAPIENTRY VertexAttrib3NubvARB(GLuint index, const GLubyte *v)
662{
663 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index, UBYTE_TO_FLOAT(v[0]),
664 UBYTE_TO_FLOAT(v[1]),
665 UBYTE_TO_FLOAT(v[2])));
666}
667static void GLAPIENTRY VertexAttrib3ubvARB(GLuint index, const GLubyte *v)
668{
669 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index, v[0], v[1], v[2]));
670}
671
672static void GLAPIENTRY VertexAttrib4NubvARB(GLuint index, const GLubyte *v)
673{
674 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index, UBYTE_TO_FLOAT(v[0]),
675 UBYTE_TO_FLOAT(v[1]),
676 UBYTE_TO_FLOAT(v[2]),
677 UBYTE_TO_FLOAT(v[3])));
678}
679
680static void GLAPIENTRY VertexAttrib4ubvARB(GLuint index, const GLubyte *v)
681{
682 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index, v[0], v[1], v[2], v[3]));
683}
684
685/* GL_SHORT attributes */
686
687static void GLAPIENTRY VertexAttrib1NsvARB(GLuint index, const GLshort *v)
688{
689 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, SHORT_TO_FLOAT(v[0])));
690}
691
692static void GLAPIENTRY VertexAttrib1svARB(GLuint index, const GLshort *v)
693{
694 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, v[0]));
695}
696
697static void GLAPIENTRY VertexAttrib2NsvARB(GLuint index, const GLshort *v)
698{
699 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index, SHORT_TO_FLOAT(v[0]),
700 SHORT_TO_FLOAT(v[1])));
701}
702
703static void GLAPIENTRY VertexAttrib2svARB(GLuint index, const GLshort *v)
704{
705 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index, v[0], v[1]));
706}
707
708static void GLAPIENTRY VertexAttrib3NsvARB(GLuint index, const GLshort *v)
709{
710 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index, SHORT_TO_FLOAT(v[0]),
711 SHORT_TO_FLOAT(v[1]),
712 SHORT_TO_FLOAT(v[2])));
713}
714
715static void GLAPIENTRY VertexAttrib3svARB(GLuint index, const GLshort *v)
716{
717 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index, v[0], v[1], v[2]));
718}
719
720static void GLAPIENTRY VertexAttrib4NsvARB(GLuint index, const GLshort *v)
721{
722 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index, SHORT_TO_FLOAT(v[0]),
723 SHORT_TO_FLOAT(v[1]),
724 SHORT_TO_FLOAT(v[2]),
725 SHORT_TO_FLOAT(v[3])));
726}
727
728static void GLAPIENTRY VertexAttrib4svARB(GLuint index, const GLshort *v)
729{
730 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index, v[0], v[1], v[2], v[3]));
731}
732
733/* GL_UNSIGNED_SHORT attributes */
734
735static void GLAPIENTRY VertexAttrib1NusvARB(GLuint index, const GLushort *v)
736{
737 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, USHORT_TO_FLOAT(v[0])));
738}
739
740static void GLAPIENTRY VertexAttrib1usvARB(GLuint index, const GLushort *v)
741{
742 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, v[0]));
743}
744
745static void GLAPIENTRY VertexAttrib2NusvARB(GLuint index, const GLushort *v)
746{
747 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index, USHORT_TO_FLOAT(v[0]),
748 USHORT_TO_FLOAT(v[1])));
749}
750
751static void GLAPIENTRY VertexAttrib2usvARB(GLuint index, const GLushort *v)
752{
753 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index, v[0], v[1]));
754}
755
756static void GLAPIENTRY VertexAttrib3NusvARB(GLuint index, const GLushort *v)
757{
758 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index, USHORT_TO_FLOAT(v[0]),
759 USHORT_TO_FLOAT(v[1]),
760 USHORT_TO_FLOAT(v[2])));
761}
762
763static void GLAPIENTRY VertexAttrib3usvARB(GLuint index, const GLushort *v)
764{
765 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index, v[0], v[1], v[2]));
766}
767
768static void GLAPIENTRY VertexAttrib4NusvARB(GLuint index, const GLushort *v)
769{
770 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index, USHORT_TO_FLOAT(v[0]),
771 USHORT_TO_FLOAT(v[1]),
772 USHORT_TO_FLOAT(v[2]),
773 USHORT_TO_FLOAT(v[3])));
774}
775
776static void GLAPIENTRY VertexAttrib4usvARB(GLuint index, const GLushort *v)
777{
778 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index, v[0], v[1], v[2], v[3]));
779}
780
781/* GL_INT attributes */
782
783static void GLAPIENTRY VertexAttrib1NivARB(GLuint index, const GLint *v)
784{
785 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, INT_TO_FLOAT(v[0])));
786}
787
788static void GLAPIENTRY VertexAttrib1ivARB(GLuint index, const GLint *v)
789{
790 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, v[0]));
791}
792
793static void GLAPIENTRY VertexAttrib2NivARB(GLuint index, const GLint *v)
794{
795 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index, INT_TO_FLOAT(v[0]),
796 INT_TO_FLOAT(v[1])));
797}
798
799static void GLAPIENTRY VertexAttrib2ivARB(GLuint index, const GLint *v)
800{
801 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index, v[0], v[1]));
802}
803
804static void GLAPIENTRY VertexAttrib3NivARB(GLuint index, const GLint *v)
805{
806 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index, INT_TO_FLOAT(v[0]),
807 INT_TO_FLOAT(v[1]),
808 INT_TO_FLOAT(v[2])));
809}
810
811static void GLAPIENTRY VertexAttrib3ivARB(GLuint index, const GLint *v)
812{
813 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index, v[0], v[1], v[2]));
814}
815
816static void GLAPIENTRY VertexAttrib4NivARB(GLuint index, const GLint *v)
817{
818 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index, INT_TO_FLOAT(v[0]),
819 INT_TO_FLOAT(v[1]),
820 INT_TO_FLOAT(v[2]),
821 INT_TO_FLOAT(v[3])));
822}
823
824static void GLAPIENTRY VertexAttrib4ivARB(GLuint index, const GLint *v)
825{
826 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index, v[0], v[1], v[2], v[3]));
827}
828
829/* GL_UNSIGNED_INT attributes */
830
831static void GLAPIENTRY VertexAttrib1NuivARB(GLuint index, const GLuint *v)
832{
833 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, UINT_TO_FLOAT(v[0])));
834}
835
836static void GLAPIENTRY VertexAttrib1uivARB(GLuint index, const GLuint *v)
837{
838 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, v[0]));
839}
840
841static void GLAPIENTRY VertexAttrib2NuivARB(GLuint index, const GLuint *v)
842{
843 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index, UINT_TO_FLOAT(v[0]),
844 UINT_TO_FLOAT(v[1])));
845}
846
847static void GLAPIENTRY VertexAttrib2uivARB(GLuint index, const GLuint *v)
848{
849 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index, v[0], v[1]));
850}
851
852static void GLAPIENTRY VertexAttrib3NuivARB(GLuint index, const GLuint *v)
853{
854 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index, UINT_TO_FLOAT(v[0]),
855 UINT_TO_FLOAT(v[1]),
856 UINT_TO_FLOAT(v[2])));
857}
858
859static void GLAPIENTRY VertexAttrib3uivARB(GLuint index, const GLuint *v)
860{
861 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index, v[0], v[1], v[2]));
862}
863
864static void GLAPIENTRY VertexAttrib4NuivARB(GLuint index, const GLuint *v)
865{
866 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index, UINT_TO_FLOAT(v[0]),
867 UINT_TO_FLOAT(v[1]),
868 UINT_TO_FLOAT(v[2]),
869 UINT_TO_FLOAT(v[3])));
870}
871
872static void GLAPIENTRY VertexAttrib4uivARB(GLuint index, const GLuint *v)
873{
874 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index, v[0], v[1], v[2], v[3]));
875}
876
877/* GL_FLOAT attributes */
878
879static void GLAPIENTRY VertexAttrib1fvARB(GLuint index, const GLfloat *v)
880{
881 CALL_VertexAttrib1fvARB(GET_DISPATCH(), (index, v));
882}
883
884static void GLAPIENTRY VertexAttrib2fvARB(GLuint index, const GLfloat *v)
885{
886 CALL_VertexAttrib2fvARB(GET_DISPATCH(), (index, v));
887}
888
889static void GLAPIENTRY VertexAttrib3fvARB(GLuint index, const GLfloat *v)
890{
891 CALL_VertexAttrib3fvARB(GET_DISPATCH(), (index, v));
892}
893
894static void GLAPIENTRY VertexAttrib4fvARB(GLuint index, const GLfloat *v)
895{
896 CALL_VertexAttrib4fvARB(GET_DISPATCH(), (index, v));
897}
898
899/* GL_DOUBLE attributes */
900
901static void GLAPIENTRY VertexAttrib1dvARB(GLuint index, const GLdouble *v)
902{
903 CALL_VertexAttrib1dvARB(GET_DISPATCH(), (index, v));
904}
905
906static void GLAPIENTRY VertexAttrib2dvARB(GLuint index, const GLdouble *v)
907{
908 CALL_VertexAttrib2dvARB(GET_DISPATCH(), (index, v));
909}
910
911static void GLAPIENTRY VertexAttrib3dvARB(GLuint index, const GLdouble *v)
912{
913 CALL_VertexAttrib3dvARB(GET_DISPATCH(), (index, v));
914}
915
916static void GLAPIENTRY VertexAttrib4dvARB(GLuint index, const GLdouble *v)
917{
918 CALL_VertexAttrib4dvARB(GET_DISPATCH(), (index, v));
919}
920
921
922/*
923 * Array [size][type] of VertexAttrib functions
924 */
925static attrib_func AttribFuncsARB[2][4][8] = {
926 {
927 /* non-normalized */
928 {
929 /* size 1 */
930 (attrib_func) VertexAttrib1bvARB,
931 (attrib_func) VertexAttrib1ubvARB,
932 (attrib_func) VertexAttrib1svARB,
933 (attrib_func) VertexAttrib1usvARB,
934 (attrib_func) VertexAttrib1ivARB,
935 (attrib_func) VertexAttrib1uivARB,
936 (attrib_func) VertexAttrib1fvARB,
937 (attrib_func) VertexAttrib1dvARB
938 },
939 {
940 /* size 2 */
941 (attrib_func) VertexAttrib2bvARB,
942 (attrib_func) VertexAttrib2ubvARB,
943 (attrib_func) VertexAttrib2svARB,
944 (attrib_func) VertexAttrib2usvARB,
945 (attrib_func) VertexAttrib2ivARB,
946 (attrib_func) VertexAttrib2uivARB,
947 (attrib_func) VertexAttrib2fvARB,
948 (attrib_func) VertexAttrib2dvARB
949 },
950 {
951 /* size 3 */
952 (attrib_func) VertexAttrib3bvARB,
953 (attrib_func) VertexAttrib3ubvARB,
954 (attrib_func) VertexAttrib3svARB,
955 (attrib_func) VertexAttrib3usvARB,
956 (attrib_func) VertexAttrib3ivARB,
957 (attrib_func) VertexAttrib3uivARB,
958 (attrib_func) VertexAttrib3fvARB,
959 (attrib_func) VertexAttrib3dvARB
960 },
961 {
962 /* size 4 */
963 (attrib_func) VertexAttrib4bvARB,
964 (attrib_func) VertexAttrib4ubvARB,
965 (attrib_func) VertexAttrib4svARB,
966 (attrib_func) VertexAttrib4usvARB,
967 (attrib_func) VertexAttrib4ivARB,
968 (attrib_func) VertexAttrib4uivARB,
969 (attrib_func) VertexAttrib4fvARB,
970 (attrib_func) VertexAttrib4dvARB
971 }
972 },
973 {
974 /* normalized (except for float/double) */
975 {
976 /* size 1 */
977 (attrib_func) VertexAttrib1NbvARB,
978 (attrib_func) VertexAttrib1NubvARB,
979 (attrib_func) VertexAttrib1NsvARB,
980 (attrib_func) VertexAttrib1NusvARB,
981 (attrib_func) VertexAttrib1NivARB,
982 (attrib_func) VertexAttrib1NuivARB,
983 (attrib_func) VertexAttrib1fvARB,
984 (attrib_func) VertexAttrib1dvARB
985 },
986 {
987 /* size 2 */
988 (attrib_func) VertexAttrib2NbvARB,
989 (attrib_func) VertexAttrib2NubvARB,
990 (attrib_func) VertexAttrib2NsvARB,
991 (attrib_func) VertexAttrib2NusvARB,
992 (attrib_func) VertexAttrib2NivARB,
993 (attrib_func) VertexAttrib2NuivARB,
994 (attrib_func) VertexAttrib2fvARB,
995 (attrib_func) VertexAttrib2dvARB
996 },
997 {
998 /* size 3 */
999 (attrib_func) VertexAttrib3NbvARB,
1000 (attrib_func) VertexAttrib3NubvARB,
1001 (attrib_func) VertexAttrib3NsvARB,
1002 (attrib_func) VertexAttrib3NusvARB,
1003 (attrib_func) VertexAttrib3NivARB,
1004 (attrib_func) VertexAttrib3NuivARB,
1005 (attrib_func) VertexAttrib3fvARB,
1006 (attrib_func) VertexAttrib3dvARB
1007 },
1008 {
1009 /* size 4 */
1010 (attrib_func) VertexAttrib4NbvARB,
1011 (attrib_func) VertexAttrib4NubvARB,
1012 (attrib_func) VertexAttrib4NsvARB,
1013 (attrib_func) VertexAttrib4NusvARB,
1014 (attrib_func) VertexAttrib4NivARB,
1015 (attrib_func) VertexAttrib4NuivARB,
1016 (attrib_func) VertexAttrib4fvARB,
1017 (attrib_func) VertexAttrib4dvARB
1018 }
1019 }
1020};
1021
Brian Paul0d4393a2004-02-11 22:53:38 +00001022/**********************************************************************/
1023
Keith Whitwell4b7d6f22001-06-01 22:22:10 +00001024
1025GLboolean _ae_create_context( GLcontext *ctx )
Keith Whitwellcab974c2000-12-26 05:09:27 +00001026{
Keith Whitwellae0eaf92003-11-24 15:23:18 +00001027 if (ctx->aelt_context)
1028 return GL_TRUE;
1029
Brian Paul0f1d98c2006-03-17 04:10:03 +00001030 /* These _gloffset_* values may not be compile-time constants */
Ian Romanick126c89e2005-08-05 18:13:37 +00001031 SecondaryColorFuncs[0] = _gloffset_SecondaryColor3bvEXT;
1032 SecondaryColorFuncs[1] = _gloffset_SecondaryColor3ubvEXT;
1033 SecondaryColorFuncs[2] = _gloffset_SecondaryColor3svEXT;
1034 SecondaryColorFuncs[3] = _gloffset_SecondaryColor3usvEXT;
1035 SecondaryColorFuncs[4] = _gloffset_SecondaryColor3ivEXT;
1036 SecondaryColorFuncs[5] = _gloffset_SecondaryColor3uivEXT;
1037 SecondaryColorFuncs[6] = _gloffset_SecondaryColor3fvEXT;
1038 SecondaryColorFuncs[7] = _gloffset_SecondaryColor3dvEXT;
1039
Brian Pauleec33cc2006-03-17 04:13:29 +00001040 FogCoordFuncs[0] = -1;
1041 FogCoordFuncs[1] = -1;
1042 FogCoordFuncs[2] = -1;
1043 FogCoordFuncs[3] = -1;
1044 FogCoordFuncs[4] = -1;
1045 FogCoordFuncs[5] = -1;
Ian Romanick126c89e2005-08-05 18:13:37 +00001046 FogCoordFuncs[6] = _gloffset_FogCoordfvEXT;
1047 FogCoordFuncs[7] = _gloffset_FogCoorddvEXT;
Ian Romanick126c89e2005-08-05 18:13:37 +00001048
Keith Whitwell4b7d6f22001-06-01 22:22:10 +00001049 ctx->aelt_context = MALLOC( sizeof(AEcontext) );
Gareth Hughes1fb0a432001-12-28 06:28:10 +00001050 if (!ctx->aelt_context)
Keith Whitwell4b7d6f22001-06-01 22:22:10 +00001051 return GL_FALSE;
1052
1053 AE_CONTEXT(ctx)->NewState = ~0;
1054 return GL_TRUE;
Keith Whitwellcab974c2000-12-26 05:09:27 +00001055}
1056
Keith Whitwell4b7d6f22001-06-01 22:22:10 +00001057
1058void _ae_destroy_context( GLcontext *ctx )
Keith Whitwellcab974c2000-12-26 05:09:27 +00001059{
Keith Whitwell4b7d6f22001-06-01 22:22:10 +00001060 if ( AE_CONTEXT( ctx ) ) {
1061 FREE( ctx->aelt_context );
Keith Whitwella0c85242005-02-11 09:34:05 +00001062 ctx->aelt_context = NULL;
Keith Whitwell4b7d6f22001-06-01 22:22:10 +00001063 }
1064}
1065
1066
Brian Paul0d4393a2004-02-11 22:53:38 +00001067/**
1068 * Make a list of per-vertex functions to call for each glArrayElement call.
Brian Paul1e3d8682004-02-24 02:49:43 +00001069 * These functions access the array data (i.e. glVertex, glColor, glNormal,
1070 * etc).
1071 * Note: this may be called during display list construction.
Brian Paul0d4393a2004-02-11 22:53:38 +00001072 */
Keith Whitwell4b7d6f22001-06-01 22:22:10 +00001073static void _ae_update_state( GLcontext *ctx )
1074{
1075 AEcontext *actx = AE_CONTEXT(ctx);
Keith Whitwell4b7d6f22001-06-01 22:22:10 +00001076 AEarray *aa = actx->arrays;
Brian Paul0d4393a2004-02-11 22:53:38 +00001077 AEattrib *at = actx->attribs;
Brian Pauldb07de02002-04-19 00:23:08 +00001078 GLuint i;
Keith Whitwellcab974c2000-12-26 05:09:27 +00001079
Brian Paul1e3d8682004-02-24 02:49:43 +00001080 /* conventional vertex arrays */
1081 if (ctx->Array.Index.Enabled) {
Keith Whitwellcab974c2000-12-26 05:09:27 +00001082 aa->array = &ctx->Array.Index;
Ian Romanick9bdfee32005-07-18 12:31:24 +00001083 aa->offset = IndexFuncs[TYPE_IDX(aa->array->Type)];
Keith Whitwellcab974c2000-12-26 05:09:27 +00001084 aa++;
1085 }
Keith Whitwellcab974c2000-12-26 05:09:27 +00001086 if (ctx->Array.EdgeFlag.Enabled) {
Keith Whitwell4b7d6f22001-06-01 22:22:10 +00001087 aa->array = &ctx->Array.EdgeFlag;
Ian Romanick9bdfee32005-07-18 12:31:24 +00001088 aa->offset = _gloffset_EdgeFlagv;
Keith Whitwellcab974c2000-12-26 05:09:27 +00001089 aa++;
1090 }
Brian Paul1e3d8682004-02-24 02:49:43 +00001091 if (ctx->Array.Normal.Enabled) {
1092 aa->array = &ctx->Array.Normal;
Ian Romanick9bdfee32005-07-18 12:31:24 +00001093 aa->offset = NormalFuncs[TYPE_IDX(aa->array->Type)];
Brian Paul1e3d8682004-02-24 02:49:43 +00001094 aa++;
1095 }
1096 if (ctx->Array.Color.Enabled) {
1097 aa->array = &ctx->Array.Color;
Ian Romanick9bdfee32005-07-18 12:31:24 +00001098 aa->offset = ColorFuncs[aa->array->Size-3][TYPE_IDX(aa->array->Type)];
Brian Paul1e3d8682004-02-24 02:49:43 +00001099 aa++;
1100 }
1101 if (ctx->Array.SecondaryColor.Enabled) {
1102 aa->array = &ctx->Array.SecondaryColor;
Ian Romanick9bdfee32005-07-18 12:31:24 +00001103 aa->offset = SecondaryColorFuncs[TYPE_IDX(aa->array->Type)];
Brian Paul1e3d8682004-02-24 02:49:43 +00001104 aa++;
1105 }
1106 if (ctx->Array.FogCoord.Enabled) {
1107 aa->array = &ctx->Array.FogCoord;
Ian Romanick9bdfee32005-07-18 12:31:24 +00001108 aa->offset = FogCoordFuncs[TYPE_IDX(aa->array->Type)];
Brian Paul1e3d8682004-02-24 02:49:43 +00001109 aa++;
1110 }
1111 for (i = 0; i < ctx->Const.MaxTextureCoordUnits; i++) {
Brian Paul095c6692006-04-25 00:21:32 +00001112 struct gl_client_array *attribArray = &ctx->Array.TexCoord[i];
1113 if (attribArray->Enabled) {
1114 /* NOTE: we use generic glVertexAttribNV functions here.
1115 * If we ever remove GL_NV_vertex_program this will have to change.
Brian Paul1e3d8682004-02-24 02:49:43 +00001116 */
Brian Paul1e3d8682004-02-24 02:49:43 +00001117 at->array = attribArray;
Brian Paul095c6692006-04-25 00:21:32 +00001118 ASSERT(!at->array->Normalized);
1119 at->func = AttribFuncsNV[at->array->Normalized]
1120 [at->array->Size-1]
1121 [TYPE_IDX(at->array->Type)];
Brian Paul9d1ff8c2004-02-24 14:59:26 +00001122 at->index = VERT_ATTRIB_TEX0 + i;
Brian Paul1e3d8682004-02-24 02:49:43 +00001123 at++;
Brian Paul0d4393a2004-02-11 22:53:38 +00001124 }
Brian Paul1e3d8682004-02-24 02:49:43 +00001125 }
Roland Scheideggerfaaf78a2004-02-11 01:06:03 +00001126
Brian Paul1e3d8682004-02-24 02:49:43 +00001127 /* generic vertex attribute arrays */
1128 for (i = 1; i < VERT_ATTRIB_MAX; i++) { /* skip zero! */
Brian Paul095c6692006-04-25 00:21:32 +00001129 struct gl_client_array *attribArray = &ctx->Array.VertexAttrib[i];
1130 if (attribArray->Enabled) {
Brian Paul0d4393a2004-02-11 22:53:38 +00001131 at->array = attribArray;
1132 /* Note: we can't grab the _glapi_Dispatch->VertexAttrib1fvNV
1133 * function pointer here (for float arrays) since the pointer may
1134 * change from one execution of _ae_loopback_array_elt() to
1135 * the next. Doing so caused UT to break.
1136 */
Brian Paul095c6692006-04-25 00:21:32 +00001137 if (ctx->VertexProgram._Enabled
1138 && ctx->VertexProgram.Current->IsNVProgram) {
1139 at->func = AttribFuncsNV[at->array->Normalized]
1140 [at->array->Size-1]
1141 [TYPE_IDX(at->array->Type)];
1142 }
1143 else {
1144 at->func = AttribFuncsARB[at->array->Normalized]
1145 [at->array->Size-1]
1146 [TYPE_IDX(at->array->Type)];
1147 }
Brian Paul1e3d8682004-02-24 02:49:43 +00001148 at->index = i;
Brian Paul0d4393a2004-02-11 22:53:38 +00001149 at++;
1150 }
Roland Scheideggerfaaf78a2004-02-11 01:06:03 +00001151 }
Brian Paul1e3d8682004-02-24 02:49:43 +00001152
1153 /* finally, vertex position */
1154 if (ctx->Array.VertexAttrib[0].Enabled) {
1155 /* Use glVertex(v) instead of glVertexAttrib(0, v) to be sure it's
Brian Paul095c6692006-04-25 00:21:32 +00001156 * issued as the last (provoking) attribute).
Brian Paul1e3d8682004-02-24 02:49:43 +00001157 */
1158 aa->array = &ctx->Array.VertexAttrib[0];
1159 assert(aa->array->Size >= 2); /* XXX fix someday? */
Ian Romanick9bdfee32005-07-18 12:31:24 +00001160 aa->offset = VertexFuncs[aa->array->Size-2][TYPE_IDX(aa->array->Type)];
Brian Paul1e3d8682004-02-24 02:49:43 +00001161 aa++;
1162 }
1163 else if (ctx->Array.Vertex.Enabled) {
1164 aa->array = &ctx->Array.Vertex;
Ian Romanick9bdfee32005-07-18 12:31:24 +00001165 aa->offset = VertexFuncs[aa->array->Size-2][TYPE_IDX(aa->array->Type)];
Brian Paul1e3d8682004-02-24 02:49:43 +00001166 aa++;
1167 }
1168
Brian Paul0d4393a2004-02-11 22:53:38 +00001169 ASSERT(at - actx->attribs <= VERT_ATTRIB_MAX);
1170 ASSERT(aa - actx->arrays < 32);
1171 at->func = NULL; /* terminate the list */
Ian Romanick9bdfee32005-07-18 12:31:24 +00001172 aa->offset = -1; /* terminate the list */
Roland Scheideggerfaaf78a2004-02-11 01:06:03 +00001173
Keith Whitwellcab974c2000-12-26 05:09:27 +00001174 actx->NewState = 0;
1175}
1176
1177
Brian Paul1e3d8682004-02-24 02:49:43 +00001178/**
1179 * Called via glArrayElement() and glDrawArrays().
1180 * Issue the glNormal, glVertex, glColor, glVertexAttrib, etc functions
1181 * for all enabled vertex arrays (for elt-th element).
1182 * Note: this may be called during display list construction.
1183 */
Karl Schultzd6745692003-12-04 20:23:44 +00001184void GLAPIENTRY _ae_loopback_array_elt( GLint elt )
Keith Whitwellcab974c2000-12-26 05:09:27 +00001185{
1186 GET_CURRENT_CONTEXT(ctx);
Brian Paul0d4393a2004-02-11 22:53:38 +00001187 const AEcontext *actx = AE_CONTEXT(ctx);
1188 const AEarray *aa;
1189 const AEattrib *at;
Ian Romanick9bdfee32005-07-18 12:31:24 +00001190 const struct _glapi_table * const disp = GET_DISPATCH();
1191
Keith Whitwell4b7d6f22001-06-01 22:22:10 +00001192
1193 if (actx->NewState)
1194 _ae_update_state( ctx );
Keith Whitwellcab974c2000-12-26 05:09:27 +00001195
Brian Paul0d4393a2004-02-11 22:53:38 +00001196 /* generic attributes */
1197 for (at = actx->attribs; at->func; at++) {
Brian Paul024b5892005-11-25 17:07:10 +00001198 const GLubyte *src
1199 = ADD_POINTERS(at->array->BufferObj->Data, at->array->Ptr)
1200 + elt * at->array->StrideB;
Brian Paul0d4393a2004-02-11 22:53:38 +00001201 at->func( at->index, src );
Brian Paul53ad0362004-02-09 00:24:48 +00001202 }
1203
Brian Paul0d4393a2004-02-11 22:53:38 +00001204 /* conventional arrays */
Ian Romanick9bdfee32005-07-18 12:31:24 +00001205 for (aa = actx->arrays; aa->offset != -1 ; aa++) {
Brian Paul024b5892005-11-25 17:07:10 +00001206 const GLubyte *src
1207 = ADD_POINTERS(aa->array->BufferObj->Data, aa->array->Ptr)
1208 + elt * aa->array->StrideB;
Ian Romanick9bdfee32005-07-18 12:31:24 +00001209 CALL_by_offset( disp, (array_func), aa->offset,
1210 ((const void *) src) );
Keith Whitwellcab974c2000-12-26 05:09:27 +00001211 }
Keith Whitwellcab974c2000-12-26 05:09:27 +00001212}
1213
1214
Keith Whitwell4b7d6f22001-06-01 22:22:10 +00001215void _ae_invalidate_state( GLcontext *ctx, GLuint new_state )
Keith Whitwellcab974c2000-12-26 05:09:27 +00001216{
Keith Whitwell4b7d6f22001-06-01 22:22:10 +00001217 AE_CONTEXT(ctx)->NewState |= new_state;
Keith Whitwellcab974c2000-12-26 05:09:27 +00001218}