Tizen 2.0 Release
[profile/ivi/osmesa.git] / src / mesa / main / api_noop.c
1 /*
2  * Mesa 3-D graphics library
3  * Version:  6.5.1
4  *
5  * Copyright (C) 1999-2006  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
26 #include "glheader.h"
27 #include "api_noop.h"
28 #include "api_validate.h"
29 #include "api_arrayelt.h"
30 #include "context.h"
31 #include "light.h"
32 #include "macros.h"
33 #include "mfeatures.h"
34 #include "dlist.h"
35 #include "eval.h"
36 #include "main/dispatch.h"
37
38
39 /**
40  * \file
41  * Just update the ctx->Current vertex attributes.
42  * These functions are used when outside glBegin/glEnd or outside display
43  * lists.
44  */
45
46
47 #if FEATURE_beginend
48
49
50 static void GLAPIENTRY _mesa_noop_EdgeFlag( GLboolean b )
51 {
52    GET_CURRENT_CONTEXT(ctx);
53    ctx->Current.Attrib[VERT_ATTRIB_EDGEFLAG][0] = (GLfloat)b;
54 }
55
56 static void GLAPIENTRY _mesa_noop_Indexf( GLfloat f )
57 {
58    GET_CURRENT_CONTEXT(ctx);
59    ctx->Current.Attrib[VERT_ATTRIB_COLOR_INDEX][0] = f;
60 }
61
62 static void GLAPIENTRY _mesa_noop_Indexfv( const GLfloat *v )
63 {
64    GET_CURRENT_CONTEXT(ctx);
65    ctx->Current.Attrib[VERT_ATTRIB_COLOR_INDEX][0] = *v;
66 }
67
68 static void GLAPIENTRY _mesa_noop_FogCoordfEXT( GLfloat a )
69 {
70    GET_CURRENT_CONTEXT(ctx);
71    GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_FOG];
72    dest[0] = a;
73    dest[1] = 0.0;
74    dest[2] = 0.0;
75    dest[3] = 1.0;
76 }
77
78 static void GLAPIENTRY _mesa_noop_FogCoordfvEXT( const GLfloat *v )
79 {
80    GET_CURRENT_CONTEXT(ctx);
81    GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_FOG];
82    dest[0] = v[0];
83    dest[1] = 0.0;
84    dest[2] = 0.0;
85    dest[3] = 1.0;
86 }
87
88 static void GLAPIENTRY _mesa_noop_Normal3f( GLfloat a, GLfloat b, GLfloat c )
89 {
90    GET_CURRENT_CONTEXT(ctx);
91    GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_NORMAL];
92    dest[0] = a;
93    dest[1] = b;
94    dest[2] = c;
95    dest[3] = 1.0;
96 }
97
98 static void GLAPIENTRY _mesa_noop_Normal3fv( const GLfloat *v )
99 {
100    GET_CURRENT_CONTEXT(ctx);
101    GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_NORMAL];
102    dest[0] = v[0];
103    dest[1] = v[1];
104    dest[2] = v[2];
105    dest[3] = 1.0;
106 }
107
108 static void GLAPIENTRY _mesa_noop_Color4f( GLfloat a, GLfloat b, GLfloat c, GLfloat d )
109 {
110    GET_CURRENT_CONTEXT(ctx);
111    GLfloat *color = ctx->Current.Attrib[VERT_ATTRIB_COLOR0];
112    color[0] = a;
113    color[1] = b;
114    color[2] = c;
115    color[3] = d;
116 }
117
118 static void GLAPIENTRY _mesa_noop_Color4fv( const GLfloat *v )
119 {
120    GET_CURRENT_CONTEXT(ctx);
121    GLfloat *color = ctx->Current.Attrib[VERT_ATTRIB_COLOR0];
122    color[0] = v[0];
123    color[1] = v[1];
124    color[2] = v[2];
125    color[3] = v[3];
126 }
127
128 static void GLAPIENTRY _mesa_noop_Color3f( GLfloat a, GLfloat b, GLfloat c )
129 {
130    GET_CURRENT_CONTEXT(ctx);
131    GLfloat *color = ctx->Current.Attrib[VERT_ATTRIB_COLOR0];
132    color[0] = a;
133    color[1] = b;
134    color[2] = c;
135    color[3] = 1.0;
136 }
137
138 static void GLAPIENTRY _mesa_noop_Color3fv( const GLfloat *v )
139 {
140    GET_CURRENT_CONTEXT(ctx);
141    GLfloat *color = ctx->Current.Attrib[VERT_ATTRIB_COLOR0];
142    color[0] = v[0];
143    color[1] = v[1];
144    color[2] = v[2];
145    color[3] = 1.0;
146 }
147
148 static void GLAPIENTRY _mesa_noop_MultiTexCoord1fARB( GLenum target, GLfloat a )
149 {
150    GET_CURRENT_CONTEXT(ctx);
151    GLuint unit = target - GL_TEXTURE0_ARB;
152
153    /* unit is unsigned -- cannot be less than zero.
154     */
155    if (unit < MAX_TEXTURE_COORD_UNITS)
156    {
157       GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit];
158       dest[0] = a;
159       dest[1] = 0;
160       dest[2] = 0;
161       dest[3] = 1;
162    }
163 }
164
165 static void GLAPIENTRY _mesa_noop_MultiTexCoord1fvARB( GLenum target, const GLfloat *v )
166 {
167    GET_CURRENT_CONTEXT(ctx);
168    GLuint unit = target - GL_TEXTURE0_ARB;
169
170    /* unit is unsigned -- cannot be less than zero.
171     */
172    if (unit < MAX_TEXTURE_COORD_UNITS)
173    {
174       GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit];
175       dest[0] = v[0];
176       dest[1] = 0;
177       dest[2] = 0;
178       dest[3] = 1;
179    }
180 }
181
182 static void GLAPIENTRY _mesa_noop_MultiTexCoord2fARB( GLenum target, GLfloat a, GLfloat b )
183 {
184    GET_CURRENT_CONTEXT(ctx);
185    GLuint unit = target - GL_TEXTURE0_ARB;
186
187    /* unit is unsigned -- cannot be less than zero.
188     */
189    if (unit < MAX_TEXTURE_COORD_UNITS)
190    {
191       GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit];
192       dest[0] = a;
193       dest[1] = b;
194       dest[2] = 0;
195       dest[3] = 1;
196    }
197 }
198
199 static void GLAPIENTRY _mesa_noop_MultiTexCoord2fvARB( GLenum target, const GLfloat *v )
200 {
201    GET_CURRENT_CONTEXT(ctx);
202    GLuint unit = target - GL_TEXTURE0_ARB;
203
204    /* unit is unsigned -- cannot be less than zero.
205     */
206    if (unit < MAX_TEXTURE_COORD_UNITS)
207    {
208       GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit];
209       dest[0] = v[0];
210       dest[1] = v[1];
211       dest[2] = 0;
212       dest[3] = 1;
213    }
214 }
215
216 static void GLAPIENTRY _mesa_noop_MultiTexCoord3fARB( GLenum target, GLfloat a, GLfloat b, GLfloat c)
217 {
218    GET_CURRENT_CONTEXT(ctx);
219    GLuint unit = target - GL_TEXTURE0_ARB;
220
221    /* unit is unsigned -- cannot be less than zero.
222     */
223    if (unit < MAX_TEXTURE_COORD_UNITS)
224    {
225       GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit];
226       dest[0] = a;
227       dest[1] = b;
228       dest[2] = c;
229       dest[3] = 1;
230    }
231 }
232
233 static void GLAPIENTRY _mesa_noop_MultiTexCoord3fvARB( GLenum target, const GLfloat *v )
234 {
235    GET_CURRENT_CONTEXT(ctx);
236    GLuint unit = target - GL_TEXTURE0_ARB;
237
238    /* unit is unsigned -- cannot be less than zero.
239     */
240    if (unit < MAX_TEXTURE_COORD_UNITS)
241    {
242       GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit];
243       dest[0] = v[0];
244       dest[1] = v[1];
245       dest[2] = v[2];
246       dest[3] = 1;
247    }
248 }
249
250 static void GLAPIENTRY _mesa_noop_MultiTexCoord4fARB( GLenum target, GLfloat a, GLfloat b,
251                               GLfloat c, GLfloat d )
252 {
253    GET_CURRENT_CONTEXT(ctx);
254    GLuint unit = target - GL_TEXTURE0_ARB;
255
256    /* unit is unsigned -- cannot be less than zero.
257     */
258    if (unit < MAX_TEXTURE_COORD_UNITS)
259    {
260       GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit];
261       dest[0] = a;
262       dest[1] = b;
263       dest[2] = c;
264       dest[3] = d;
265    }
266 }
267
268 static void GLAPIENTRY _mesa_noop_MultiTexCoord4fvARB( GLenum target, const GLfloat *v )
269 {
270    GET_CURRENT_CONTEXT(ctx);
271    GLuint unit = target - GL_TEXTURE0_ARB;
272
273    /* unit is unsigned -- cannot be less than zero.
274     */
275    if (unit < MAX_TEXTURE_COORD_UNITS)
276    {
277       GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit];
278       dest[0] = v[0];
279       dest[1] = v[1];
280       dest[2] = v[2];
281       dest[3] = v[3];
282    }
283 }
284
285 static void GLAPIENTRY _mesa_noop_SecondaryColor3fEXT( GLfloat a, GLfloat b, GLfloat c )
286 {
287    GET_CURRENT_CONTEXT(ctx);
288    GLfloat *color = ctx->Current.Attrib[VERT_ATTRIB_COLOR1];
289    color[0] = a;
290    color[1] = b;
291    color[2] = c;
292    color[3] = 1.0;
293 }
294
295 static void GLAPIENTRY _mesa_noop_SecondaryColor3fvEXT( const GLfloat *v )
296 {
297    GET_CURRENT_CONTEXT(ctx);
298    GLfloat *color = ctx->Current.Attrib[VERT_ATTRIB_COLOR1];
299    color[0] = v[0];
300    color[1] = v[1];
301    color[2] = v[2];
302    color[3] = 1.0;
303 }
304
305 static void GLAPIENTRY _mesa_noop_TexCoord1f( GLfloat a )
306 {
307    GET_CURRENT_CONTEXT(ctx);
308    GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_TEX0];
309    dest[0] = a;
310    dest[1] = 0;
311    dest[2] = 0;
312    dest[3] = 1;
313 }
314
315 static void GLAPIENTRY _mesa_noop_TexCoord1fv( const GLfloat *v )
316 {
317    GET_CURRENT_CONTEXT(ctx);
318    GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_TEX0];
319    dest[0] = v[0];
320    dest[1] = 0;
321    dest[2] = 0;
322    dest[3] = 1;
323 }
324
325 static void GLAPIENTRY _mesa_noop_TexCoord2f( GLfloat a, GLfloat b )
326 {
327    GET_CURRENT_CONTEXT(ctx);
328    GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_TEX0];
329    dest[0] = a;
330    dest[1] = b;
331    dest[2] = 0;
332    dest[3] = 1;
333 }
334
335 static void GLAPIENTRY _mesa_noop_TexCoord2fv( const GLfloat *v )
336 {
337    GET_CURRENT_CONTEXT(ctx);
338    GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_TEX0];
339    dest[0] = v[0];
340    dest[1] = v[1];
341    dest[2] = 0;
342    dest[3] = 1;
343 }
344
345 static void GLAPIENTRY _mesa_noop_TexCoord3f( GLfloat a, GLfloat b, GLfloat c )
346 {
347    GET_CURRENT_CONTEXT(ctx);
348    GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_TEX0];
349    dest[0] = a;
350    dest[1] = b;
351    dest[2] = c;
352    dest[3] = 1;
353 }
354
355 static void GLAPIENTRY _mesa_noop_TexCoord3fv( const GLfloat *v )
356 {
357    GET_CURRENT_CONTEXT(ctx);
358    GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_TEX0];
359    dest[0] = v[0];
360    dest[1] = v[1];
361    dest[2] = v[2];
362    dest[3] = 1;
363 }
364
365 static void GLAPIENTRY _mesa_noop_TexCoord4f( GLfloat a, GLfloat b, GLfloat c, GLfloat d )
366 {
367    GET_CURRENT_CONTEXT(ctx);
368    GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_TEX0];
369    dest[0] = a;
370    dest[1] = b;
371    dest[2] = c;
372    dest[3] = d;
373 }
374
375 static void GLAPIENTRY _mesa_noop_TexCoord4fv( const GLfloat *v )
376 {
377    GET_CURRENT_CONTEXT(ctx);
378    GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_TEX0];
379    dest[0] = v[0];
380    dest[1] = v[1];
381    dest[2] = v[2];
382    dest[3] = v[3];
383 }
384
385
386 /**
387  * GL_NV_vertex_program attributes.
388  * Note that these attributes alias the conventional vertex attributes.
389  */
390
391 static void GLAPIENTRY _mesa_noop_VertexAttrib1fNV( GLuint index, GLfloat x )
392 {
393    GET_CURRENT_CONTEXT(ctx);
394    if (index < MAX_NV_VERTEX_PROGRAM_INPUTS) {
395       ASSIGN_4V(ctx->Current.Attrib[index], x, 0, 0, 1);
396    }
397    else
398       _mesa_error( ctx, GL_INVALID_VALUE, "glVertexAttrib1fNV(index)" );
399 }
400
401 static void GLAPIENTRY _mesa_noop_VertexAttrib1fvNV( GLuint index, const GLfloat *v )
402 {
403    GET_CURRENT_CONTEXT(ctx);
404    if (index < MAX_NV_VERTEX_PROGRAM_INPUTS) {
405       ASSIGN_4V(ctx->Current.Attrib[index], v[0], 0, 0, 1);
406    }
407    else
408       _mesa_error( ctx, GL_INVALID_VALUE, "glVertexAttrib1fvNV(index)" );
409 }
410
411 static void GLAPIENTRY _mesa_noop_VertexAttrib2fNV( GLuint index, GLfloat x, GLfloat y )
412 {
413    GET_CURRENT_CONTEXT(ctx);
414    if (index < MAX_NV_VERTEX_PROGRAM_INPUTS) {
415       ASSIGN_4V(ctx->Current.Attrib[index], x, y, 0, 1);
416    }
417    else
418       _mesa_error( ctx, GL_INVALID_VALUE, "glVertexAttrib2fNV(index)" );
419 }
420
421 static void GLAPIENTRY _mesa_noop_VertexAttrib2fvNV( GLuint index, const GLfloat *v )
422 {
423    GET_CURRENT_CONTEXT(ctx);
424    if (index < MAX_NV_VERTEX_PROGRAM_INPUTS) {
425       ASSIGN_4V(ctx->Current.Attrib[index], v[0], v[1], 0, 1);
426    }
427    else
428       _mesa_error( ctx, GL_INVALID_VALUE, "glVertexAttrib2fvNV(index)" );
429 }
430
431 static void GLAPIENTRY _mesa_noop_VertexAttrib3fNV( GLuint index, GLfloat x,
432                                   GLfloat y, GLfloat z )
433 {
434    GET_CURRENT_CONTEXT(ctx);
435    if (index < MAX_NV_VERTEX_PROGRAM_INPUTS) {
436       ASSIGN_4V(ctx->Current.Attrib[index], x, y, z, 1);
437    }
438    else
439       _mesa_error( ctx, GL_INVALID_VALUE, "glVertexAttrib3fNV(index)" );
440 }
441
442 static void GLAPIENTRY _mesa_noop_VertexAttrib3fvNV( GLuint index, const GLfloat *v )
443 {
444    GET_CURRENT_CONTEXT(ctx);
445    if (index < MAX_NV_VERTEX_PROGRAM_INPUTS) {
446       ASSIGN_4V(ctx->Current.Attrib[index], v[0], v[1], v[2], 1);
447    }
448    else
449       _mesa_error( ctx, GL_INVALID_VALUE, "glVertexAttrib3fvNV(index)" );
450 }
451
452 static void GLAPIENTRY _mesa_noop_VertexAttrib4fNV( GLuint index, GLfloat x,
453                                   GLfloat y, GLfloat z, GLfloat w )
454 {
455    GET_CURRENT_CONTEXT(ctx);
456    if (index < MAX_NV_VERTEX_PROGRAM_INPUTS) {
457       ASSIGN_4V(ctx->Current.Attrib[index], x, y, z, w);
458    }
459    else
460       _mesa_error( ctx, GL_INVALID_VALUE, "glVertexAttrib4fNV(index)" );
461 }
462
463 static void GLAPIENTRY _mesa_noop_VertexAttrib4fvNV( GLuint index, const GLfloat *v )
464 {
465    GET_CURRENT_CONTEXT(ctx);
466    if (index < MAX_NV_VERTEX_PROGRAM_INPUTS) {
467       ASSIGN_4V(ctx->Current.Attrib[index], v[0], v[1], v[2], v[3]);
468    }
469    else
470       _mesa_error( ctx, GL_INVALID_VALUE, "glVertexAttrib4fvNV(index)" );
471 }
472
473
474
475 /**
476  * GL_ARB_vertex_program attributes.
477  * Note that these attributes DO NOT alias the conventional vertex attributes.
478  */
479
480 static void GLAPIENTRY _mesa_noop_VertexAttrib1fARB( GLuint index, GLfloat x )
481 {
482    GET_CURRENT_CONTEXT(ctx);
483    if (index < MAX_VERTEX_GENERIC_ATTRIBS) {
484       ASSIGN_4V(ctx->Current.Attrib[VERT_ATTRIB_GENERIC0 + index], x, 0, 0, 1);
485    }
486    else
487       _mesa_error( ctx, GL_INVALID_VALUE, "glVertexAttrib1fARB(index)" );
488 }
489
490 static void GLAPIENTRY _mesa_noop_VertexAttrib1fvARB( GLuint index, const GLfloat *v )
491 {
492    GET_CURRENT_CONTEXT(ctx);
493    if (index < MAX_VERTEX_GENERIC_ATTRIBS) {
494       ASSIGN_4V(ctx->Current.Attrib[VERT_ATTRIB_GENERIC0 + index], v[0], 0, 0, 1);
495    }
496    else
497       _mesa_error( ctx, GL_INVALID_VALUE, "glVertexAttrib1fvARB(index)" );
498 }
499
500 static void GLAPIENTRY _mesa_noop_VertexAttrib2fARB( GLuint index, GLfloat x, GLfloat y )
501 {
502    GET_CURRENT_CONTEXT(ctx);
503    if (index < MAX_VERTEX_GENERIC_ATTRIBS) {
504       ASSIGN_4V(ctx->Current.Attrib[VERT_ATTRIB_GENERIC0 + index], x, y, 0, 1);
505    }
506    else
507       _mesa_error( ctx, GL_INVALID_VALUE, "glVertexAttrib2fARB(index)" );
508 }
509
510 static void GLAPIENTRY _mesa_noop_VertexAttrib2fvARB( GLuint index, const GLfloat *v )
511 {
512    GET_CURRENT_CONTEXT(ctx);
513    if (index < MAX_VERTEX_GENERIC_ATTRIBS) {
514       ASSIGN_4V(ctx->Current.Attrib[VERT_ATTRIB_GENERIC0 + index], v[0], v[1], 0, 1);
515    }
516    else
517       _mesa_error( ctx, GL_INVALID_VALUE, "glVertexAttrib2fvARB(index)" );
518 }
519
520 static void GLAPIENTRY _mesa_noop_VertexAttrib3fARB( GLuint index, GLfloat x,
521                                   GLfloat y, GLfloat z )
522 {
523    GET_CURRENT_CONTEXT(ctx);
524    if (index < MAX_VERTEX_GENERIC_ATTRIBS) {
525       ASSIGN_4V(ctx->Current.Attrib[VERT_ATTRIB_GENERIC0 + index], x, y, z, 1);
526    }
527    else
528       _mesa_error( ctx, GL_INVALID_VALUE, "glVertexAttrib3fARB(index)" );
529 }
530
531 static void GLAPIENTRY _mesa_noop_VertexAttrib3fvARB( GLuint index, const GLfloat *v )
532 {
533    GET_CURRENT_CONTEXT(ctx);
534    if (index < MAX_VERTEX_GENERIC_ATTRIBS) {
535       ASSIGN_4V(ctx->Current.Attrib[VERT_ATTRIB_GENERIC0 + index], v[0], v[1], v[2], 1);
536    }
537    else
538       _mesa_error( ctx, GL_INVALID_VALUE, "glVertexAttrib3fvARB(index)" );
539 }
540
541 static void GLAPIENTRY _mesa_noop_VertexAttrib4fARB( GLuint index, GLfloat x,
542                                   GLfloat y, GLfloat z, GLfloat w )
543 {
544    GET_CURRENT_CONTEXT(ctx);
545    if (index < MAX_VERTEX_GENERIC_ATTRIBS) {
546       ASSIGN_4V(ctx->Current.Attrib[VERT_ATTRIB_GENERIC0 + index], x, y, z, w);
547    }
548    else
549       _mesa_error( ctx, GL_INVALID_VALUE, "glVertexAttrib4fARB(index)" );
550 }
551
552 static void GLAPIENTRY _mesa_noop_VertexAttrib4fvARB( GLuint index, const GLfloat *v )
553 {
554    GET_CURRENT_CONTEXT(ctx);
555    if (index < MAX_VERTEX_GENERIC_ATTRIBS) {
556       ASSIGN_4V(ctx->Current.Attrib[VERT_ATTRIB_GENERIC0 + index], v[0], v[1], v[2], v[3]);
557    }
558    else
559       _mesa_error( ctx, GL_INVALID_VALUE, "glVertexAttrib4fvARB(index)" );
560 }
561
562
563
564 /**
565  * Called by glMaterial*()
566  */
567 void GLAPIENTRY
568 _mesa_noop_Materialfv( GLenum face, GLenum pname, const GLfloat *params )
569 {
570    GET_CURRENT_CONTEXT(ctx);
571    GLint i, nr;
572    struct gl_material *mat = &ctx->Light.Material;
573    GLuint bitmask = _mesa_material_bitmask( ctx, face, pname, ~0,
574                                             "_mesa_noop_Materialfv" );
575
576    if (ctx->Light.ColorMaterialEnabled)
577       bitmask &= ~ctx->Light.ColorMaterialBitmask;
578
579    if (bitmask == 0)
580       return;
581
582    switch (pname) {
583    case GL_SHININESS: nr = 1; break;
584    case GL_COLOR_INDEXES: nr = 3; break;
585    default: nr = 4 ; break;
586    }
587
588    for (i = 0 ; i < MAT_ATTRIB_MAX ; i++) 
589       if (bitmask & (1<<i))
590          COPY_SZ_4V( mat->Attrib[i], nr, params ); 
591
592    _mesa_update_material( ctx, bitmask );
593 }
594
595
596 /**
597  * These really are noops outside begin/end:
598  */
599 static void GLAPIENTRY _mesa_noop_Vertex2fv( const GLfloat *v )
600 {
601    (void) v;
602 }
603
604 static void GLAPIENTRY _mesa_noop_Vertex3fv( const GLfloat *v )
605 {
606    (void) v;
607 }
608
609 static void GLAPIENTRY _mesa_noop_Vertex4fv( const GLfloat *v )
610 {
611    (void) v;
612 }
613
614 static void GLAPIENTRY _mesa_noop_Vertex2f( GLfloat a, GLfloat b )
615 {
616    (void) a; (void) b;
617 }
618
619 static void GLAPIENTRY _mesa_noop_Vertex3f( GLfloat a, GLfloat b, GLfloat c )
620 {
621    (void) a; (void) b; (void) c;
622 }
623
624 static void GLAPIENTRY _mesa_noop_Vertex4f( GLfloat a, GLfloat b, GLfloat c, GLfloat d )
625 {
626    (void) a; (void) b; (void) c; (void) d;
627 }
628
629
630 #if FEATURE_evaluators
631 /* Similarly, these have no effect outside begin/end:
632  */
633 static void GLAPIENTRY _mesa_noop_EvalCoord1f( GLfloat a )
634 {
635    (void) a;
636 }
637
638 static void GLAPIENTRY _mesa_noop_EvalCoord1fv( const GLfloat *v )
639 {
640    (void) v;
641 }
642
643 static void GLAPIENTRY _mesa_noop_EvalCoord2f( GLfloat a, GLfloat b )
644 {
645    (void) a; (void) b;
646 }
647
648 static void GLAPIENTRY _mesa_noop_EvalCoord2fv( const GLfloat *v )
649 {
650    (void) v;
651 }
652
653 static void GLAPIENTRY _mesa_noop_EvalPoint1( GLint a )
654 {
655    (void) a;
656 }
657
658 static void GLAPIENTRY _mesa_noop_EvalPoint2( GLint a, GLint b )
659 {
660    (void) a; (void) b;
661 }
662 #endif /* FEATURE_evaluators */
663
664
665 /* Begin -- call into driver, should result in the vtxfmt being
666  * swapped out:
667  */
668 static void GLAPIENTRY _mesa_noop_Begin( GLenum mode )
669 {
670    (void) mode;
671 }
672
673
674 /* End -- just raise an error
675  */
676 static void GLAPIENTRY _mesa_noop_End( void )
677 {
678    GET_CURRENT_CONTEXT(ctx);
679    _mesa_error( ctx, GL_INVALID_OPERATION, "glEnd(no glBegin)" );
680 }
681
682
683 /***
684  * PrimitiveRestart called outside glBegin()/End(): raise an error
685  */
686 static void GLAPIENTRY _mesa_noop_PrimitiveRestartNV( void )
687 {
688    GET_CURRENT_CONTEXT(ctx);
689    _mesa_error(ctx, GL_INVALID_OPERATION, "glPrimitiveRestartNV(no glBegin)");
690 }
691
692
693 /**
694  * Execute a glRectf() function.  This is not suitable for GL_COMPILE
695  * modes (as the test for outside begin/end is not compiled),
696  * but may be useful for drivers in circumstances which exclude
697  * display list interactions.
698  *
699  * (None of the functions in this file are suitable for GL_COMPILE
700  * modes).
701  */
702 void GLAPIENTRY
703 _mesa_noop_Rectf( GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2 )
704 {
705    {
706       GET_CURRENT_CONTEXT(ctx);
707       ASSERT_OUTSIDE_BEGIN_END(ctx);
708    }
709
710    CALL_Begin(GET_DISPATCH(), (GL_QUADS));
711    CALL_Vertex2f(GET_DISPATCH(), (x1, y1));
712    CALL_Vertex2f(GET_DISPATCH(), (x2, y1));
713    CALL_Vertex2f(GET_DISPATCH(), (x2, y2));
714    CALL_Vertex2f(GET_DISPATCH(), (x1, y2));
715    CALL_End(GET_DISPATCH(), ());
716 }
717
718
719 /**
720  * Some very basic support for arrays.  Drivers without explicit array
721  * support can hook these in, but still need to supply an array-elt
722  * implementation.
723  */
724 static void GLAPIENTRY
725 _mesa_noop_DrawArrays(GLenum mode, GLint start, GLsizei count)
726 {
727    GET_CURRENT_CONTEXT(ctx);
728    GLint i;
729
730    if (!_mesa_validate_DrawArrays( ctx, mode, start, count ))
731       return;
732
733    CALL_Begin(GET_DISPATCH(), (mode));
734    for (i = 0; i < count; i++)
735        CALL_ArrayElement(GET_DISPATCH(), (start + i));
736    CALL_End(GET_DISPATCH(), ());
737 }
738
739
740 static void GLAPIENTRY
741 _mesa_noop_DrawElements(GLenum mode, GLsizei count, GLenum type,
742                         const GLvoid *indices)
743 {
744    GET_CURRENT_CONTEXT(ctx);
745    GLint i;
746
747    if (!_mesa_validate_DrawElements( ctx, mode, count, type, indices, 0 ))
748       return;
749
750    CALL_Begin(GET_DISPATCH(), (mode));
751
752    switch (type) {
753    case GL_UNSIGNED_BYTE:
754       for (i = 0 ; i < count ; i++)
755           CALL_ArrayElement(GET_DISPATCH(), ( ((GLubyte *)indices)[i] ));
756       break;
757    case GL_UNSIGNED_SHORT:
758       for (i = 0 ; i < count ; i++)
759           CALL_ArrayElement(GET_DISPATCH(), ( ((GLushort *)indices)[i] ));
760       break;
761    case GL_UNSIGNED_INT:
762       for (i = 0 ; i < count ; i++)
763           CALL_ArrayElement(GET_DISPATCH(), ( ((GLuint *)indices)[i] ));
764       break;
765    default:
766       _mesa_error( ctx, GL_INVALID_ENUM, "glDrawElements(type)" );
767       break;
768    }
769
770    CALL_End(GET_DISPATCH(), ());
771 }
772
773 static void GLAPIENTRY
774 _mesa_noop_DrawElementsBaseVertex(GLenum mode, GLsizei count, GLenum type,
775                                   const GLvoid *indices, GLint basevertex)
776 {
777    GET_CURRENT_CONTEXT(ctx);
778    GLint i;
779
780    if (!_mesa_validate_DrawElements( ctx, mode, count, type, indices,
781                                      basevertex ))
782       return;
783
784    CALL_Begin(GET_DISPATCH(), (mode));
785
786    switch (type) {
787    case GL_UNSIGNED_BYTE:
788       for (i = 0 ; i < count ; i++)
789           CALL_ArrayElement(GET_DISPATCH(), ( ((GLubyte *)indices)[i] +
790                                               basevertex));
791       break;
792    case GL_UNSIGNED_SHORT:
793       for (i = 0 ; i < count ; i++)
794           CALL_ArrayElement(GET_DISPATCH(), ( ((GLushort *)indices)[i] +
795                                               basevertex ));
796       break;
797    case GL_UNSIGNED_INT:
798       for (i = 0 ; i < count ; i++)
799           CALL_ArrayElement(GET_DISPATCH(), ( ((GLuint *)indices)[i] +
800                                               basevertex ));
801       break;
802    default:
803       _mesa_error( ctx, GL_INVALID_ENUM, "glDrawElementsBaseVertex(type)" );
804       break;
805    }
806
807    CALL_End(GET_DISPATCH(), ());
808 }
809
810
811 static void GLAPIENTRY
812 _mesa_noop_DrawRangeElements(GLenum mode,
813                              GLuint start, GLuint end,
814                              GLsizei count, GLenum type,
815                              const GLvoid *indices)
816 {
817    GET_CURRENT_CONTEXT(ctx);
818
819    if (_mesa_validate_DrawRangeElements( ctx, mode,
820                                          start, end,
821                                          count, type, indices, 0 ))
822        CALL_DrawElements(GET_DISPATCH(), (mode, count, type, indices));
823 }
824
825 /* GL_EXT_multi_draw_arrays */
826 void GLAPIENTRY
827 _mesa_noop_MultiDrawElements(GLenum mode, const GLsizei *count, GLenum type,
828                              const GLvoid **indices, GLsizei primcount)
829 {
830    GLsizei i;
831
832    for (i = 0; i < primcount; i++) {
833       if (count[i] > 0) {
834          CALL_DrawElements(GET_DISPATCH(), (mode, count[i], type, indices[i]));
835       }
836    }
837 }
838
839 static void GLAPIENTRY
840 _mesa_noop_DrawRangeElementsBaseVertex(GLenum mode,
841                                        GLuint start, GLuint end,
842                                        GLsizei count, GLenum type,
843                                        const GLvoid *indices, GLint basevertex)
844 {
845    GET_CURRENT_CONTEXT(ctx);
846
847    if (_mesa_validate_DrawRangeElements( ctx, mode,
848                                          start, end,
849                                          count, type, indices, basevertex ))
850       CALL_DrawElementsBaseVertex(GET_DISPATCH(), (mode, count, type, indices,
851                                                    basevertex));
852 }
853
854 /* GL_EXT_multi_draw_arrays */
855 void GLAPIENTRY
856 _mesa_noop_MultiDrawElementsBaseVertex(GLenum mode, const GLsizei *count,
857                                        GLenum type,
858                                        const GLvoid **indices,
859                                        GLsizei primcount,
860                                        const GLint *basevertex)
861 {
862    GLsizei i;
863
864    for (i = 0; i < primcount; i++) {
865       if (count[i] > 0) {
866          CALL_DrawElementsBaseVertex(GET_DISPATCH(), (mode, count[i], type,
867                                                       indices[i],
868                                                       basevertex[i]));
869       }
870    }
871 }
872
873 /*
874  * Eval Mesh
875  */
876
877 /**
878  * KW:
879  * If are compiling, we don't know whether eval will produce a
880  * vertex when it is run in the future.  If this is pure immediate
881  * mode, eval is a noop if neither vertex map is enabled.
882  *
883  * Thus we need to have a check in the display list code or elsewhere
884  * for eval(1,2) vertices in the case where map(1,2)_vertex is
885  * disabled, and to purge those vertices from the vb.
886  */
887 void GLAPIENTRY
888 _mesa_noop_EvalMesh1( GLenum mode, GLint i1, GLint i2 )
889 {
890    GET_CURRENT_CONTEXT(ctx);
891    GLint i;
892    GLfloat u, du;
893    GLenum prim;
894
895    ASSERT_OUTSIDE_BEGIN_END(ctx);
896
897    switch (mode) {
898    case GL_POINT:
899       prim = GL_POINTS;
900       break;
901    case GL_LINE:
902       prim = GL_LINE_STRIP;
903       break;
904    default:
905       _mesa_error( ctx, GL_INVALID_ENUM, "glEvalMesh1(mode)" );
906       return;
907    }
908
909    /* No effect if vertex maps disabled.
910     */
911    if (!ctx->Eval.Map1Vertex4 && 
912        !ctx->Eval.Map1Vertex3 &&
913        !(ctx->VertexProgram._Enabled && ctx->Eval.Map1Attrib[VERT_ATTRIB_POS]))
914       return;
915
916    du = ctx->Eval.MapGrid1du;
917    u = ctx->Eval.MapGrid1u1 + i1 * du;
918
919    CALL_Begin(GET_DISPATCH(), (prim));
920    for (i=i1;i<=i2;i++,u+=du) {
921       CALL_EvalCoord1f(GET_DISPATCH(), (u));
922    }
923    CALL_End(GET_DISPATCH(), ());
924 }
925
926
927
928 void GLAPIENTRY
929 _mesa_noop_EvalMesh2( GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2 )
930 {
931    GET_CURRENT_CONTEXT(ctx);
932    GLfloat u, du, v, dv, v1, u1;
933    GLint i, j;
934
935    ASSERT_OUTSIDE_BEGIN_END(ctx);
936
937    switch (mode) {
938    case GL_POINT:
939    case GL_LINE:
940    case GL_FILL:
941       break;
942    default:
943       _mesa_error( ctx, GL_INVALID_ENUM, "glEvalMesh2(mode)" );
944       return;
945    }
946
947    /* No effect if vertex maps disabled.
948     */
949    if (!ctx->Eval.Map2Vertex4 && 
950        !ctx->Eval.Map2Vertex3 &&
951        !(ctx->VertexProgram._Enabled && ctx->Eval.Map2Attrib[VERT_ATTRIB_POS]))
952       return;
953
954    du = ctx->Eval.MapGrid2du;
955    dv = ctx->Eval.MapGrid2dv;
956    v1 = ctx->Eval.MapGrid2v1 + j1 * dv;
957    u1 = ctx->Eval.MapGrid2u1 + i1 * du;
958
959    switch (mode) {
960    case GL_POINT:
961       CALL_Begin(GET_DISPATCH(), (GL_POINTS));
962       for (v=v1,j=j1;j<=j2;j++,v+=dv) {
963          for (u=u1,i=i1;i<=i2;i++,u+=du) {
964             CALL_EvalCoord2f(GET_DISPATCH(), (u, v));
965          }
966       }
967       CALL_End(GET_DISPATCH(), ());
968       break;
969    case GL_LINE:
970       for (v=v1,j=j1;j<=j2;j++,v+=dv) {
971          CALL_Begin(GET_DISPATCH(), (GL_LINE_STRIP));
972          for (u=u1,i=i1;i<=i2;i++,u+=du) {
973             CALL_EvalCoord2f(GET_DISPATCH(), (u, v));
974          }
975          CALL_End(GET_DISPATCH(), ());
976       }
977       for (u=u1,i=i1;i<=i2;i++,u+=du) {
978          CALL_Begin(GET_DISPATCH(), (GL_LINE_STRIP));
979          for (v=v1,j=j1;j<=j2;j++,v+=dv) {
980             CALL_EvalCoord2f(GET_DISPATCH(), (u, v));
981          }
982          CALL_End(GET_DISPATCH(), ());
983       }
984       break;
985    case GL_FILL:
986       for (v=v1,j=j1;j<j2;j++,v+=dv) {
987          CALL_Begin(GET_DISPATCH(), (GL_TRIANGLE_STRIP));
988          for (u=u1,i=i1;i<=i2;i++,u+=du) {
989             CALL_EvalCoord2f(GET_DISPATCH(), (u, v));
990             CALL_EvalCoord2f(GET_DISPATCH(), (u, v+dv));
991          }
992          CALL_End(GET_DISPATCH(), ());
993       }
994       break;
995    default:
996       _mesa_error( ctx, GL_INVALID_ENUM, "glEvalMesh2(mode)" );
997       return;
998    }
999 }
1000
1001
1002
1003 /**
1004  * Build a vertexformat of functions to use outside begin/end pairs.
1005  * 
1006  * TODO -- build a whole dispatch table for this purpose, and likewise
1007  * for inside begin/end.
1008  */
1009 void
1010 _mesa_noop_vtxfmt_init( GLvertexformat *vfmt )
1011 {
1012    _MESA_INIT_ARRAYELT_VTXFMT(vfmt, _ae_);
1013
1014    vfmt->Begin = _mesa_noop_Begin;
1015
1016    _MESA_INIT_DLIST_VTXFMT(vfmt, _mesa_);
1017
1018    vfmt->Color3f = _mesa_noop_Color3f;
1019    vfmt->Color3fv = _mesa_noop_Color3fv;
1020    vfmt->Color4f = _mesa_noop_Color4f;
1021    vfmt->Color4fv = _mesa_noop_Color4fv;
1022    vfmt->EdgeFlag = _mesa_noop_EdgeFlag;
1023    vfmt->End = _mesa_noop_End;
1024
1025    vfmt->PrimitiveRestartNV = _mesa_noop_PrimitiveRestartNV;
1026
1027    _MESA_INIT_EVAL_VTXFMT(vfmt, _mesa_noop_);
1028
1029    vfmt->FogCoordfEXT = _mesa_noop_FogCoordfEXT;
1030    vfmt->FogCoordfvEXT = _mesa_noop_FogCoordfvEXT;
1031    vfmt->Indexf = _mesa_noop_Indexf;
1032    vfmt->Indexfv = _mesa_noop_Indexfv;
1033    vfmt->Materialfv = _mesa_noop_Materialfv;
1034    vfmt->MultiTexCoord1fARB = _mesa_noop_MultiTexCoord1fARB;
1035    vfmt->MultiTexCoord1fvARB = _mesa_noop_MultiTexCoord1fvARB;
1036    vfmt->MultiTexCoord2fARB = _mesa_noop_MultiTexCoord2fARB;
1037    vfmt->MultiTexCoord2fvARB = _mesa_noop_MultiTexCoord2fvARB;
1038    vfmt->MultiTexCoord3fARB = _mesa_noop_MultiTexCoord3fARB;
1039    vfmt->MultiTexCoord3fvARB = _mesa_noop_MultiTexCoord3fvARB;
1040    vfmt->MultiTexCoord4fARB = _mesa_noop_MultiTexCoord4fARB;
1041    vfmt->MultiTexCoord4fvARB = _mesa_noop_MultiTexCoord4fvARB;
1042    vfmt->Normal3f = _mesa_noop_Normal3f;
1043    vfmt->Normal3fv = _mesa_noop_Normal3fv;
1044    vfmt->SecondaryColor3fEXT = _mesa_noop_SecondaryColor3fEXT;
1045    vfmt->SecondaryColor3fvEXT = _mesa_noop_SecondaryColor3fvEXT;
1046    vfmt->TexCoord1f = _mesa_noop_TexCoord1f;
1047    vfmt->TexCoord1fv = _mesa_noop_TexCoord1fv;
1048    vfmt->TexCoord2f = _mesa_noop_TexCoord2f;
1049    vfmt->TexCoord2fv = _mesa_noop_TexCoord2fv;
1050    vfmt->TexCoord3f = _mesa_noop_TexCoord3f;
1051    vfmt->TexCoord3fv = _mesa_noop_TexCoord3fv;
1052    vfmt->TexCoord4f = _mesa_noop_TexCoord4f;
1053    vfmt->TexCoord4fv = _mesa_noop_TexCoord4fv;
1054    vfmt->Vertex2f = _mesa_noop_Vertex2f;
1055    vfmt->Vertex2fv = _mesa_noop_Vertex2fv;
1056    vfmt->Vertex3f = _mesa_noop_Vertex3f;
1057    vfmt->Vertex3fv = _mesa_noop_Vertex3fv;
1058    vfmt->Vertex4f = _mesa_noop_Vertex4f;
1059    vfmt->Vertex4fv = _mesa_noop_Vertex4fv;
1060    vfmt->VertexAttrib1fNV = _mesa_noop_VertexAttrib1fNV;
1061    vfmt->VertexAttrib1fvNV = _mesa_noop_VertexAttrib1fvNV;
1062    vfmt->VertexAttrib2fNV = _mesa_noop_VertexAttrib2fNV;
1063    vfmt->VertexAttrib2fvNV = _mesa_noop_VertexAttrib2fvNV;
1064    vfmt->VertexAttrib3fNV = _mesa_noop_VertexAttrib3fNV;
1065    vfmt->VertexAttrib3fvNV = _mesa_noop_VertexAttrib3fvNV;
1066    vfmt->VertexAttrib4fNV = _mesa_noop_VertexAttrib4fNV;
1067    vfmt->VertexAttrib4fvNV = _mesa_noop_VertexAttrib4fvNV;
1068    vfmt->VertexAttrib1fARB = _mesa_noop_VertexAttrib1fARB;
1069    vfmt->VertexAttrib1fvARB = _mesa_noop_VertexAttrib1fvARB;
1070    vfmt->VertexAttrib2fARB = _mesa_noop_VertexAttrib2fARB;
1071    vfmt->VertexAttrib2fvARB = _mesa_noop_VertexAttrib2fvARB;
1072    vfmt->VertexAttrib3fARB = _mesa_noop_VertexAttrib3fARB;
1073    vfmt->VertexAttrib3fvARB = _mesa_noop_VertexAttrib3fvARB;
1074    vfmt->VertexAttrib4fARB = _mesa_noop_VertexAttrib4fARB;
1075    vfmt->VertexAttrib4fvARB = _mesa_noop_VertexAttrib4fvARB;
1076
1077    vfmt->Rectf = _mesa_noop_Rectf;
1078
1079    vfmt->DrawArrays = _mesa_noop_DrawArrays;
1080    vfmt->DrawElements = _mesa_noop_DrawElements;
1081    vfmt->DrawRangeElements = _mesa_noop_DrawRangeElements;
1082    vfmt->MultiDrawElementsEXT = _mesa_noop_MultiDrawElements;
1083    vfmt->DrawElementsBaseVertex = _mesa_noop_DrawElementsBaseVertex;
1084    vfmt->DrawRangeElementsBaseVertex = _mesa_noop_DrawRangeElementsBaseVertex;
1085    vfmt->MultiDrawElementsBaseVertex = _mesa_noop_MultiDrawElementsBaseVertex;
1086 }
1087
1088
1089 #endif /* FEATURE_beginend */