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