Brian Paul | 05a4b37 | 2002-10-29 20:28:36 +0000 | [diff] [blame^] | 1 | /* $Id: api_arrayelt.c,v 1.11 2002/10/29 20:28:36 brianp Exp $ */ |
Gareth Hughes | 22144ab | 2001-03-12 00:48:37 +0000 | [diff] [blame] | 2 | |
| 3 | /* |
| 4 | * Mesa 3-D graphics library |
Brian Paul | 03c0c2e | 2002-01-14 16:06:35 +0000 | [diff] [blame] | 5 | * Version: 4.1 |
Gareth Hughes | 22144ab | 2001-03-12 00:48:37 +0000 | [diff] [blame] | 6 | * |
Brian Paul | 03c0c2e | 2002-01-14 16:06:35 +0000 | [diff] [blame] | 7 | * Copyright (C) 1999-2002 Brian Paul All Rights Reserved. |
Gareth Hughes | 22144ab | 2001-03-12 00:48:37 +0000 | [diff] [blame] | 8 | * |
| 9 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 10 | * copy of this software and associated documentation files (the "Software"), |
| 11 | * to deal in the Software without restriction, including without limitation |
| 12 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 13 | * and/or sell copies of the Software, and to permit persons to whom the |
| 14 | * Software is furnished to do so, subject to the following conditions: |
| 15 | * |
| 16 | * The above copyright notice and this permission notice shall be included |
| 17 | * in all copies or substantial portions of the Software. |
| 18 | * |
| 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
| 20 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 22 | * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN |
| 23 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
| 24 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 25 | */ |
| 26 | |
Keith Whitwell | fc00cbe | 2001-12-20 15:30:45 +0000 | [diff] [blame] | 27 | /* Author: |
Brian Paul | 05a4b37 | 2002-10-29 20:28:36 +0000 | [diff] [blame^] | 28 | * Keith Whitwell <keith@tungstengraphics.com> |
Keith Whitwell | fc00cbe | 2001-12-20 15:30:45 +0000 | [diff] [blame] | 29 | */ |
| 30 | |
Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 31 | #include "glheader.h" |
Keith Whitwell | 4b7d6f2 | 2001-06-01 22:22:10 +0000 | [diff] [blame] | 32 | #include "api_arrayelt.h" |
Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 33 | #include "context.h" |
Keith Whitwell | fc00cbe | 2001-12-20 15:30:45 +0000 | [diff] [blame] | 34 | #include "glapi.h" |
Brian Paul | 3c63452 | 2002-10-24 23:57:19 +0000 | [diff] [blame] | 35 | #include "imports.h" |
Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 36 | #include "macros.h" |
Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 37 | #include "mtypes.h" |
| 38 | |
| 39 | |
Gareth Hughes | 1fb0a43 | 2001-12-28 06:28:10 +0000 | [diff] [blame] | 40 | typedef void (*texarray_func)( GLenum, const void * ); |
| 41 | |
Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 42 | typedef struct { |
| 43 | GLint unit; |
| 44 | struct gl_client_array *array; |
Gareth Hughes | 1fb0a43 | 2001-12-28 06:28:10 +0000 | [diff] [blame] | 45 | texarray_func func; |
Keith Whitwell | 4b7d6f2 | 2001-06-01 22:22:10 +0000 | [diff] [blame] | 46 | } AEtexarray; |
Gareth Hughes | 22144ab | 2001-03-12 00:48:37 +0000 | [diff] [blame] | 47 | |
Gareth Hughes | 1fb0a43 | 2001-12-28 06:28:10 +0000 | [diff] [blame] | 48 | typedef void (*array_func)( const void * ); |
Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 49 | |
| 50 | typedef struct { |
| 51 | struct gl_client_array *array; |
Gareth Hughes | 1fb0a43 | 2001-12-28 06:28:10 +0000 | [diff] [blame] | 52 | array_func func; |
Keith Whitwell | 4b7d6f2 | 2001-06-01 22:22:10 +0000 | [diff] [blame] | 53 | } AEarray; |
Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 54 | |
| 55 | typedef struct { |
Keith Whitwell | 4b7d6f2 | 2001-06-01 22:22:10 +0000 | [diff] [blame] | 56 | AEtexarray texarrays[MAX_TEXTURE_UNITS+1]; |
| 57 | AEarray arrays[32]; |
Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 58 | GLuint NewState; |
Keith Whitwell | 4b7d6f2 | 2001-06-01 22:22:10 +0000 | [diff] [blame] | 59 | } AEcontext; |
Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 60 | |
Keith Whitwell | 4b7d6f2 | 2001-06-01 22:22:10 +0000 | [diff] [blame] | 61 | #define AE_CONTEXT(ctx) ((AEcontext *)(ctx)->aelt_context) |
| 62 | #define TYPE_IDX(t) ((t) & 0xf) |
Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 63 | |
Keith Whitwell | 4b7d6f2 | 2001-06-01 22:22:10 +0000 | [diff] [blame] | 64 | static void (*colorfuncs[2][8])( const void * ) = { |
Gareth Hughes | 1fb0a43 | 2001-12-28 06:28:10 +0000 | [diff] [blame] | 65 | { (array_func)glColor3bv, |
Keith Whitwell | 306d3fc | 2002-04-09 16:56:50 +0000 | [diff] [blame] | 66 | (array_func)glColor3ubv, |
Gareth Hughes | 1fb0a43 | 2001-12-28 06:28:10 +0000 | [diff] [blame] | 67 | (array_func)glColor3sv, |
| 68 | (array_func)glColor3usv, |
| 69 | (array_func)glColor3iv, |
| 70 | (array_func)glColor3uiv, |
| 71 | (array_func)glColor3fv, |
| 72 | (array_func)glColor3dv }, |
Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 73 | |
Gareth Hughes | 1fb0a43 | 2001-12-28 06:28:10 +0000 | [diff] [blame] | 74 | { (array_func)glColor4bv, |
Keith Whitwell | 306d3fc | 2002-04-09 16:56:50 +0000 | [diff] [blame] | 75 | (array_func)glColor4ubv, |
Gareth Hughes | 1fb0a43 | 2001-12-28 06:28:10 +0000 | [diff] [blame] | 76 | (array_func)glColor4sv, |
| 77 | (array_func)glColor4usv, |
| 78 | (array_func)glColor4iv, |
| 79 | (array_func)glColor4uiv, |
| 80 | (array_func)glColor4fv, |
| 81 | (array_func)glColor4dv } |
Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 82 | }; |
| 83 | |
Keith Whitwell | 4b7d6f2 | 2001-06-01 22:22:10 +0000 | [diff] [blame] | 84 | static void (*vertexfuncs[3][8])( const void * ) = { |
| 85 | { 0, |
| 86 | 0, |
Gareth Hughes | 1fb0a43 | 2001-12-28 06:28:10 +0000 | [diff] [blame] | 87 | (array_func)glVertex2sv, |
Keith Whitwell | 4b7d6f2 | 2001-06-01 22:22:10 +0000 | [diff] [blame] | 88 | 0, |
Gareth Hughes | 1fb0a43 | 2001-12-28 06:28:10 +0000 | [diff] [blame] | 89 | (array_func)glVertex2iv, |
Keith Whitwell | 4b7d6f2 | 2001-06-01 22:22:10 +0000 | [diff] [blame] | 90 | 0, |
Gareth Hughes | 1fb0a43 | 2001-12-28 06:28:10 +0000 | [diff] [blame] | 91 | (array_func)glVertex2fv, |
| 92 | (array_func)glVertex2dv }, |
Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 93 | |
Keith Whitwell | 4b7d6f2 | 2001-06-01 22:22:10 +0000 | [diff] [blame] | 94 | { 0, |
| 95 | 0, |
Gareth Hughes | 1fb0a43 | 2001-12-28 06:28:10 +0000 | [diff] [blame] | 96 | (array_func)glVertex3sv, |
Keith Whitwell | 4b7d6f2 | 2001-06-01 22:22:10 +0000 | [diff] [blame] | 97 | 0, |
Gareth Hughes | 1fb0a43 | 2001-12-28 06:28:10 +0000 | [diff] [blame] | 98 | (array_func)glVertex3iv, |
Keith Whitwell | 4b7d6f2 | 2001-06-01 22:22:10 +0000 | [diff] [blame] | 99 | 0, |
Gareth Hughes | 1fb0a43 | 2001-12-28 06:28:10 +0000 | [diff] [blame] | 100 | (array_func)glVertex3fv, |
| 101 | (array_func)glVertex3dv }, |
Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 102 | |
Keith Whitwell | 4b7d6f2 | 2001-06-01 22:22:10 +0000 | [diff] [blame] | 103 | { 0, |
| 104 | 0, |
Gareth Hughes | 1fb0a43 | 2001-12-28 06:28:10 +0000 | [diff] [blame] | 105 | (array_func)glVertex4sv, |
Keith Whitwell | 4b7d6f2 | 2001-06-01 22:22:10 +0000 | [diff] [blame] | 106 | 0, |
Gareth Hughes | 1fb0a43 | 2001-12-28 06:28:10 +0000 | [diff] [blame] | 107 | (array_func)glVertex4iv, |
Keith Whitwell | 4b7d6f2 | 2001-06-01 22:22:10 +0000 | [diff] [blame] | 108 | 0, |
Gareth Hughes | 1fb0a43 | 2001-12-28 06:28:10 +0000 | [diff] [blame] | 109 | (array_func)glVertex4fv, |
| 110 | (array_func)glVertex4dv } |
Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 111 | }; |
| 112 | |
| 113 | |
Keith Whitwell | 4b7d6f2 | 2001-06-01 22:22:10 +0000 | [diff] [blame] | 114 | static void (*multitexfuncs[4][8])( GLenum, const void * ) = { |
| 115 | { 0, |
| 116 | 0, |
Gareth Hughes | 1fb0a43 | 2001-12-28 06:28:10 +0000 | [diff] [blame] | 117 | (texarray_func)glMultiTexCoord1svARB, |
Keith Whitwell | 4b7d6f2 | 2001-06-01 22:22:10 +0000 | [diff] [blame] | 118 | 0, |
Gareth Hughes | 1fb0a43 | 2001-12-28 06:28:10 +0000 | [diff] [blame] | 119 | (texarray_func)glMultiTexCoord1ivARB, |
Keith Whitwell | 4b7d6f2 | 2001-06-01 22:22:10 +0000 | [diff] [blame] | 120 | 0, |
Gareth Hughes | 1fb0a43 | 2001-12-28 06:28:10 +0000 | [diff] [blame] | 121 | (texarray_func)glMultiTexCoord1fvARB, |
| 122 | (texarray_func)glMultiTexCoord1dvARB }, |
Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 123 | |
Keith Whitwell | 4b7d6f2 | 2001-06-01 22:22:10 +0000 | [diff] [blame] | 124 | { 0, |
| 125 | 0, |
Gareth Hughes | 1fb0a43 | 2001-12-28 06:28:10 +0000 | [diff] [blame] | 126 | (texarray_func)glMultiTexCoord2svARB, |
Keith Whitwell | 4b7d6f2 | 2001-06-01 22:22:10 +0000 | [diff] [blame] | 127 | 0, |
Gareth Hughes | 1fb0a43 | 2001-12-28 06:28:10 +0000 | [diff] [blame] | 128 | (texarray_func)glMultiTexCoord2ivARB, |
Keith Whitwell | 4b7d6f2 | 2001-06-01 22:22:10 +0000 | [diff] [blame] | 129 | 0, |
Gareth Hughes | 1fb0a43 | 2001-12-28 06:28:10 +0000 | [diff] [blame] | 130 | (texarray_func)glMultiTexCoord2fvARB, |
| 131 | (texarray_func)glMultiTexCoord2dvARB }, |
Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 132 | |
Keith Whitwell | 4b7d6f2 | 2001-06-01 22:22:10 +0000 | [diff] [blame] | 133 | { 0, |
| 134 | 0, |
Gareth Hughes | 1fb0a43 | 2001-12-28 06:28:10 +0000 | [diff] [blame] | 135 | (texarray_func)glMultiTexCoord3svARB, |
Keith Whitwell | 4b7d6f2 | 2001-06-01 22:22:10 +0000 | [diff] [blame] | 136 | 0, |
Gareth Hughes | 1fb0a43 | 2001-12-28 06:28:10 +0000 | [diff] [blame] | 137 | (texarray_func)glMultiTexCoord3ivARB, |
Keith Whitwell | 4b7d6f2 | 2001-06-01 22:22:10 +0000 | [diff] [blame] | 138 | 0, |
Gareth Hughes | 1fb0a43 | 2001-12-28 06:28:10 +0000 | [diff] [blame] | 139 | (texarray_func)glMultiTexCoord3fvARB, |
| 140 | (texarray_func)glMultiTexCoord3dvARB }, |
Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 141 | |
Keith Whitwell | 4b7d6f2 | 2001-06-01 22:22:10 +0000 | [diff] [blame] | 142 | { 0, |
| 143 | 0, |
Gareth Hughes | 1fb0a43 | 2001-12-28 06:28:10 +0000 | [diff] [blame] | 144 | (texarray_func)glMultiTexCoord4svARB, |
Keith Whitwell | 4b7d6f2 | 2001-06-01 22:22:10 +0000 | [diff] [blame] | 145 | 0, |
Gareth Hughes | 1fb0a43 | 2001-12-28 06:28:10 +0000 | [diff] [blame] | 146 | (texarray_func)glMultiTexCoord4ivARB, |
Keith Whitwell | 4b7d6f2 | 2001-06-01 22:22:10 +0000 | [diff] [blame] | 147 | 0, |
Gareth Hughes | 1fb0a43 | 2001-12-28 06:28:10 +0000 | [diff] [blame] | 148 | (texarray_func)glMultiTexCoord4fvARB, |
| 149 | (texarray_func)glMultiTexCoord4dvARB } |
Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 150 | }; |
| 151 | |
Keith Whitwell | 4b7d6f2 | 2001-06-01 22:22:10 +0000 | [diff] [blame] | 152 | static void (*indexfuncs[8])( const void * ) = { |
| 153 | 0, |
Gareth Hughes | 1fb0a43 | 2001-12-28 06:28:10 +0000 | [diff] [blame] | 154 | (array_func)glIndexubv, |
| 155 | (array_func)glIndexsv, |
Keith Whitwell | 4b7d6f2 | 2001-06-01 22:22:10 +0000 | [diff] [blame] | 156 | 0, |
Gareth Hughes | 1fb0a43 | 2001-12-28 06:28:10 +0000 | [diff] [blame] | 157 | (array_func)glIndexiv, |
Keith Whitwell | 4b7d6f2 | 2001-06-01 22:22:10 +0000 | [diff] [blame] | 158 | 0, |
Gareth Hughes | 1fb0a43 | 2001-12-28 06:28:10 +0000 | [diff] [blame] | 159 | (array_func)glIndexfv, |
| 160 | (array_func)glIndexdv |
Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 161 | }; |
| 162 | |
| 163 | |
Keith Whitwell | 4b7d6f2 | 2001-06-01 22:22:10 +0000 | [diff] [blame] | 164 | static void (*normalfuncs[8])( const void * ) = { |
Gareth Hughes | 1fb0a43 | 2001-12-28 06:28:10 +0000 | [diff] [blame] | 165 | (array_func)glNormal3bv, |
Keith Whitwell | 4b7d6f2 | 2001-06-01 22:22:10 +0000 | [diff] [blame] | 166 | 0, |
Gareth Hughes | 1fb0a43 | 2001-12-28 06:28:10 +0000 | [diff] [blame] | 167 | (array_func)glNormal3sv, |
Keith Whitwell | 4b7d6f2 | 2001-06-01 22:22:10 +0000 | [diff] [blame] | 168 | 0, |
Gareth Hughes | 1fb0a43 | 2001-12-28 06:28:10 +0000 | [diff] [blame] | 169 | (array_func)glNormal3iv, |
Keith Whitwell | 4b7d6f2 | 2001-06-01 22:22:10 +0000 | [diff] [blame] | 170 | 0, |
Gareth Hughes | 1fb0a43 | 2001-12-28 06:28:10 +0000 | [diff] [blame] | 171 | (array_func)glNormal3fv, |
| 172 | (array_func)glNormal3dv, |
Keith Whitwell | 4b7d6f2 | 2001-06-01 22:22:10 +0000 | [diff] [blame] | 173 | }; |
| 174 | |
Brian Paul | 03c0c2e | 2002-01-14 16:06:35 +0000 | [diff] [blame] | 175 | |
| 176 | /* Wrapper functions in case glSecondaryColor*EXT doesn't exist */ |
| 177 | static void SecondaryColor3bvEXT(const GLbyte *c) |
| 178 | { |
| 179 | _glapi_Dispatch->SecondaryColor3bvEXT(c); |
| 180 | } |
| 181 | |
| 182 | static void SecondaryColor3ubvEXT(const GLubyte *c) |
| 183 | { |
| 184 | _glapi_Dispatch->SecondaryColor3ubvEXT(c); |
| 185 | } |
| 186 | |
| 187 | static void SecondaryColor3svEXT(const GLshort *c) |
| 188 | { |
| 189 | _glapi_Dispatch->SecondaryColor3svEXT(c); |
| 190 | } |
| 191 | |
| 192 | static void SecondaryColor3usvEXT(const GLushort *c) |
| 193 | { |
| 194 | _glapi_Dispatch->SecondaryColor3usvEXT(c); |
| 195 | } |
| 196 | |
| 197 | static void SecondaryColor3ivEXT(const GLint *c) |
| 198 | { |
| 199 | _glapi_Dispatch->SecondaryColor3ivEXT(c); |
| 200 | } |
| 201 | |
| 202 | static void SecondaryColor3uivEXT(const GLuint *c) |
| 203 | { |
| 204 | _glapi_Dispatch->SecondaryColor3uivEXT(c); |
| 205 | } |
| 206 | |
| 207 | static void SecondaryColor3fvEXT(const GLfloat *c) |
| 208 | { |
| 209 | _glapi_Dispatch->SecondaryColor3fvEXT(c); |
| 210 | } |
| 211 | |
| 212 | static void SecondaryColor3dvEXT(const GLdouble *c) |
| 213 | { |
| 214 | _glapi_Dispatch->SecondaryColor3dvEXT(c); |
| 215 | } |
| 216 | |
| 217 | static void (*secondarycolorfuncs[8])( const void * ) = { |
| 218 | (array_func) SecondaryColor3bvEXT, |
| 219 | (array_func) SecondaryColor3ubvEXT, |
| 220 | (array_func) SecondaryColor3svEXT, |
| 221 | (array_func) SecondaryColor3usvEXT, |
| 222 | (array_func) SecondaryColor3ivEXT, |
| 223 | (array_func) SecondaryColor3uivEXT, |
| 224 | (array_func) SecondaryColor3fvEXT, |
| 225 | (array_func) SecondaryColor3dvEXT, |
| 226 | }; |
| 227 | |
| 228 | |
| 229 | /* Again, wrapper functions in case glSecondaryColor*EXT doesn't exist */ |
| 230 | static void FogCoordfvEXT(const GLfloat *f) |
| 231 | { |
| 232 | _glapi_Dispatch->FogCoordfvEXT(f); |
| 233 | } |
| 234 | |
| 235 | static void FogCoorddvEXT(const GLdouble *f) |
| 236 | { |
| 237 | _glapi_Dispatch->FogCoorddvEXT(f); |
| 238 | } |
| 239 | |
| 240 | static void (*fogcoordfuncs[8])( const void * ) = { |
| 241 | 0, |
| 242 | 0, |
| 243 | 0, |
| 244 | 0, |
| 245 | 0, |
| 246 | 0, |
| 247 | (array_func) FogCoordfvEXT, |
| 248 | (array_func) FogCoorddvEXT |
| 249 | }; |
| 250 | |
| 251 | |
Keith Whitwell | 4b7d6f2 | 2001-06-01 22:22:10 +0000 | [diff] [blame] | 252 | |
| 253 | GLboolean _ae_create_context( GLcontext *ctx ) |
Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 254 | { |
Keith Whitwell | 4b7d6f2 | 2001-06-01 22:22:10 +0000 | [diff] [blame] | 255 | ctx->aelt_context = MALLOC( sizeof(AEcontext) ); |
Gareth Hughes | 1fb0a43 | 2001-12-28 06:28:10 +0000 | [diff] [blame] | 256 | if (!ctx->aelt_context) |
Keith Whitwell | 4b7d6f2 | 2001-06-01 22:22:10 +0000 | [diff] [blame] | 257 | return GL_FALSE; |
| 258 | |
| 259 | AE_CONTEXT(ctx)->NewState = ~0; |
| 260 | return GL_TRUE; |
Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 261 | } |
| 262 | |
Keith Whitwell | 4b7d6f2 | 2001-06-01 22:22:10 +0000 | [diff] [blame] | 263 | |
| 264 | void _ae_destroy_context( GLcontext *ctx ) |
Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 265 | { |
Keith Whitwell | 4b7d6f2 | 2001-06-01 22:22:10 +0000 | [diff] [blame] | 266 | if ( AE_CONTEXT( ctx ) ) { |
| 267 | FREE( ctx->aelt_context ); |
| 268 | ctx->aelt_context = 0; |
| 269 | } |
| 270 | } |
| 271 | |
| 272 | |
| 273 | static void _ae_update_state( GLcontext *ctx ) |
| 274 | { |
| 275 | AEcontext *actx = AE_CONTEXT(ctx); |
| 276 | AEtexarray *ta = actx->texarrays; |
| 277 | AEarray *aa = actx->arrays; |
Brian Paul | db07de0 | 2002-04-19 00:23:08 +0000 | [diff] [blame] | 278 | GLuint i; |
Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 279 | |
Gareth Hughes | 22144ab | 2001-03-12 00:48:37 +0000 | [diff] [blame] | 280 | for (i = 0 ; i < ctx->Const.MaxTextureUnits ; i++) |
Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 281 | if (ctx->Array.TexCoord[i].Enabled) { |
| 282 | ta->unit = i; |
| 283 | ta->array = &ctx->Array.TexCoord[i]; |
| 284 | ta->func = multitexfuncs[ta->array->Size-1][TYPE_IDX(ta->array->Type)]; |
| 285 | ta++; |
| 286 | } |
| 287 | |
| 288 | ta->func = 0; |
| 289 | |
| 290 | if (ctx->Array.Color.Enabled) { |
| 291 | aa->array = &ctx->Array.Color; |
| 292 | aa->func = colorfuncs[aa->array->Size-3][TYPE_IDX(aa->array->Type)]; |
| 293 | aa++; |
| 294 | } |
| 295 | |
| 296 | if (ctx->Array.Normal.Enabled) { |
| 297 | aa->array = &ctx->Array.Normal; |
| 298 | aa->func = normalfuncs[TYPE_IDX(aa->array->Type)]; |
| 299 | aa++; |
| 300 | } |
| 301 | |
| 302 | if (ctx->Array.Index.Enabled) { |
| 303 | aa->array = &ctx->Array.Index; |
| 304 | aa->func = indexfuncs[TYPE_IDX(aa->array->Type)]; |
| 305 | aa++; |
| 306 | } |
| 307 | |
| 308 | if (ctx->Array.EdgeFlag.Enabled) { |
Keith Whitwell | 4b7d6f2 | 2001-06-01 22:22:10 +0000 | [diff] [blame] | 309 | aa->array = &ctx->Array.EdgeFlag; |
Gareth Hughes | 1fb0a43 | 2001-12-28 06:28:10 +0000 | [diff] [blame] | 310 | aa->func = (array_func)glEdgeFlagv; |
Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 311 | aa++; |
| 312 | } |
| 313 | |
| 314 | if (ctx->Array.FogCoord.Enabled) { |
Keith Whitwell | 4b7d6f2 | 2001-06-01 22:22:10 +0000 | [diff] [blame] | 315 | aa->array = &ctx->Array.FogCoord; |
Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 316 | aa->func = fogcoordfuncs[TYPE_IDX(aa->array->Type)]; |
| 317 | aa++; |
| 318 | } |
| 319 | |
| 320 | if (ctx->Array.SecondaryColor.Enabled) { |
| 321 | aa->array = &ctx->Array.SecondaryColor; |
| 322 | aa->func = secondarycolorfuncs[TYPE_IDX(aa->array->Type)]; |
| 323 | aa++; |
| 324 | } |
| 325 | |
| 326 | /* Must be last |
| 327 | */ |
| 328 | if (ctx->Array.Vertex.Enabled) { |
| 329 | aa->array = &ctx->Array.Vertex; |
| 330 | aa->func = vertexfuncs[aa->array->Size-2][TYPE_IDX(aa->array->Type)]; |
| 331 | aa++; |
| 332 | } |
| 333 | |
| 334 | aa->func = 0; |
| 335 | actx->NewState = 0; |
| 336 | } |
| 337 | |
| 338 | |
Keith Whitwell | 4b7d6f2 | 2001-06-01 22:22:10 +0000 | [diff] [blame] | 339 | void _ae_loopback_array_elt( GLint elt ) |
Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 340 | { |
| 341 | GET_CURRENT_CONTEXT(ctx); |
Keith Whitwell | 4b7d6f2 | 2001-06-01 22:22:10 +0000 | [diff] [blame] | 342 | AEcontext *actx = AE_CONTEXT(ctx); |
| 343 | AEtexarray *ta; |
| 344 | AEarray *aa; |
| 345 | |
| 346 | if (actx->NewState) |
| 347 | _ae_update_state( ctx ); |
Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 348 | |
| 349 | for (ta = actx->texarrays ; ta->func ; ta++) { |
Brian Paul | 4753d60 | 2002-06-15 02:38:15 +0000 | [diff] [blame] | 350 | ta->func( ta->unit + GL_TEXTURE0_ARB, (char *)ta->array->Ptr + elt * ta->array->StrideB ); |
Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 351 | } |
| 352 | |
Keith Whitwell | 4b7d6f2 | 2001-06-01 22:22:10 +0000 | [diff] [blame] | 353 | /* Must be last |
| 354 | */ |
Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 355 | for (aa = actx->arrays ; aa->func ; aa++) { |
Keith Whitwell | 4b7d6f2 | 2001-06-01 22:22:10 +0000 | [diff] [blame] | 356 | aa->func( (char *)aa->array->Ptr + elt * aa->array->StrideB ); |
Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 357 | } |
| 358 | } |
| 359 | |
| 360 | |
Keith Whitwell | 4b7d6f2 | 2001-06-01 22:22:10 +0000 | [diff] [blame] | 361 | |
| 362 | void _ae_invalidate_state( GLcontext *ctx, GLuint new_state ) |
Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 363 | { |
Keith Whitwell | 4b7d6f2 | 2001-06-01 22:22:10 +0000 | [diff] [blame] | 364 | AE_CONTEXT(ctx)->NewState |= new_state; |
Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 365 | } |