~ubuntu-branches/ubuntu/quantal/mesa-glw/quantal

« back to all changes in this revision

Viewing changes to src/mesa/vbo/vbo_attrib_tmp.h

  • Committer: Bazaar Package Importer
  • Author(s): Morten Kjeldgaard
  • Date: 2008-05-06 16:19:15 UTC
  • Revision ID: james.westby@ubuntu.com-20080506161915-uynz7nftmfixu6bq
Tags: upstream-7.0.3
ImportĀ upstreamĀ versionĀ 7.0.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**************************************************************************
 
2
 
 
3
Copyright 2002 Tungsten Graphics Inc., Cedar Park, Texas.
 
4
 
 
5
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
on the rights to use, copy, modify, merge, publish, distribute, sub
 
11
license, and/or sell copies of the Software, and to permit persons to whom
 
12
the Software is furnished to do so, subject to the following conditions:
 
13
 
 
14
The above copyright notice and this permission notice (including the next
 
15
paragraph) shall be included in all copies or substantial portions of the
 
16
Software.
 
17
 
 
18
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 
19
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 
20
FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
 
21
TUNGSTEN GRAPHICS AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
 
22
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
 
23
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
 
24
USE OR OTHER DEALINGS IN THE SOFTWARE.
 
25
 
 
26
**************************************************************************/
 
27
 
 
28
#define ATTR1FV( A, V ) ATTR( A, 1, (V)[0], 0, 0, 1 )
 
29
#define ATTR2FV( A, V ) ATTR( A, 2, (V)[0], (V)[1], 0, 1 )
 
30
#define ATTR3FV( A, V ) ATTR( A, 3, (V)[0], (V)[1], (V)[2], 1 )
 
31
#define ATTR4FV( A, V ) ATTR( A, 4, (V)[0], (V)[1], (V)[2], (V)[3] )
 
32
 
 
33
#define ATTR1F( A, X )          ATTR( A, 1, X, 0, 0, 1 )
 
34
#define ATTR2F( A, X, Y )       ATTR( A, 2, X, Y, 0, 1 )
 
35
#define ATTR3F( A, X, Y, Z )    ATTR( A, 3, X, Y, Z, 1 )
 
36
#define ATTR4F( A, X, Y, Z, W ) ATTR( A, 4, X, Y, Z, W )
 
37
 
 
38
#define MAT_ATTR( A, N, V ) ATTR( A, N, (V)[0], (V)[1], (V)[2], (V)[3] )
 
39
 
 
40
static void GLAPIENTRY TAG(Vertex2f)( GLfloat x, GLfloat y )
 
41
{
 
42
   GET_CURRENT_CONTEXT( ctx );
 
43
   ATTR2F( VBO_ATTRIB_POS, x, y );
 
44
}
 
45
 
 
46
static void GLAPIENTRY TAG(Vertex2fv)( const GLfloat *v )
 
47
{
 
48
   GET_CURRENT_CONTEXT( ctx );
 
49
   ATTR2FV( VBO_ATTRIB_POS, v );
 
50
}
 
51
 
 
52
static void GLAPIENTRY TAG(Vertex3f)( GLfloat x, GLfloat y, GLfloat z )
 
53
{
 
54
   GET_CURRENT_CONTEXT( ctx );
 
55
   ATTR3F( VBO_ATTRIB_POS, x, y, z );
 
56
}
 
57
 
 
58
static void GLAPIENTRY TAG(Vertex3fv)( const GLfloat *v )
 
59
{
 
60
   GET_CURRENT_CONTEXT( ctx );
 
61
   ATTR3FV( VBO_ATTRIB_POS, v );
 
62
}
 
63
 
 
64
static void GLAPIENTRY TAG(Vertex4f)( GLfloat x, GLfloat y, GLfloat z, GLfloat w )
 
65
{
 
66
   GET_CURRENT_CONTEXT( ctx );
 
67
   ATTR4F( VBO_ATTRIB_POS, x, y, z, w );
 
68
}
 
