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