| 1 |
/* |
| 2 |
* Mesa 3-D graphics library |
| 3 |
* Version: 6.4.1 |
| 4 |
* |
| 5 |
* Copyright (C) 1999-2005 Brian Paul All Rights Reserved. |
| 6 |
* |
| 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 |
|
| 25 |
/* Author: |
| 26 |
* Keith Whitwell <[email protected]> |
| 27 |
*/ |
| 28 |
|
| 29 |
#include "glheader.h" |
| 30 |
#include "api_arrayelt.h" |
| 31 |
#include "context.h" |
| 32 |
#include "glapi.h" |
| 33 |
#include "imports.h" |
| 34 |
#include "macros.h" |
| 35 |
#include "mtypes.h" |
| 36 |
#include "glapioffsets.h" |
| 37 |
#include "dispatch.h" |
| 38 |
|
| 39 |
typedef void (GLAPIENTRY *array_func)( const void * ); |
| 40 |
|
| 41 |
typedef struct { |
| 42 |
const struct gl_client_array *array; |
| 43 |
int offset; |
| 44 |
} AEarray; |
| 45 |
|
| 46 |
typedef void (GLAPIENTRY *attrib_func)( GLuint indx, const void *data ); |
| 47 |
|
| 48 |
typedef struct { |
| 49 |
const struct gl_client_array *array; |
| 50 |
attrib_func func; |
| 51 |
GLuint index; |
| 52 |
} AEattrib; |
| 53 |
|
| 54 |
typedef struct { |
| 55 |
AEarray arrays[32]; |
| 56 |
AEattrib attribs[VERT_ATTRIB_MAX + 1]; |
| 57 |
GLuint NewState; |
| 58 |
} AEcontext; |
| 59 |
|
| 60 |
#define AE_CONTEXT(ctx) ((AEcontext *)(ctx)->aelt_context) |
| 61 |
|
| 62 |
|
| 63 |
/* |
| 64 |
* Convert GL_BYTE, GL_UNSIGNED_BYTE, .. GL_DOUBLE into an integer |
| 65 |
* in the range [0, 7]. Luckily these type tokens are sequentially |
| 66 |
* numbered in gl.h, except for GL_DOUBLE. |
| 67 |
*/ |
| 68 |
#define TYPE_IDX(t) ( (t) == GL_DOUBLE ? 7 : (t) & 7 ) |
| 69 |
|
| 70 |
static const int ColorFuncs[2][8] = { |
| 71 |
{ |
| 72 |
_gloffset_Color3bv, |
| 73 |
_gloffset_Color3ubv, |
| 74 |
_gloffset_Color3sv, |
| 75 |
_gloffset_Color3usv, |
| 76 |
_gloffset_Color3iv, |
| 77 |
_gloffset_Color3uiv, |
| 78 |
_gloffset_Color3fv, |
| 79 |
_gloffset_Color3dv, |
| 80 |
}, |
| 81 |
{ |
| 82 |
_gloffset_Color4bv, |
| 83 |
_gloffset_Color4ubv, |
| 84 |
_gloffset_Color4sv, |
| 85 |
_gloffset_Color4usv, |
| 86 |
_gloffset_Color4iv, |
| 87 |
_gloffset_Color4uiv, |
| 88 |
_gloffset_Color4fv, |
| 89 |
_gloffset_Color4dv, |
| 90 |
}, |
| 91 |
}; |
| 92 |
|
| 93 |
static const int VertexFuncs[3][8] = { |
| 94 |
{ |
| 95 |
-1, |
| 96 |
-1, |
| 97 |
_gloffset_Vertex2sv, |
| 98 |
-1, |
| 99 |
_gloffset_Vertex2iv, |
| 100 |
-1, |
| 101 |
_gloffset_Vertex2fv, |
| 102 |
_gloffset_Vertex2dv, |
| 103 |
}, |
| 104 |
{ |
| 105 |
-1, |
| 106 |
-1, |
| 107 |
_gloffset_Vertex3sv, |
| 108 |
-1, |
| 109 |
_gloffset_Vertex3iv, |
| 110 |
-1, |
| 111 |
_gloffset_Vertex3fv, |
| 112 |
_gloffset_Vertex3dv, |
| 113 |
}, |
| 114 |
{ |
| 115 |
-1, |
| 116 |
-1, |
| 117 |
_gloffset_Vertex4sv, |
| 118 |
-1, |
| 119 |
_gloffset_Vertex4iv, |
| 120 |
-1, |
| 121 |
_gloffset_Vertex4fv, |
| 122 |
_gloffset_Vertex4dv, |
| 123 |
}, |
| 124 |
}; |
| 125 |
|
| 126 |
static 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, |
| 135 |
}; |
| 136 |
|
| 137 |
static 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, |
| 146 |
}; |
| 147 |
|
| 148 |
#if defined(IN_DRI_DRIVER) |
| 149 |
static int SecondaryColorFuncs[8]; |
| 150 |
static int FogCoordFuncs[8] = { |
| 151 |
-1, |
| 152 |
-1, |
| 153 |
-1, |
| 154 |
-1, |
| 155 |
-1, |
| 156 |
-1, |
| 157 |
0, |
| 158 |
0, |
| 159 |
}; |
| 160 |
#else |
| 161 |
static const int SecondaryColorFuncs[8] = { |
| 162 |
_gloffset_SecondaryColor3bvEXT, |
| 163 |
_gloffset_SecondaryColor3ubvEXT, |
| 164 |
_gloffset_SecondaryColor3svEXT, |
| 165 |
_gloffset_SecondaryColor3usvEXT, |
| 166 |
_gloffset_SecondaryColor3ivEXT, |
| 167 |
_gloffset_SecondaryColor3uivEXT, |
| 168 |
_gloffset_SecondaryColor3fvEXT, |
| 169 |
_gloffset_SecondaryColor3dvEXT, |
| 170 |
}; |
| 171 |
|
| 172 |
static const int FogCoordFuncs[8] = { |
| 173 |
-1, |
| 174 |
-1, |
| 175 |
-1, |
| 176 |
-1, |
| 177 |
-1, |
| 178 |
-1, |
| 179 |
_gloffset_FogCoordfvEXT, |
| 180 |
_gloffset_FogCoorddvEXT |
| 181 |
}; |
| 182 |
#endif |
| 183 |
|
| 184 |
/**********************************************************************/ |
| 185 |
|
| 186 |
/* GL_BYTE attributes */ |
| 187 |
|
| 188 |
static void GLAPIENTRY VertexAttrib1NbvNV(GLuint index, const GLbyte *v) |
| 189 |
{ |
| 190 |
CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, BYTE_TO_FLOAT(v[0]))); |
| 191 |
} |
| 192 |
|
| 193 |
static void GLAPIENTRY VertexAttrib1bvNV(GLuint index, const GLbyte *v) |
| 194 |
{ |
| 195 |
CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, v[0])); |
| 196 |
} |
| 197 |
|
| 198 |
static void GLAPIENTRY VertexAttrib2NbvNV(GLuint index, const GLbyte *v) |
| 199 |
{ |
| 200 |
CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, BYTE_TO_FLOAT(v[0]), BYTE_TO_FLOAT(v[1]))); |
| 201 |
} |
| 202 |
|
| 203 |
static void GLAPIENTRY VertexAttrib2bvNV(GLuint index, const GLbyte *v) |
| 204 |
{ |
| 205 |
CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, v[0], v[1])); |
| 206 |
} |
| 207 |
|
| 208 |
static void GLAPIENTRY VertexAttrib3NbvNV(GLuint index, const GLbyte *v) |
| 209 |
{ |
| 210 |
CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, BYTE_TO_FLOAT(v[0]), |
| 211 |
BYTE_TO_FLOAT(v[1]), |
| 212 |
BYTE_TO_FLOAT(v[2]))); |
| 213 |
} |
| 214 |
|
| 215 |
static void GLAPIENTRY VertexAttrib3bvNV(GLuint index, const GLbyte *v) |
| 216 |
{ |
| 217 |
CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, v[0], v[1], v[2])); |
| 218 |
} |
| 219 |
|
| 220 |
static void GLAPIENTRY VertexAttrib4NbvNV(GLuint index, const GLbyte *v) |
| 221 |
{ |
| 222 |
CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, BYTE_TO_FLOAT(v[0]), |
| 223 |
BYTE_TO_FLOAT(v[1]), |
| 224 |
BYTE_TO_FLOAT(v[2]), |
| 225 |
BYTE_TO_FLOAT(v[3]))); |
| 226 |
} |
| 227 |
|
| 228 |
static void GLAPIENTRY VertexAttrib4bvNV(GLuint index, const GLbyte *v) |
| 229 |
{ |
| 230 |
CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, v[0], v[1], v[2], v[3])); |
| 231 |
} |
| 232 |
|
| 233 |
/* GL_UNSIGNED_BYTE attributes */ |
| 234 |
|
| 235 |
static void GLAPIENTRY VertexAttrib1NubvNV(GLuint index, const GLubyte *v) |
| 236 |
{ |
| 237 |
CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, UBYTE_TO_FLOAT(v[0]))); |
| 238 |
} |
| 239 |
|
| 240 |
static void GLAPIENTRY VertexAttrib1ubvNV(GLuint index, const GLubyte *v) |
| 241 |
{ |
| 242 |
CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, v[0])); |
| 243 |
} |
| 244 |
|
| 245 |
static void GLAPIENTRY VertexAttrib2NubvNV(GLuint index, const GLubyte *v) |
| 246 |
{ |
| 247 |
CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, UBYTE_TO_FLOAT(v[0]), |
| 248 |
UBYTE_TO_FLOAT(v[1]))); |
| 249 |
} |
| 250 |
|
| 251 |
static void GLAPIENTRY VertexAttrib2ubvNV(GLuint index, const GLubyte *v) |
| 252 |
{ |
| 253 |
CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, v[0], v[1])); |
| 254 |
} |
| 255 |
|
| 256 |
static void GLAPIENTRY VertexAttrib3NubvNV(GLuint index, const GLubyte *v) |
| 257 |
{ |
| 258 |
CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, UBYTE_TO_FLOAT(v[0]), |
| 259 |
UBYTE_TO_FLOAT(v[1]), |
| 260 |
UBYTE_TO_FLOAT(v[2]))); |
| 261 |
} |
| 262 |
static void GLAPIENTRY VertexAttrib3ubvNV(GLuint index, const GLubyte *v) |
| 263 |
{ |
| 264 |
CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, v[0], v[1], v[2])); |
| 265 |
} |
| 266 |
|
| 267 |
static void GLAPIENTRY VertexAttrib4NubvNV(GLuint index, const GLubyte *v) |
| 268 |
{ |
| 269 |
CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, UBYTE_TO_FLOAT(v[0]), |
| 270 |
UBYTE_TO_FLOAT(v[1]), |
| 271 |
UBYTE_TO_FLOAT(v[2]), |
| 272 |
UBYTE_TO_FLOAT(v[3]))); |
| 273 |
} |
| 274 |
|
| 275 |
static void GLAPIENTRY VertexAttrib4ubvNV(GLuint index, const GLubyte *v) |
| 276 |
{ |
| 277 |
CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, v[0], v[1], v[2], v[3])); |
| 278 |
} |
| 279 |
|
| 280 |
/* GL_SHORT attributes */ |
| 281 |
|
| 282 |
static void GLAPIENTRY VertexAttrib1NsvNV(GLuint index, const GLshort *v) |
| 283 |
{ |
| 284 |
CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, SHORT_TO_FLOAT(v[0]))); |
| 285 |
} |
| 286 |
|
| 287 |
static void GLAPIENTRY VertexAttrib1svNV(GLuint index, const GLshort *v) |
| 288 |
{ |
| 289 |
CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, v[0])); |
| 290 |
} |
| 291 |
|
| 292 |
static void GLAPIENTRY VertexAttrib2NsvNV(GLuint index, const GLshort *v) |
| 293 |
{ |
| 294 |
CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, SHORT_TO_FLOAT(v[0]), |
| 295 |
SHORT_TO_FLOAT(v[1]))); |
| 296 |
} |
| 297 |
|
| 298 |
static void GLAPIENTRY VertexAttrib2svNV(GLuint index, const GLshort *v) |
| 299 |
{ |
| 300 |
CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, v[0], v[1])); |
| 301 |
} |
| 302 |
|
| 303 |
static void GLAPIENTRY VertexAttrib3NsvNV(GLuint index, const GLshort *v) |
| 304 |
{ |
| 305 |
CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, SHORT_TO_FLOAT(v[0]), |
| 306 |
SHORT_TO_FLOAT(v[1]), |
| 307 |
SHORT_TO_FLOAT(v[2]))); |
| 308 |
} |
| 309 |
|
| 310 |
static void GLAPIENTRY VertexAttrib3svNV(GLuint index, const GLshort *v) |
| 311 |
{ |
| 312 |
CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, v[0], v[1], v[2])); |
| 313 |
} |
| 314 |
|
| 315 |
static void GLAPIENTRY VertexAttrib4NsvNV(GLuint index, const GLshort *v) |
| 316 |
{ |
| 317 |
CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, SHORT_TO_FLOAT(v[0]), |
| 318 |
SHORT_TO_FLOAT(v[1]), |
| 319 |
SHORT_TO_FLOAT(v[2]), |
| 320 |
SHORT_TO_FLOAT(v[3]))); |
| 321 |
} |
| 322 |
|
| 323 |
static void GLAPIENTRY VertexAttrib4svNV(GLuint index, const GLshort *v) |
| 324 |
{ |
| 325 |
CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, v[0], v[1], v[2], v[3])); |
| 326 |
} |
| 327 |
|
| 328 |
/* GL_UNSIGNED_SHORT attributes */ |
| 329 |
|
| 330 |
static void GLAPIENTRY VertexAttrib1NusvNV(GLuint index, const GLushort *v) |
| 331 |
{ |
| 332 |
CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, USHORT_TO_FLOAT(v[0]))); |
| 333 |
} |
| 334 |
|
| 335 |
static void GLAPIENTRY VertexAttrib1usvNV(GLuint index, const GLushort *v) |
| 336 |
{ |
| 337 |
CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, v[0])); |
| 338 |
} |
| 339 |
|
| 340 |
static void GLAPIENTRY VertexAttrib2NusvNV(GLuint index, const GLushort *v) |
| 341 |
{ |
| 342 |
CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, USHORT_TO_FLOAT(v[0]), |
| 343 |
USHORT_TO_FLOAT(v[1]))); |
| 344 |
} |
| 345 |
|
| 346 |
static void GLAPIENTRY VertexAttrib2usvNV(GLuint index, const GLushort *v) |
| 347 |
{ |
| 348 |
CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, v[0], v[1])); |
| 349 |
} |
| 350 |
|
| 351 |
static void GLAPIENTRY VertexAttrib3NusvNV(GLuint index, const GLushort *v) |
| 352 |
{ |
| 353 |
CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, USHORT_TO_FLOAT(v[0]), |
| 354 |
USHORT_TO_FLOAT(v[1]), |
| 355 |
USHORT_TO_FLOAT(v[2]))); |
| 356 |
} |
| 357 |
|
| 358 |
static void GLAPIENTRY VertexAttrib3usvNV(GLuint index, const GLushort *v) |
| 359 |
{ |
| 360 |
CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, v[0], v[1], v[2])); |
| 361 |
} |
| 362 |
|
| 363 |
static void GLAPIENTRY VertexAttrib4NusvNV(GLuint index, const GLushort *v) |
| 364 |
{ |
| 365 |
CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, USHORT_TO_FLOAT(v[0]), |
| 366 |
USHORT_TO_FLOAT(v[1]), |
| 367 |
USHORT_TO_FLOAT(v[2]), |
| 368 |
USHORT_TO_FLOAT(v[3]))); |
| 369 |
} |
| 370 |
|
| 371 |
static void GLAPIENTRY VertexAttrib4usvNV(GLuint index, const GLushort *v) |
| 372 |
{ |
| 373 |
CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, v[0], v[1], v[2], v[3])); |
| 374 |
} |
| 375 |
|
| 376 |
/* GL_INT attributes */ |
| 377 |
|
| 378 |
static void GLAPIENTRY VertexAttrib1NivNV(GLuint index, const GLint *v) |
| 379 |
{ |
| 380 |
CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, INT_TO_FLOAT(v[0]))); |
| 381 |
} |
| 382 |
|
| 383 |
static void GLAPIENTRY VertexAttrib1ivNV(GLuint index, const GLint *v) |
| 384 |
{ |
| 385 |
CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, v[0])); |
| 386 |
} |
| 387 |
|
| 388 |
static void GLAPIENTRY VertexAttrib2NivNV(GLuint index, const GLint *v) |
| 389 |
{ |
| 390 |
CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, INT_TO_FLOAT(v[0]), |
| 391 |
INT_TO_FLOAT(v[1]))); |
| 392 |
} |
| 393 |
|
| 394 |
static void GLAPIENTRY VertexAttrib2ivNV(GLuint index, const GLint *v) |
| 395 |
{ |
| 396 |
CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, v[0], v[1])); |
| 397 |
} |
| 398 |
|
| 399 |
static void GLAPIENTRY VertexAttrib3NivNV(GLuint index, const GLint *v) |
| 400 |
{ |
| 401 |
CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, INT_TO_FLOAT(v[0]), |
| 402 |
INT_TO_FLOAT(v[1]), |
| 403 |
INT_TO_FLOAT(v[2]))); |
| 404 |
} |
| 405 |
|
| 406 |
static void GLAPIENTRY VertexAttrib3ivNV(GLuint index, const GLint *v) |
| 407 |
{ |
| 408 |
CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, v[0], v[1], v[2])); |
| 409 |
} |
| 410 |
|
| 411 |
static void GLAPIENTRY VertexAttrib4NivNV(GLuint index, const GLint *v) |
| 412 |
{ |
| 413 |
CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, INT_TO_FLOAT(v[0]), |
| 414 |
INT_TO_FLOAT(v[1]), |
| 415 |
INT_TO_FLOAT(v[2]), |
| 416 |
INT_TO_FLOAT(v[3]))); |
| 417 |
} |
| 418 |
|
| 419 |
static void GLAPIENTRY VertexAttrib4ivNV(GLuint index, const GLint *v) |
| 420 |
{ |
| 421 |
CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, v[0], v[1], v[2], v[3])); |
| 422 |
} |
| 423 |
|
| 424 |
/* GL_UNSIGNED_INT attributes */ |
| 425 |
|
| 426 |
static void GLAPIENTRY VertexAttrib1NuivNV(GLuint index, const GLuint *v) |
| 427 |
{ |
| 428 |
CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, UINT_TO_FLOAT(v[0]))); |
| 429 |
} |
| 430 |
|
| 431 |
static void GLAPIENTRY VertexAttrib1uivNV(GLuint index, const GLuint *v) |
| 432 |
{ |
| 433 |
CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, v[0])); |
| 434 |
} |
| 435 |
|
| 436 |
static void GLAPIENTRY VertexAttrib2NuivNV(GLuint index, const GLuint *v) |
| 437 |
{ |
| 438 |
CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, UINT_TO_FLOAT(v[0]), |
| 439 |
UINT_TO_FLOAT(v[1]))); |
| 440 |
} |
| 441 |
|
| 442 |
static void GLAPIENTRY VertexAttrib2uivNV(GLuint index, const GLuint *v) |
| 443 |
{ |
| 444 |
CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, v[0], v[1])); |
| 445 |
} |
| 446 |
|
| 447 |
static void GLAPIENTRY VertexAttrib3NuivNV(GLuint index, const GLuint *v) |
| 448 |
{ |
| 449 |
CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, UINT_TO_FLOAT(v[0]), |
| 450 |
UINT_TO_FLOAT(v[1]), |
| 451 |
UINT_TO_FLOAT(v[2]))); |
| 452 |
} |
| 453 |
|
| 454 |
static void GLAPIENTRY VertexAttrib3uivNV(GLuint index, const GLuint *v) |
| 455 |
{ |
| 456 |
CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, v[0], v[1], v[2])); |
| 457 |
} |
| 458 |
|
| 459 |
static void GLAPIENTRY VertexAttrib4NuivNV(GLuint index, const GLuint *v) |
| 460 |
{ |
| 461 |
CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, UINT_TO_FLOAT(v[0]), |
| 462 |
UINT_TO_FLOAT(v[1]), |
| 463 |
UINT_TO_FLOAT(v[2]), |
| 464 |
UINT_TO_FLOAT(v[3]))); |
| 465 |
} |
| 466 |
|
| 467 |
static void GLAPIENTRY VertexAttrib4uivNV(GLuint index, const GLuint *v) |
| 468 |
{ |
| 469 |
CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, v[0], v[1], v[2], v[3])); |
| 470 |
} |
| 471 |
|
| 472 |
/* GL_FLOAT attributes */ |
| 473 |
|
| 474 |
static void GLAPIENTRY VertexAttrib1fvNV(GLuint index, const GLfloat *v) |
| 475 |
{ |
| 476 |
CALL_VertexAttrib1fvNV(GET_DISPATCH(), (index, v)); |
| 477 |
} |
| 478 |
|
| 479 |
static void GLAPIENTRY VertexAttrib2fvNV(GLuint index, const GLfloat *v) |
| 480 |
{ |
| 481 |
CALL_VertexAttrib2fvNV(GET_DISPATCH(), (index, v)); |
| 482 |
} |
| 483 |
|
| 484 |
static void GLAPIENTRY VertexAttrib3fvNV(GLuint index, const GLfloat *v) |
| 485 |
{ |
| 486 |
CALL_VertexAttrib3fvNV(GET_DISPATCH(), (index, v)); |
| 487 |
} |
| 488 |
|
| 489 |
static void GLAPIENTRY VertexAttrib4fvNV(GLuint index, const GLfloat *v) |
| 490 |
{ |
| 491 |
CALL_VertexAttrib4fvNV(GET_DISPATCH(), (index, v)); |
| 492 |
} |
| 493 |
|
| 494 |
/* GL_DOUBLE attributes */ |
| 495 |
|
| 496 |
static void GLAPIENTRY VertexAttrib1dvNV(GLuint index, const GLdouble *v) |
| 497 |
{ |
| 498 |
CALL_VertexAttrib1dvNV(GET_DISPATCH(), (index, v)); |
| 499 |
} |
| 500 |
|
| 501 |
static void GLAPIENTRY VertexAttrib2dvNV(GLuint index, const GLdouble *v) |
| 502 |
{ |
| 503 |
CALL_VertexAttrib2dvNV(GET_DISPATCH(), (index, v)); |
| 504 |
} |
| 505 |
|
| 506 |
static void GLAPIENTRY VertexAttrib3dvNV(GLuint index, const GLdouble *v) |
| 507 |
{ |
| 508 |
CALL_VertexAttrib3dvNV(GET_DISPATCH(), (index, v)); |
| 509 |
} |
| 510 |
|
| 511 |
static void GLAPIENTRY VertexAttrib4dvNV(GLuint index, const GLdouble *v) |
| 512 |
{ |
| 513 |
CALL_VertexAttrib4dvNV(GET_DISPATCH(), (index, v)); |
| 514 |
} |
| 515 |
|
| 516 |
|
| 517 |
/* |
| 518 |
* Array [size][type] of VertexAttrib functions |
| 519 |
*/ |
| 520 |
static attrib_func AttribFuncsNV[2][4][8] = { |
| 521 |
{ |
| 522 |
/* non-normalized */ |
| 523 |
{ |
| 524 |
/* size 1 */ |
| 525 |
(attrib_func) VertexAttrib1bvNV, |
| 526 |
(attrib_func) VertexAttrib1ubvNV, |
| 527 |
(attrib_func) VertexAttrib1svNV, |
| 528 |
(attrib_func) VertexAttrib1usvNV, |
| 529 |
(attrib_func) VertexAttrib1ivNV, |
| 530 |
(attrib_func) VertexAttrib1uivNV, |
| 531 |
(attrib_func) VertexAttrib1fvNV, |
| 532 |
(attrib_func) VertexAttrib1dvNV |
| 533 |
}, |
| 534 |
{ |
| 535 |
/* size 2 */ |
| 536 |
(attrib_func) VertexAttrib2bvNV, |
| 537 |
(attrib_func) VertexAttrib2ubvNV, |
| 538 |
(attrib_func) VertexAttrib2svNV, |
| 539 |
(attrib_func) VertexAttrib2usvNV, |
| 540 |
(attrib_func) VertexAttrib2ivNV, |
| 541 |
(attrib_func) VertexAttrib2uivNV, |
| 542 |
(attrib_func) VertexAttrib2fvNV, |
| 543 |
(attrib_func) VertexAttrib2dvNV |
| 544 |
}, |
| 545 |
{ |
| 546 |
/* size 3 */ |
| 547 |
(attrib_func) VertexAttrib3bvNV, |
| 548 |
(attrib_func) VertexAttrib3ubvNV, |
| 549 |
(attrib_func) VertexAttrib3svNV, |
| 550 |
(attrib_func) VertexAttrib3usvNV, |
| 551 |
(attrib_func) VertexAttrib3ivNV, |
| 552 |
(attrib_func) VertexAttrib3uivNV, |
| 553 |
(attrib_func) VertexAttrib3fvNV, |
| 554 |
(attrib_func) VertexAttrib3dvNV |
| 555 |
}, |
| 556 |
{ |
| 557 |
/* size 4 */ |
| 558 |
(attrib_func) VertexAttrib4bvNV, |
| 559 |
(attrib_func) VertexAttrib4ubvNV, |
| 560 |
(attrib_func) VertexAttrib4svNV, |
| 561 |
(attrib_func) VertexAttrib4usvNV, |
| 562 |
(attrib_func) VertexAttrib4ivNV, |
| 563 |
(attrib_func) VertexAttrib4uivNV, |
| 564 |
(attrib_func) VertexAttrib4fvNV, |
| 565 |
(attrib_func) VertexAttrib4dvNV |
| 566 |
} |
| 567 |
}, |
| 568 |
{ |
| 569 |
/* normalized (except for float/double) */ |
| 570 |
{ |
| 571 |
/* size 1 */ |
| 572 |
(attrib_func) VertexAttrib1NbvNV, |
| 573 |
(attrib_func) VertexAttrib1NubvNV, |
| 574 |
(attrib_func) VertexAttrib1NsvNV, |
| 575 |
(attrib_func) VertexAttrib1NusvNV, |
| 576 |
(attrib_func) VertexAttrib1NivNV, |
| 577 |
(attrib_func) VertexAttrib1NuivNV, |
| 578 |
(attrib_func) VertexAttrib1fvNV, |
| 579 |
(attrib_func) VertexAttrib1dvNV |
| 580 |
}, |
| 581 |
{ |
| 582 |
/* size 2 */ |
| 583 |
(attrib_func) VertexAttrib2NbvNV, |
| 584 |
(attrib_func) VertexAttrib2NubvNV, |
| 585 |
(attrib_func) VertexAttrib2NsvNV, |
| 586 |
(attrib_func) VertexAttrib2NusvNV, |
| 587 |
(attrib_func) VertexAttrib2NivNV, |
| 588 |
(attrib_func) VertexAttrib2NuivNV, |
| 589 |
(attrib_func) VertexAttrib2fvNV, |
| 590 |
(attrib_func) VertexAttrib2dvNV |
| 591 |
}, |
| 592 |
{ |
| 593 |
/* size 3 */ |
| 594 |
(attrib_func) VertexAttrib3NbvNV, |
| 595 |
(attrib_func) VertexAttrib3NubvNV, |
| 596 |
(attrib_func) VertexAttrib3NsvNV, |
| 597 |
(attrib_func) VertexAttrib3NusvNV, |
| 598 |
(attrib_func) VertexAttrib3NivNV, |
| 599 |
(attrib_func) VertexAttrib3NuivNV, |
| 600 |
(attrib_func) VertexAttrib3fvNV, |
| 601 |
(attrib_func) VertexAttrib3dvNV |
| 602 |
}, |
| 603 |
{ |
| 604 |
/* size 4 */ |
| 605 |
(attrib_func) VertexAttrib4NbvNV, |
| 606 |
(attrib_func) VertexAttrib4NubvNV, |
| 607 |
(attrib_func) VertexAttrib4NsvNV, |
| 608 |
(attrib_func) VertexAttrib4NusvNV, |
| 609 |
(attrib_func) VertexAttrib4NivNV, |
| 610 |
(attrib_func) VertexAttrib4NuivNV, |
| 611 |
(attrib_func) VertexAttrib4fvNV, |
| 612 |
(attrib_func) VertexAttrib4dvNV |
| 613 |
} |
| 614 |
} |
| 615 |
}; |
| 616 |
|
| 617 |
/**********************************************************************/ |
| 618 |
|
| 619 |
|
| 620 |
GLboolean _ae_create_context( GLcontext *ctx ) |
| 621 |
{ |
| 622 |
if (ctx->aelt_context) |
| 623 |
return GL_TRUE; |
| 624 |
|
| 625 |
#if defined(IN_DRI_DRIVER) |
| 626 |
SecondaryColorFuncs[0] = _gloffset_SecondaryColor3bvEXT; |
| 627 |
SecondaryColorFuncs[1] = _gloffset_SecondaryColor3ubvEXT; |
| 628 |
SecondaryColorFuncs[2] = _gloffset_SecondaryColor3svEXT; |
| 629 |
SecondaryColorFuncs[3] = _gloffset_SecondaryColor3usvEXT; |
| 630 |
SecondaryColorFuncs[4] = _gloffset_SecondaryColor3ivEXT; |
| 631 |
SecondaryColorFuncs[5] = _gloffset_SecondaryColor3uivEXT; |
| 632 |
SecondaryColorFuncs[6] = _gloffset_SecondaryColor3fvEXT; |
| 633 |
SecondaryColorFuncs[7] = _gloffset_SecondaryColor3dvEXT; |
| 634 |
|
| 635 |
FogCoordFuncs[6] = _gloffset_FogCoordfvEXT; |
| 636 |
FogCoordFuncs[7] = _gloffset_FogCoorddvEXT; |
| 637 |
#endif |
| 638 |
|
| 639 |
ctx->aelt_context = MALLOC( sizeof(AEcontext) ); |
| 640 |
if (!ctx->aelt_context) |
| 641 |
return GL_FALSE; |
| 642 |
|
| 643 |
AE_CONTEXT(ctx)->NewState = ~0; |
| 644 |
return GL_TRUE; |
| 645 |
} |
| 646 |
|
| 647 |
|
| 648 |
void _ae_destroy_context( GLcontext *ctx ) |
| 649 |
{ |
| 650 |
if ( AE_CONTEXT( ctx ) ) { |
| 651 |
FREE( ctx->aelt_context ); |
| 652 |
ctx->aelt_context = NULL; |
| 653 |
} |
| 654 |
} |
| 655 |
|
| 656 |
|
| 657 |
/** |
| 658 |
* Make a list of per-vertex functions to call for each glArrayElement call. |
| 659 |
* These functions access the array data (i.e. glVertex, glColor, glNormal, |
| 660 |
* etc). |
| 661 |
* Note: this may be called during display list construction. |
| 662 |
*/ |
| 663 |
static void _ae_update_state( GLcontext *ctx ) |
| 664 |
{ |
| 665 |
AEcontext *actx = AE_CONTEXT(ctx); |
| 666 |
AEarray *aa = actx->arrays; |
| 667 |
AEattrib *at = actx->attribs; |
| 668 |
GLuint i; |
| 669 |
|
| 670 |
/* conventional vertex arrays */ |
| 671 |
if (ctx->Array.Index.Enabled) { |
| 672 |
aa->array = &ctx->Array.Index; |
| 673 |
aa->offset = IndexFuncs[TYPE_IDX(aa->array->Type)]; |
| 674 |
aa++; |
| 675 |
} |
| 676 |
if (ctx->Array.EdgeFlag.Enabled) { |
| 677 |
aa->array = &ctx->Array.EdgeFlag; |
| 678 |
aa->offset = _gloffset_EdgeFlagv; |
| 679 |
aa++; |
| 680 |
} |
| 681 |
if (ctx->Array.Normal.Enabled) { |
| 682 |
aa->array = &ctx->Array.Normal; |
| 683 |
aa->offset = NormalFuncs[TYPE_IDX(aa->array->Type)]; |
| 684 |
aa++; |
| 685 |
} |
| 686 |
if (ctx->Array.Color.Enabled) { |
| 687 |
aa->array = &ctx->Array.Color; |
| 688 |
aa->offset = ColorFuncs[aa->array->Size-3][TYPE_IDX(aa->array->Type)]; |
| 689 |
aa++; |
| 690 |
} |
| 691 |
if (ctx->Array.SecondaryColor.Enabled) { |
| 692 |
aa->array = &ctx->Array.SecondaryColor; |
| 693 |
aa->offset = SecondaryColorFuncs[TYPE_IDX(aa->array->Type)]; |
| 694 |
aa++; |
| 695 |
} |
| 696 |
if (ctx->Array.FogCoord.Enabled) { |
| 697 |
aa->array = &ctx->Array.FogCoord; |
| 698 |
aa->offset = FogCoordFuncs[TYPE_IDX(aa->array->Type)]; |
| 699 |
aa++; |
| 700 |
} |
| 701 |
for (i = 0; i < ctx->Const.MaxTextureCoordUnits; i++) { |
| 702 |
if (ctx->Array.TexCoord[i].Enabled) { |
| 703 |
/* NOTE: we use generic glVertexAttrib functions here. |
| 704 |
* If we ever de-alias conventional/generic vertex attribs this |
| 705 |
* will have to change. |
| 706 |
*/ |
| 707 |
struct gl_client_array *attribArray = &ctx->Array.TexCoord[i]; |
| 708 |
at->array = attribArray; |
| 709 |
at->func = AttribFuncsNV[at->array->Normalized][at->array->Size-1][TYPE_IDX(at->array->Type)]; |
| 710 |
at->index = VERT_ATTRIB_TEX0 + i; |
| 711 |
at++; |
| 712 |
} |
| 713 |
} |
| 714 |
|
| 715 |
/* generic vertex attribute arrays */ |
| 716 |
for (i = 1; i < VERT_ATTRIB_MAX; i++) { /* skip zero! */ |
| 717 |
if (ctx->Array.VertexAttrib[i].Enabled) { |
| 718 |
struct gl_client_array *attribArray = &ctx->Array.VertexAttrib[i]; |
| 719 |
at->array = attribArray; |
| 720 |
/* Note: we can't grab the _glapi_Dispatch->VertexAttrib1fvNV |
| 721 |
* function pointer here (for float arrays) since the pointer may |
| 722 |
* change from one execution of _ae_loopback_array_elt() to |
| 723 |
* the next. Doing so caused UT to break. |
| 724 |
*/ |
| 725 |
at->func = AttribFuncsNV[at->array->Normalized][at->array->Size-1][TYPE_IDX(at->array->Type)]; |
| 726 |
at->index = i; |
| 727 |
at++; |
| 728 |
} |
| 729 |
} |
| 730 |
|
| 731 |
/* finally, vertex position */ |
| 732 |
if (ctx->Array.VertexAttrib[0].Enabled) { |
| 733 |
/* Use glVertex(v) instead of glVertexAttrib(0, v) to be sure it's |
| 734 |
* issued as the last (proviking) attribute). |
| 735 |
*/ |
| 736 |
aa->array = &ctx->Array.VertexAttrib[0]; |
| 737 |
assert(aa->array->Size >= 2); /* XXX fix someday? */ |
| 738 |
aa->offset = VertexFuncs[aa->array->Size-2][TYPE_IDX(aa->array->Type)]; |
| 739 |
aa++; |
| 740 |
} |
| 741 |
else if (ctx->Array.Vertex.Enabled) { |
| 742 |
aa->array = &ctx->Array.Vertex; |
| 743 |
aa->offset = VertexFuncs[aa->array->Size-2][TYPE_IDX(aa->array->Type)]; |
| 744 |
aa++; |
| 745 |
} |
| 746 |
|
| 747 |
ASSERT(at - actx->attribs <= VERT_ATTRIB_MAX); |
| 748 |
ASSERT(aa - actx->arrays < 32); |
| 749 |
at->func = NULL; /* terminate the list */ |
| 750 |
aa->offset = -1; /* terminate the list */ |
| 751 |
|
| 752 |
actx->NewState = 0; |
| 753 |
} |
| 754 |
|
| 755 |
|
| 756 |
/** |
| 757 |
* Called via glArrayElement() and glDrawArrays(). |
| 758 |
* Issue the glNormal, glVertex, glColor, glVertexAttrib, etc functions |
| 759 |
* for all enabled vertex arrays (for elt-th element). |
| 760 |
* Note: this may be called during display list construction. |
| 761 |
*/ |
| 762 |
void GLAPIENTRY _ae_loopback_array_elt( GLint elt ) |
| 763 |
{ |
| 764 |
GET_CURRENT_CONTEXT(ctx); |
| 765 |
const AEcontext *actx = AE_CONTEXT(ctx); |
| 766 |
const AEarray *aa; |
| 767 |
const AEattrib *at; |
| 768 |
const struct _glapi_table * const disp = GET_DISPATCH(); |
| 769 |
|
| 770 |
|
| 771 |
if (actx->NewState) |
| 772 |
_ae_update_state( ctx ); |
| 773 |
|
| 774 |
/* generic attributes */ |
| 775 |
for (at = actx->attribs; at->func; at++) { |
| 776 |
const GLubyte *src |
| 777 |
= ADD_POINTERS(at->array->BufferObj->Data, at->array->Ptr) |
| 778 |
+ elt * at->array->StrideB; |
| 779 |
at->func( at->index, src ); |
| 780 |
} |
| 781 |
|
| 782 |
/* conventional arrays */ |
| 783 |
for (aa = actx->arrays; aa->offset != -1 ; aa++) { |
| 784 |
const GLubyte *src |
| 785 |
= ADD_POINTERS(aa->array->BufferObj->Data, aa->array->Ptr) |
| 786 |
+ elt * aa->array->StrideB; |
| 787 |
CALL_by_offset( disp, (array_func), aa->offset, |
| 788 |
((const void *) src) ); |
| 789 |
} |
| 790 |
} |
| 791 |
|
| 792 |
|
| 793 |
void _ae_invalidate_state( GLcontext *ctx, GLuint new_state ) |
| 794 |
{ |
| 795 |
AE_CONTEXT(ctx)->NewState |= new_state; |
| 796 |
} |