69
 
 
70
static void GLAPIENTRY TAG(Vertex4fv)( const GLfloat *v )
 
71
{
 
72
   GET_CURRENT_CONTEXT( ctx );
 
73
   ATTR4FV( VBO_ATTRIB_POS, v );
 
74
}
 
75
 
 
76
static void GLAPIENTRY TAG(TexCoord1f)( GLfloat x )
 
77
{
 
78
   GET_CURRENT_CONTEXT( ctx );
 
79
   ATTR1F( VBO_ATTRIB_TEX0, x );
 
80
}
 
81
 
 
82
static void GLAPIENTRY TAG(TexCoord1fv)( const GLfloat *v )
 
83
{
 
84
   GET_CURRENT_CONTEXT( ctx );
 
85
   ATTR1FV( VBO_ATTRIB_TEX0, v );
 
86
}
 
87
 
 
88
static void GLAPIENTRY TAG(TexCoord2f)( GLfloat x, GLfloat y )
 
89
{
 
90
   GET_CURRENT_CONTEXT( ctx );
 
91
   ATTR2F( VBO_ATTRIB_TEX0, x, y );
 
92
}
 
93
 
 
94
static void GLAPIENTRY TAG(TexCoord2fv)( const GLfloat *v )
 
95
{
 
96
   GET_CURRENT_CONTEXT( ctx );
 
97
   ATTR2FV( VBO_ATTRIB_TEX0, v );
 
98
}
 
99
 
 
100
static void GLAPIENTRY TAG(TexCoord3f)( GLfloat x, GLfloat y, GLfloat z )
 
101
{
 
102
   GET_CURRENT_CONTEXT( ctx );
 
103
   ATTR3F( VBO_ATTRIB_TEX0, x, y, z );
 
104
}
 
105
 
 
106
static void GLAPIENTRY TAG(TexCoord3fv)( const GLfloat *v )
 
107
{
 
108
   GET_CURRENT_CONTEXT( ctx );
 
109
   ATTR3FV( VBO_ATTRIB_TEX0, v );
 
110
}
 
111
 
 
112
static void GLAPIENTRY TAG(TexCoord4f)( GLfloat x, GLfloat y, GLfloat z, GLfloat w )
 
113
{
 
114
   GET_CURRENT_CONTEXT( ctx );
 
115
   ATTR4F( VBO_ATTRIB_TEX0, x, y, z, w );
 
116
}
 
117
 
 
118
static void GLAPIENTRY TAG(TexCoord4fv)( const GLfloat *v )
 
119
{
 
120
   GET_CURRENT_CONTEXT( ctx );
 
121
   ATTR4FV( VBO_ATTRIB_TEX0, v );
 
122
}
 
123
 
 
124
static void GLAPIENTRY TAG(Normal3f)( GLfloat x, GLfloat y, GLfloat z )
 
125
{
 
126
   GET_CURRENT_CONTEXT( ctx );
 
127
   ATTR3F( VBO_ATTRIB_NORMAL, x, y, z );
 
128
}
 
129
 
 
130
static void GLAPIENTRY TAG(Normal3fv)( const GLfloat *v )
 
131
{
 
132
   GET_CURRENT_CONTEXT( ctx );
 
133
   ATTR3FV( VBO_ATTRIB_NORMAL, v );
 
134
}
 
135
 
 
136
static void GLAPIENTRY TAG(FogCoordfEXT)( GLfloat x )
 
137
{
 
138
   GET_CURRENT_CONTEXT( ctx );
 
139
   ATTR1F( VBO_ATTRIB_FOG, x );
 
140
}
 
141
 
 
142
static void GLAPIENTRY TAG(FogCoordfvEXT)( const GLfloat *v )
 
143
{
 
144
   GET_CURRENT_CONTEXT( ctx );
 
145
   ATTR1FV( VBO_ATTRIB_FOG, v );
 
146
}
 
147
 
 
148
static void GLAPIENTRY TAG(Color3f)( GLfloat x, GLfloat y, GLfloat z )
 
