mesa: Clean up header file inclusion in texrender.h.
[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 "main/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 * PrimitiveRestart called outside glBegin()/End(): raise an error
684 */
685 static void GLAPIENTRY _mesa_noop_PrimitiveRestartNV( void )
686 {
687 GET_CURRENT_CONTEXT(ctx);
688 _mesa_error(ctx, GL_INVALID_OPERATION, "glPrimitiveRestartNV(no glBegin)");
689 }
690
691
692 /**
693 * Execute a glRectf() function. This is not suitable for GL_COMPILE
694 * modes (as the test for outside begin/end is not compiled),
695 * but may be useful for drivers in circumstances which exclude
696 * display list interactions.
697 *
698 * (None of the functions in this file are suitable for GL_COMPILE
699 * modes).
700 */
701 void GLAPIENTRY
702 _mesa_noop_Rectf( GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2 )
703 {
704 {
705 GET_CURRENT_CONTEXT(ctx);
706 ASSERT_OUTSIDE_BEGIN_END(ctx);
707 }
708
709 CALL_Begin(GET_DISPATCH(), (GL_QUADS));
710 CALL_Vertex2f(GET_DISPATCH(), (x1, y1));
711 CALL_Vertex2f(GET_DISPATCH(), (x2, y1));
712 CALL_Vertex2f(GET_DISPATCH(), (x2, y2));
713 CALL_Vertex2f(GET_DISPATCH(), (x1, y2));
714 CALL_End(GET_DISPATCH(), ());
715 }
716
717
718 /**
719 * Some very basic support for arrays. Drivers without explicit array
720 * support can hook these in, but still need to supply an array-elt
721 * implementation.
722 */
723 static void GLAPIENTRY
724 _mesa_noop_DrawArrays(GLenum mode, GLint start, GLsizei count)
725 {
726 GET_CURRENT_CONTEXT(ctx);
727 GLint i;
728
729 if (!_mesa_validate_DrawArrays( ctx, mode, start, count ))
730 return;
731
732 CALL_Begin(GET_DISPATCH(), (mode));
733 for (i = 0; i < count; i++)
734 CALL_ArrayElement(GET_DISPATCH(), (start + i));
735 CALL_End(GET_DISPATCH(), ());
736 }
737
738
739 static void GLAPIENTRY
740 _mesa_noop_DrawElements(GLenum mode, GLsizei count, GLenum type,
741 const GLvoid *indices)
742 {
743 GET_CURRENT_CONTEXT(ctx);
744 GLint i;
745
746 if (!_mesa_validate_DrawElements( ctx, mode, count, type, indices, 0 ))
747 return;
748
749 CALL_Begin(GET_DISPATCH(), (mode));
750
751 switch (type) {
752 case GL_UNSIGNED_BYTE:
753 for (i = 0 ; i < count ; i++)
754 CALL_ArrayElement(GET_DISPATCH(), ( ((GLubyte *)indices)[i] ));
755 break;
756 case GL_UNSIGNED_SHORT:
757 for (i = 0 ; i < count ; i++)
758 CALL_ArrayElement(GET_DISPATCH(), ( ((GLushort *)indices)[i] ));
759 break;
760 case GL_UNSIGNED_INT:
761 for (i = 0 ; i < count ; i++)
762 CALL_ArrayElement(GET_DISPATCH(), ( ((GLuint *)indices)[i] ));
763 break;
764 default:
765 _mesa_error( ctx, GL_INVALID_ENUM, "glDrawElements(type)" );
766 break;
767 }
768
769 CALL_End(GET_DISPATCH(), ());
770 }
771
772 static void GLAPIENTRY
773 _mesa_noop_DrawElementsBaseVertex(GLenum mode, GLsizei count, GLenum type,
774 const GLvoid *indices, GLint basevertex)
775 {
776 GET_CURRENT_CONTEXT(ctx);
777 GLint i;
778
779 if (!_mesa_validate_DrawElements( ctx, mode, count, type, indices,
780 basevertex ))
781 return;
782
783 CALL_Begin(GET_DISPATCH(), (mode));
784
785 switch (type) {
786 case GL_UNSIGNED_BYTE:
787 for (i = 0 ; i < count ; i++)
788 CALL_ArrayElement(GET_DISPATCH(), ( ((GLubyte *)indices)[i] +
789 basevertex));
790 break;
791 case GL_UNSIGNED_SHORT:
792 for (i = 0 ; i < count ; i++)
793 CALL_ArrayElement(GET_DISPATCH(), ( ((GLushort *)indices)[i] +
794 basevertex ));
795 break;
796 case GL_UNSIGNED_INT:
797 for (i = 0 ; i < count ; i++)
798 CALL_ArrayElement(GET_DISPATCH(), ( ((GLuint *)indices)[i] +
799 basevertex ));
800 break;
801 default:
802 _mesa_error( ctx, GL_INVALID_ENUM, "glDrawElementsBaseVertex(type)" );
803 break;
804 }
805
806 CALL_End(GET_DISPATCH(), ());
807 }
808
809
810 static void GLAPIENTRY
811 _mesa_noop_DrawRangeElements(GLenum mode,
812 GLuint start, GLuint end,
813 GLsizei count, GLenum type,
814 const GLvoid *indices)
815 {
816 GET_CURRENT_CONTEXT(ctx);
817
818 if (_mesa_validate_DrawRangeElements( ctx, mode,
819 start, end,
820 count, type, indices, 0 ))
821 CALL_DrawElements(GET_DISPATCH(), (mode, count, type, indices));
822 }
823
824 /* GL_EXT_multi_draw_arrays */
825 void GLAPIENTRY
826 _mesa_noop_MultiDrawElements(GLenum mode, const GLsizei *count, GLenum type,
827 const GLvoid **indices, GLsizei primcount)
828 {
829 GLsizei i;
830
831 for (i = 0; i < primcount; i++) {
832 if (count[i] > 0) {
833 CALL_DrawElements(GET_DISPATCH(), (mode, count[i], type, indices[i]));
834 }
835 }
836 }
837
838 static void GLAPIENTRY
839 _mesa_noop_DrawRangeElementsBaseVertex(GLenum mode,
840 GLuint start, GLuint end,
841 GLsizei count, GLenum type,
842 const GLvoid *indices, GLint basevertex)
843 {
844 GET_CURRENT_CONTEXT(ctx);
845
846 if (_mesa_validate_DrawRangeElements( ctx, mode,
847 start, end,
848 count, type, indices, basevertex ))
849 CALL_DrawElementsBaseVertex(GET_DISPATCH(), (mode, count, type, indices,
850 basevertex));
851 }
852
853 /* GL_EXT_multi_draw_arrays */
854 void GLAPIENTRY
855 _mesa_noop_MultiDrawElementsBaseVertex(GLenum mode, const GLsizei *count,
856 GLenum type,
857 const GLvoid **indices,
858 GLsizei primcount,
859 const GLint *basevertex)
860 {
861 GLsizei i;
862
863 for (i = 0; i < primcount; i++) {
864 if (count[i] > 0) {
865 CALL_DrawElementsBaseVertex(GET_DISPATCH(), (mode, count[i], type,
866 indices[i],
867 basevertex[i]));
868 }
869 }
870 }
871
872 /*
873 * Eval Mesh
874 */
875
876 /**
877 * KW:
878 * If are compiling, we don't know whether eval will produce a
879 * vertex when it is run in the future. If this is pure immediate
880 * mode, eval is a noop if neither vertex map is enabled.
881 *
882 * Thus we need to have a check in the display list code or elsewhere
883 * for eval(1,2) vertices in the case where map(1,2)_vertex is
884 * disabled, and to purge those vertices from the vb.
885 */
886 void GLAPIENTRY
887 _mesa_noop_EvalMesh1( GLenum mode, GLint i1, GLint i2 )
888 {
889 GET_CURRENT_CONTEXT(ctx);
890 GLint i;
891 GLfloat u, du;
892 GLenum prim;
893
894 switch (mode) {
895 case GL_POINT:
896 prim = GL_POINTS;
897 break;
898 case GL_LINE:
899 prim = GL_LINE_STRIP;
900 break;
901 default:
902 _mesa_error( ctx, GL_INVALID_ENUM, "glEvalMesh1(mode)" );
903 return;
904 }
905
906 /* No effect if vertex maps disabled.
907 */
908 if (!ctx->Eval.Map1Vertex4 &&
909 !ctx->Eval.Map1Vertex3 &&
910 !(ctx->VertexProgram._Enabled && ctx->Eval.Map1Attrib[VERT_ATTRIB_POS]))
911 return;
912
913 du = ctx->Eval.MapGrid1du;
914 u = ctx->Eval.MapGrid1u1 + i1 * du;
915
916 CALL_Begin(GET_DISPATCH(), (prim));
917 for (i=i1;i<=i2;i++,u+=du) {
918 CALL_EvalCoord1f(GET_DISPATCH(), (u));
919 }
920 CALL_End(GET_DISPATCH(), ());
921 }
922
923
924
925 void GLAPIENTRY
926 _mesa_noop_EvalMesh2( GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2 )
927 {
928 GET_CURRENT_CONTEXT(ctx);
929 GLfloat u, du, v, dv, v1, u1;
930 GLint i, j;
931
932 switch (mode) {
933 case GL_POINT:
934 case GL_LINE:
935 case GL_FILL:
936 break;
937 default:
938 _mesa_error( ctx, GL_INVALID_ENUM, "glEvalMesh2(mode)" );
939 return;
940 }
941
942 /* No effect if vertex maps disabled.
943 */
944 if (!ctx->Eval.Map2Vertex4 &&
945 !ctx->Eval.Map2Vertex3 &&
946 !(ctx->VertexProgram._Enabled && ctx->Eval.Map2Attrib[VERT_ATTRIB_POS]))
947 return;
948
949 du = ctx->Eval.MapGrid2du;
950 dv = ctx->Eval.MapGrid2dv;
951 v1 = ctx->Eval.MapGrid2v1 + j1 * dv;
952 u1 = ctx->Eval.MapGrid2u1 + i1 * du;
953
954 switch (mode) {
955 case GL_POINT:
956 CALL_Begin(GET_DISPATCH(), (GL_POINTS));
957 for (v=v1,j=j1;j<=j2;j++,v+=dv) {
958 for (u=u1,i=i1;i<=i2;i++,u+=du) {
959 CALL_EvalCoord2f(GET_DISPATCH(), (u, v));
960 }
961 }
962 CALL_End(GET_DISPATCH(), ());
963 break;
964 case GL_LINE:
965 for (v=v1,j=j1;j<=j2;j++,v+=dv) {
966 CALL_Begin(GET_DISPATCH(), (GL_LINE_STRIP));
967 for (u=u1,i=i1;i<=i2;i++,u+=du) {
968 CALL_EvalCoord2f(GET_DISPATCH(), (u, v));
969 }
970 CALL_End(GET_DISPATCH(), ());
971 }
972 for (u=u1,i=i1;i<=i2;i++,u+=du) {
973 CALL_Begin(GET_DISPATCH(), (GL_LINE_STRIP));
974 for (v=v1,j=j1;j<=j2;j++,v+=dv) {
975 CALL_EvalCoord2f(GET_DISPATCH(), (u, v));
976 }
977 CALL_End(GET_DISPATCH(), ());
978 }
979 break;
980 case GL_FILL:
981 for (v=v1,j=j1;j<j2;j++,v+=dv) {
982 CALL_Begin(GET_DISPATCH(), (GL_TRIANGLE_STRIP));
983 for (u=u1,i=i1;i<=i2;i++,u+=du) {
984 CALL_EvalCoord2f(GET_DISPATCH(), (u, v));
985 CALL_EvalCoord2f(GET_DISPATCH(), (u, v+dv));
986 }
987 CALL_End(GET_DISPATCH(), ());
988 }
989 break;
990 default:
991 _mesa_error( ctx, GL_INVALID_ENUM, "glEvalMesh2(mode)" );
992 return;
993 }
994 }
995
996
997
998 /**
999 * Build a vertexformat of functions to use outside begin/end pairs.
1000 *
1001 * TODO -- build a whole dispatch table for this purpose, and likewise
1002 * for inside begin/end.
1003 */
1004 void
1005 _mesa_noop_vtxfmt_init( GLvertexformat *vfmt )
1006 {
1007 _MESA_INIT_ARRAYELT_VTXFMT(vfmt, _ae_);
1008
1009 vfmt->Begin = _mesa_noop_Begin;
1010
1011 _MESA_INIT_DLIST_VTXFMT(vfmt, _mesa_);
1012
1013 vfmt->Color3f = _mesa_noop_Color3f;
1014 vfmt->Color3fv = _mesa_noop_Color3fv;
1015 vfmt->Color4f = _mesa_noop_Color4f;
1016 vfmt->Color4fv = _mesa_noop_Color4fv;
1017 vfmt->EdgeFlag = _mesa_noop_EdgeFlag;
1018 vfmt->End = _mesa_noop_End;
1019
1020 vfmt->PrimitiveRestartNV = _mesa_noop_PrimitiveRestartNV;
1021
1022 _MESA_INIT_EVAL_VTXFMT(vfmt, _mesa_noop_);
1023
1024 vfmt->FogCoordfEXT = _mesa_noop_FogCoordfEXT;
1025 vfmt->FogCoordfvEXT = _mesa_noop_FogCoordfvEXT;
1026 vfmt->Indexf = _mesa_noop_Indexf;
1027 vfmt->Indexfv = _mesa_noop_Indexfv;
1028 vfmt->Materialfv = _mesa_noop_Materialfv;
1029 vfmt->MultiTexCoord1fARB = _mesa_noop_MultiTexCoord1fARB;
1030 vfmt->MultiTexCoord1fvARB = _mesa_noop_MultiTexCoord1fvARB;
1031 vfmt->MultiTexCoord2fARB = _mesa_noop_MultiTexCoord2fARB;
1032 vfmt->MultiTexCoord2fvARB = _mesa_noop_MultiTexCoord2fvARB;
1033 vfmt->MultiTexCoord3fARB = _mesa_noop_MultiTexCoord3fARB;
1034 vfmt->MultiTexCoord3fvARB = _mesa_noop_MultiTexCoord3fvARB;
1035 vfmt->MultiTexCoord4fARB = _mesa_noop_MultiTexCoord4fARB;
1036 vfmt->MultiTexCoord4fvARB = _mesa_noop_MultiTexCoord4fvARB;
1037 vfmt->Normal3f = _mesa_noop_Normal3f;
1038 vfmt->Normal3fv = _mesa_noop_Normal3fv;
1039 vfmt->SecondaryColor3fEXT = _mesa_noop_SecondaryColor3fEXT;
1040 vfmt->SecondaryColor3fvEXT = _mesa_noop_SecondaryColor3fvEXT;
1041 vfmt->TexCoord1f = _mesa_noop_TexCoord1f;
1042 vfmt->TexCoord1fv = _mesa_noop_TexCoord1fv;
1043 vfmt->TexCoord2f = _mesa_noop_TexCoord2f;
1044 vfmt->TexCoord2fv = _mesa_noop_TexCoord2fv;
1045 vfmt->TexCoord3f = _mesa_noop_TexCoord3f;
1046 vfmt->TexCoord3fv = _mesa_noop_TexCoord3fv;
1047 vfmt->TexCoord4f = _mesa_noop_TexCoord4f;
1048 vfmt->TexCoord4fv = _mesa_noop_TexCoord4fv;
1049 vfmt->Vertex2f = _mesa_noop_Vertex2f;
1050 vfmt->Vertex2fv = _mesa_noop_Vertex2fv;
1051 vfmt->Vertex3f = _mesa_noop_Vertex3f;
1052 vfmt->Vertex3fv = _mesa_noop_Vertex3fv;
1053 vfmt->Vertex4f = _mesa_noop_Vertex4f;
1054 vfmt->Vertex4fv = _mesa_noop_Vertex4fv;
1055 vfmt->VertexAttrib1fNV = _mesa_noop_VertexAttrib1fNV;
1056 vfmt->VertexAttrib1fvNV = _mesa_noop_VertexAttrib1fvNV;
1057 vfmt->VertexAttrib2fNV = _mesa_noop_VertexAttrib2fNV;
1058 vfmt->VertexAttrib2fvNV = _mesa_noop_VertexAttrib2fvNV;
1059 vfmt->VertexAttrib3fNV = _mesa_noop_VertexAttrib3fNV;
1060 vfmt->VertexAttrib3fvNV = _mesa_noop_VertexAttrib3fvNV;
1061 vfmt->VertexAttrib4fNV = _mesa_noop_VertexAttrib4fNV;
1062 vfmt->VertexAttrib4fvNV = _mesa_noop_VertexAttrib4fvNV;
1063 vfmt->VertexAttrib1fARB = _mesa_noop_VertexAttrib1fARB;
1064 vfmt->VertexAttrib1fvARB = _mesa_noop_VertexAttrib1fvARB;
1065 vfmt->VertexAttrib2fARB = _mesa_noop_VertexAttrib2fARB;
1066 vfmt->VertexAttrib2fvARB = _mesa_noop_VertexAttrib2fvARB;
1067 vfmt->VertexAttrib3fARB = _mesa_noop_VertexAttrib3fARB;
1068 vfmt->VertexAttrib3fvARB = _mesa_noop_VertexAttrib3fvARB;
1069 vfmt->VertexAttrib4fARB = _mesa_noop_VertexAttrib4fARB;
1070 vfmt->VertexAttrib4fvARB = _mesa_noop_VertexAttrib4fvARB;
1071
1072 vfmt->Rectf = _mesa_noop_Rectf;
1073
1074 vfmt->DrawArrays = _mesa_noop_DrawArrays;
1075 vfmt->DrawElements = _mesa_noop_DrawElements;
1076 vfmt->DrawRangeElements = _mesa_noop_DrawRangeElements;
1077 vfmt->MultiDrawElementsEXT = _mesa_noop_MultiDrawElements;
1078 vfmt->DrawElementsBaseVertex = _mesa_noop_DrawElementsBaseVertex;
1079 vfmt->DrawRangeElementsBaseVertex = _mesa_noop_DrawRangeElementsBaseVertex;
1080 vfmt->MultiDrawElementsBaseVertex = _mesa_noop_MultiDrawElementsBaseVertex;
1081 }
1082
1083
1084 #endif /* FEATURE_beginend */