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