149
{
 
150
   GET_CURRENT_CONTEXT( ctx );
 
151
   ATTR3F( VBO_ATTRIB_COLOR0, x, y, z );
 
152
}
 
153
 
 
154
static void GLAPIENTRY TAG(Color3fv)( const GLfloat *v )
 
155
{
 
156
   GET_CURRENT_CONTEXT( ctx );
 
157
   ATTR3FV( VBO_ATTRIB_COLOR0, v );
 
158
}
 
159
 
 
160
static void GLAPIENTRY TAG(Color4f)( GLfloat x, GLfloat y, GLfloat z, GLfloat w )
 
161
{
 
162
   GET_CURRENT_CONTEXT( ctx );
 
163
   ATTR4F( VBO_ATTRIB_COLOR0, x, y, z, w );
 
164
}
 
165
 
 
166
static void GLAPIENTRY TAG(Color4fv)( const GLfloat *v )
 
167
{
 
168
   GET_CURRENT_CONTEXT( ctx );
 
169
   ATTR4FV( VBO_ATTRIB_COLOR0, v );
 
170
}
 
171
 
 
172
static void GLAPIENTRY TAG(SecondaryColor3fEXT)( GLfloat x, GLfloat y, GLfloat z )
 
173
{
 
174
   GET_CURRENT_CONTEXT( ctx );
 
175
   ATTR3F( VBO_ATTRIB_COLOR1, x, y, z );
 
176
}
 
177
 
 
178
static void GLAPIENTRY TAG(SecondaryColor3fvEXT)( const GLfloat *v )
 
179
{
 
180
   GET_CURRENT_CONTEXT( ctx );
 
181
   ATTR3FV( VBO_ATTRIB_COLOR1, v );
 
182
}
 
183
 
 
184
 
 
185
static void GLAPIENTRY TAG(EdgeFlag)( GLboolean b )
 
186
{
 
187
   GET_CURRENT_CONTEXT( ctx );
 
188
   ATTR1F( VBO_ATTRIB_EDGEFLAG, (GLfloat)b );
 
189
}
 
190
 
 
191
static void GLAPIENTRY TAG(Indexf)( GLfloat f )
 
192
{
 
193
   GET_CURRENT_CONTEXT( ctx );
 
194
   ATTR1F( VBO_ATTRIB_INDEX, f );
 
195
}
 
196
 
 
197
static void GLAPIENTRY TAG(Indexfv)( const GLfloat *f )
 
198
{
 
199
   GET_CURRENT_CONTEXT( ctx );
 
200
   ATTR1FV( VBO_ATTRIB_INDEX, f );
 
201
}
 
202
 
 
203
 
 
204
static void GLAPIENTRY TAG(MultiTexCoord1f)( GLenum target, GLfloat x  )
 
205
{
 
206
   GET_CURRENT_CONTEXT( ctx );
 
207
   GLuint attr = (target & 0x7) + VBO_ATTRIB_TEX0;
 
208
   ATTR1F( attr, x );
 
209
}
 
210
 
 
211
static void GLAPIENTRY TAG(MultiTexCoord1fv)( GLenum target, const GLfloat *v )
 
212
{
 
213
   GET_CURRENT_CONTEXT( ctx );
 
214
   GLuint attr = (target & 0x7) + VBO_ATTRIB_TEX0;
 
215
   ATTR1FV( attr, v );
 
216
}
 
217
 
 
218
static void GLAPIENTRY TAG(MultiTexCoord2f)( GLenum target, GLfloat x, GLfloat y )
 
219
{
 
220
   GET_CURRENT_CONTEXT( ctx );
 
221
   GLuint attr = (target & 0x7) + VBO_ATTRIB_TEX0;
 
222
   ATTR2F( attr, x, y );
 
223
}
 
224
 
 
225
static void GLAPIENTRY TAG(MultiTexCoord2fv)( GLenum target, const GLfloat *v )
 
226
{
 
227
   GET_CURRENT_CONTEXT( ctx );
 
228
   GLuint attr = (target & 0x7) + VBO_ATTRIB_TEX0;
 
229
   ATTR2FV( attr, v );
 
230
}
 
