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