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