231
 
 
232
static void GLAPIENTRY TAG(MultiTexCoord3f)( GLenum target, GLfloat x, GLfloat y,
 
233
                                    GLfloat z)
 
234
{
 
235
   GET_CURRENT_CONTEXT( ctx );
 
236
   GLuint attr = (target & 0x7) + VBO_ATTRIB_TEX0;
 
237
   ATTR3F( attr, x, y, z );
 
238
}
 
239
 
 
240
static void GLAPIENTRY TAG(MultiTexCoord3fv)( GLenum target, const GLfloat *v )
 
241
{
 
242
   GET_CURRENT_CONTEXT( ctx );
 
243
   GLuint attr = (target & 0x7) + VBO_ATTRIB_TEX0;
 
244
   ATTR3FV( attr, v );
 
245
}
 
246
 
 
247
static void GLAPIENTRY TAG(MultiTexCoord4f)( GLenum target, GLfloat x, GLfloat y,
 
248
                                    GLfloat z, GLfloat w )
 
249
{
 
250
   GET_CURRENT_CONTEXT( ctx );
 
251
   GLuint attr = (target & 0x7) + VBO_ATTRIB_TEX0;
 
252
   ATTR4F( attr, x, y, z, w );
 
253
}
 
254
 
 
255
static void GLAPIENTRY TAG(MultiTexCoord4fv)( GLenum target, const GLfloat *v )
 
256
{
 
257
   GET_CURRENT_CONTEXT( ctx );
 
258
   GLuint attr = (target & 0x7) + VBO_ATTRIB_TEX0;
 
259
   ATTR4FV( attr, v );
 
260
}
 
261
 
 
262
 
 
263
static void GLAPIENTRY TAG(VertexAttrib1fARB)( GLuint index, GLfloat x )
 
264
{
 
265
   GET_CURRENT_CONTEXT( ctx );
 
266
   if (index == 0) 
 
267
      ATTR1F(0, x);
 
268
   else if (index < MAX_VERTEX_ATTRIBS)
 
269
      ATTR1F(VBO_ATTRIB_GENERIC0 + index, x);
 
270
   else
 
271
      ERROR();
 
272
}
 
273
 
 
274
static void GLAPIENTRY TAG(VertexAttrib1fvARB)( GLuint index, 
 
275
                                               const GLfloat *v )
 
276
{
 
277
   GET_CURRENT_CONTEXT( ctx );
 
278
   if (index == 0) 
 
279
      ATTR1FV(0, v);
 
280
   else if (index < MAX_VERTEX_ATTRIBS)
 
281
      ATTR1FV(VBO_ATTRIB_GENERIC0 + index, v);
 
282
   else
 
283
      ERROR();
 
284
}
 
285
 
 
286
static void GLAPIENTRY TAG(VertexAttrib2fARB)( GLuint index, GLfloat x, 
 
287
                                              GLfloat y )
 
288
{
 
289
   GET_CURRENT_CONTEXT( ctx );
 
290
   if (index == 0) 
 
291
      ATTR2F(0, x, y);
 
292
   else if (index < MAX_VERTEX_ATTRIBS)
 
293
      ATTR2F(VBO_ATTRIB_GENERIC0 + index, x, y);
 
294
   else
 
295
      ERROR();
 
296
}
 
297
 
 
298
static void GLAPIENTRY TAG(VertexAttrib2fvARB)( GLuint index,
 
299
                                               const GLfloat *v )
 
300
{
 
301
   GET_CURRENT_CONTEXT( ctx );
 
302
   if (index == 0) 
 
303
      ATTR2FV(0, v);
 
304
   else if (index < MAX_VERTEX_ATTRIBS)
 
305
      ATTR2FV(VBO_ATTRIB_GENERIC0 + index, v);
 
306
   else
 
307
      ERROR();
 
308
}
 
309
 
 
310
static void GLAPIENTRY TAG(VertexAttrib3fARB)( GLuint index, GLfloat x,
 
311
                                              GLfloat y, GLfloat z )
 
312
{
 
313
   GET_CURRENT_CONTEXT( ctx );
 
314
   if (index == 0) 
 
315
      ATTR3F(0, x, y, z);
 
316
   else if (index < MAX_VERTEX_ATTRIBS)
 
317
      ATTR3F(VBO_ATTRIB_GENERIC0 + index, x, y, z);
 
318
   else
 
319
      ERROR();
 
320
}
 
321
 
 
322
static void GLAPIENTRY TAG(VertexAttrib3fvARB)( GLuint index,
 
323
                                               const GLfloat *v )
 
324
{
 
325
   GET_CURRENT_CONTEXT( ctx );
 
326
   if (index == 0) 
 
327
      ATTR3FV(0, v);
 
328
   else if (index < MAX_VERTEX_ATTRIBS)
 
329
      ATTR3FV(VBO_ATTRIB_GENERIC0 + index, v);
 
330
   else
 
331
      ERROR();
 
332
}
 
333
 
 
334
static void GLAPIENTRY TAG(VertexAttrib4fARB)( GLuint index, GLfloat x,
 
335
                                              GLfloat y, GLfloat z,
 
336
                                              GLfloat w )
 
337
{
 
338
   GET_CURRENT_CONTEXT( ctx );
 
339
   if (index == 0) 
 
340
      ATTR4F(0, x, y, z, w);
 
341
   else if (index < MAX_VERTEX_ATTRIBS)
 
342
      ATTR4F(VBO_ATTRIB_GENERIC0 + index, x, y, z, w);
 
343
   else
 
344
      ERROR();
 
345
}
 
346
 
 
347
static void GLAPIENTRY TAG(VertexAttrib4fvARB)( GLuint index, 
 
348
                                               const GLfloat *v )
 
349
{
 
350
   GET_CURRENT_CONTEXT( ctx );
 
351
   if (index == 0) 
 
352
      ATTR4FV(0, v);
 
353
   else if (index < MAX_VERTEX_ATTRIBS)
 
354
      ATTR4FV(VBO_ATTRIB_GENERIC0 + index, v);
 
355
   else
 
356
      ERROR();
 
357
}
 
358
 
 
359
 
 
360
/* In addition to supporting NV_vertex_program, these entrypoints are
 
361
 * used by the display list and other code specifically because of
 
362
 * their property of aliasing with other attributes.  (See
 
363
 * vbo_save_loopback.c)
 
364
 */
 
365
static void GLAPIENTRY TAG(VertexAttrib1fNV)( GLuint index, GLfloat x )
 
366
{
 
367
   GET_CURRENT_CONTEXT( ctx );
 
368
   if (index < VBO_ATTRIB_MAX)
 
369
      ATTR1F(index, x);
 
370
}
 
371
 
 
372
static void GLAPIENTRY TAG(VertexAttrib1fvNV)( GLuint index, 
 
373
                                               const GLfloat *v )
 
374
{
 
375
   GET_CURRENT_CONTEXT( ctx );
 
376
   if (index < VBO_ATTRIB_MAX) 
 
377
      ATTR1FV(index, v);
 
378
}
 
379
 
 
380
static void GLAPIENTRY TAG(VertexAttrib2fNV)( GLuint index, GLfloat x, 
 
381
                                              GLfloat y )
 
382
{
 
383
   GET_CURRENT_CONTEXT( ctx );
 
384
   if (index < VBO_ATTRIB_MAX) 
 
385
      ATTR2F(index, x, y);
 
386
}
 
387
 
 
388
static void GLAPIENTRY TAG(VertexAttrib2fvNV)( GLuint index,
 
389
                                               const GLfloat *v )
 
390
{
 
391
   GET_CURRENT_CONTEXT( ctx );
 
392
   if (index < VBO_ATTRIB_MAX) 
 
393
      ATTR2FV(index, v);
 
394
}
 
395
 
 
396
static void GLAPIENTRY TAG(VertexAttrib3fNV)( GLuint index, GLfloat x,
 
397
                                              GLfloat y, GLfloat z )
 
398
{
 
399
   GET_CURRENT_CONTEXT( ctx );
 
400
   if (index < VBO_ATTRIB_MAX) 
 
401
      ATTR3F(index, x, y, z);
 
402
}
 
403
 
 
404
static void GLAPIENTRY TAG(VertexAttrib3fvNV)( GLuint index,
 
405
                                               const GLfloat *v )
 
406
{
 
407
   GET_CURRENT_CONTEXT( ctx );
 
408
   if (index < VBO_ATTRIB_MAX) 
 
409
      ATTR3FV(index, v);
 
410
}
 
411
 
 
412
static void GLAPIENTRY TAG(VertexAttrib4fNV)( GLuint index, GLfloat x,
 
413
                                              GLfloat y, GLfloat z,
 
414
                                              GLfloat w )
 
415
{
 
416
   GET_CURRENT_CONTEXT( ctx );
 
417
   if (index < VBO_ATTRIB_MAX) 
 
418
      ATTR4F(index, x, y, z, w);
 
419
}
 
420
 
 
421
static void GLAPIENTRY TAG(VertexAttrib4fvNV)( GLuint index, 
 
422
                                               const GLfloat *v )
 
423
{
 
424
   GET_CURRENT_CONTEXT( ctx );
 
425
   if (index < VBO_ATTRIB_MAX) 
 
426
      ATTR4FV(index, v);
 
427
}
 
428
 
 
429
 
 
430
#define MAT( ATTR, N, face, params )                    \
 
431
do {                                                    \
 
432
   if (face != GL_BACK)                                 \
 
433
      MAT_ATTR( ATTR, N, params ); /* front */          \
 
434
   if (face != GL_FRONT)                                \
 
435
      MAT_ATTR( ATTR + 1, N, params ); /* back */       \
 
436
} while (0)
 
437
 
 
438
 
 
439
/* Colormaterial conflicts are dealt with later.
 
440
 */
 
441
static void GLAPIENTRY TAG(Materialfv)( GLenum face, GLenum pname, 
 
442
                               const GLfloat *params )
 
443
{
 
444
   GET_CURRENT_CONTEXT( ctx );
 
445
   switch (pname) {
 
446
   case GL_EMISSION:
 
447
      MAT( VBO_ATTRIB_MAT_FRONT_EMISSION, 4, face, params );
 
448
      break;
 
449
   case GL_AMBIENT:
 
450
      MAT( VBO_ATTRIB_MAT_FRONT_AMBIENT, 4, face, params );
 
451
      break;
 
452
   case GL_DIFFUSE:
 
453
      MAT( VBO_ATTRIB_MAT_FRONT_DIFFUSE, 4, face, params );
 
454
      break;
 
455
   case GL_SPECULAR:
 
456
      MAT( VBO_ATTRIB_MAT_FRONT_SPECULAR, 4, face, params );
 
457
      break;
 
458
   case GL_SHININESS:
 
459
      MAT( VBO_ATTRIB_MAT_FRONT_SHININESS, 1, face, params );
 
460
      break;
 
461
   case GL_COLOR_INDEXES:
 
462
      MAT( VBO_ATTRIB_MAT_FRONT_INDEXES, 3, face, params );
 
463
      break;
 
464
   case GL_AMBIENT_AND_DIFFUSE:
 
465
      MAT( VBO_ATTRIB_MAT_FRONT_AMBIENT, 4, face, params );
 
466
      MAT( VBO_ATTRIB_MAT_FRONT_DIFFUSE, 4, face, params );
 
467
      break;
 
468
   default:
 
469
      ERROR();
 
470
      return;
 
471
   }
 
472
}
 
473
 
 
474
 
 
475
#undef ATTR1FV
 
476
#undef ATTR2FV
 
477
#undef ATTR3FV
 
478
#undef ATTR4FV
 
479
 
 
480
#undef ATTR1F
 
481
#undef ATTR2F
 
482
#undef ATTR3F
 
483
#undef ATTR4F
 
484
 
 
485
#undef MAT
 
486
#undef MAT_ATTR