bde37e70e3d50b37f3641eaa691b3222affe4f12
[mesa.git] / src / mesa / main / api_noop.c
1
2 /*
3 * Mesa 3-D graphics library
4 * Version: 5.1
5 *
6 * Copyright (C) 1999-2003 Brian Paul All Rights Reserved.
7 *
8 * Permission is hereby granted, free of charge, to any person obtaining a
9 * copy of this software and associated documentation files (the "Software"),
10 * to deal in the Software without restriction, including without limitation
11 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
12 * and/or sell copies of the Software, and to permit persons to whom the
13 * Software is furnished to do so, subject to the following conditions:
14 *
15 * The above copyright notice and this permission notice shall be included
16 * in all copies or substantial portions of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
22 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 */
25
26
27 #include "glheader.h"
28 #include "api_noop.h"
29 #include "api_validate.h"
30 #include "api_arrayelt.h"
31 #include "context.h"
32 #include "colormac.h"
33 #include "light.h"
34 #include "macros.h"
35 #include "mtypes.h"
36 #include "dlist.h"
37
38
39 /* In states where certain vertex components are required for t&l or
40 * rasterization, we still need to keep track of the current values.
41 * These functions provide this service by keeping uptodate the
42 * 'ctx->Current' struct for all data elements not included in the
43 * currently enabled hardware vertex.
44 *
45 */
46 void GLAPIENTRY _mesa_noop_EdgeFlag( GLboolean b )
47 {
48 GET_CURRENT_CONTEXT(ctx);
49 ctx->Current.EdgeFlag = b;
50 }
51
52 void GLAPIENTRY _mesa_noop_EdgeFlagv( const GLboolean *b )
53 {
54 GET_CURRENT_CONTEXT(ctx);
55 ctx->Current.EdgeFlag = *b;
56 }
57
58 void GLAPIENTRY _mesa_noop_Indexf( GLfloat f )
59 {
60 GET_CURRENT_CONTEXT(ctx);
61 ctx->Current.Index = f;
62 }
63
64 void GLAPIENTRY _mesa_noop_Indexfv( const GLfloat *v )
65 {
66 GET_CURRENT_CONTEXT(ctx);
67 ctx->Current.Index = *v;
68 }
69
70 void GLAPIENTRY _mesa_noop_FogCoordfEXT( GLfloat a )
71 {
72 GET_CURRENT_CONTEXT(ctx);
73 GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_FOG];
74 dest[0] = a;
75 dest[1] = 0.0;
76 dest[2] = 0.0;
77 dest[3] = 1.0;
78 }
79
80 void GLAPIENTRY _mesa_noop_FogCoordfvEXT( const GLfloat *v )
81 {
82 GET_CURRENT_CONTEXT(ctx);
83 GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_NORMAL];
84 dest[0] = v[0];
85 dest[1] = 0.0;
86 dest[2] = 0.0;
87 dest[3] = 1.0;
88 }
89
90 void GLAPIENTRY _mesa_noop_Normal3f( GLfloat a, GLfloat b, GLfloat c )
91 {
92 GET_CURRENT_CONTEXT(ctx);
93 GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_NORMAL];
94 dest[0] = a;
95 dest[1] = b;
96 dest[2] = c;
97 dest[3] = 1.0;
98 }
99
100 void GLAPIENTRY _mesa_noop_Normal3fv( const GLfloat *v )
101 {
102 GET_CURRENT_CONTEXT(ctx);
103 GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_NORMAL];
104 dest[0] = v[0];
105 dest[1] = v[1];
106 dest[2] = v[2];
107 dest[3] = 1.0;
108 }
109
110 void GLAPIENTRY _mesa_noop_Color4f( GLfloat a, GLfloat b, GLfloat c, GLfloat d )
111 {
112 GET_CURRENT_CONTEXT(ctx);
113 GLfloat *color = ctx->Current.Attrib[VERT_ATTRIB_COLOR0];
114 color[0] = a;
115 color[1] = b;
116 color[2] = c;
117 color[3] = d;
118 }
119
120 void GLAPIENTRY _mesa_noop_Color4fv( const GLfloat *v )
121 {
122 GET_CURRENT_CONTEXT(ctx);
123 GLfloat *color = ctx->Current.Attrib[VERT_ATTRIB_COLOR0];
124 color[0] = v[0];
125 color[1] = v[1];
126 color[2] = v[2];
127 color[3] = v[3];
128 }
129
130 void GLAPIENTRY _mesa_noop_Color3f( GLfloat a, GLfloat b, GLfloat c )
131 {
132 GET_CURRENT_CONTEXT(ctx);
133 GLfloat *color = ctx->Current.Attrib[VERT_ATTRIB_COLOR0];
134 color[0] = a;
135 color[1] = b;
136 color[2] = c;
137 color[3] = 1.0;
138 }
139
140 void GLAPIENTRY _mesa_noop_Color3fv( const GLfloat *v )
141 {
142 GET_CURRENT_CONTEXT(ctx);
143 GLfloat *color = ctx->Current.Attrib[VERT_ATTRIB_COLOR0];
144 color[0] = v[0];
145 color[1] = v[1];
146 color[2] = v[2];
147 color[3] = 1.0;
148 }
149
150 void GLAPIENTRY _mesa_noop_MultiTexCoord1fARB( GLenum target, GLfloat a )
151 {
152 GET_CURRENT_CONTEXT(ctx);
153 GLuint unit = target - GL_TEXTURE0_ARB;
154
155 /* unit is unsigned -- cannot be less than zero.
156 */
157 if (unit < MAX_TEXTURE_COORD_UNITS)
158 {
159 GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit];
160 dest[0] = a;
161 dest[1] = 0;
162 dest[2] = 0;
163 dest[3] = 1;
164 }
165 }
166
167 void GLAPIENTRY _mesa_noop_MultiTexCoord1fvARB( GLenum target, const GLfloat *v )
168 {
169 GET_CURRENT_CONTEXT(ctx);
170 GLuint unit = target - GL_TEXTURE0_ARB;
171
172 /* unit is unsigned -- cannot be less than zero.
173 */
174 if (unit < MAX_TEXTURE_COORD_UNITS)
175 {
176 GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit];
177 dest[0] = v[0];
178 dest[1] = 0;
179 dest[2] = 0;
180 dest[3] = 1;
181 }
182 }
183
184 void GLAPIENTRY _mesa_noop_MultiTexCoord2fARB( GLenum target, GLfloat a, GLfloat b )
185 {
186 GET_CURRENT_CONTEXT(ctx);
187 GLuint unit = target - GL_TEXTURE0_ARB;
188
189 /* unit is unsigned -- cannot be less than zero.
190 */
191 if (unit < MAX_TEXTURE_COORD_UNITS)
192 {
193 GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit];
194 dest[0] = a;
195 dest[1] = b;
196 dest[2] = 0;
197 dest[3] = 1;
198 }
199 }
200
201 void GLAPIENTRY _mesa_noop_MultiTexCoord2fvARB( GLenum target, const GLfloat *v )
202 {
203 GET_CURRENT_CONTEXT(ctx);
204 GLuint unit = target - GL_TEXTURE0_ARB;
205
206 /* unit is unsigned -- cannot be less than zero.
207 */
208 if (unit < MAX_TEXTURE_COORD_UNITS)
209 {
210 GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit];
211 dest[0] = v[0];
212 dest[1] = v[1];
213 dest[2] = 0;
214 dest[3] = 1;
215 }
216 }
217
218 void GLAPIENTRY _mesa_noop_MultiTexCoord3fARB( GLenum target, GLfloat a, GLfloat b, GLfloat c)
219 {
220 GET_CURRENT_CONTEXT(ctx);
221 GLuint unit = target - GL_TEXTURE0_ARB;
222
223 /* unit is unsigned -- cannot be less than zero.
224 */
225 if (unit < MAX_TEXTURE_COORD_UNITS)
226 {
227 GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit];
228 dest[0] = a;
229 dest[1] = b;
230 dest[2] = c;
231 dest[3] = 1;
232 }
233 }
234
235 void GLAPIENTRY _mesa_noop_MultiTexCoord3fvARB( GLenum target, const GLfloat *v )
236 {
237 GET_CURRENT_CONTEXT(ctx);
238 GLuint unit = target - GL_TEXTURE0_ARB;
239
240 /* unit is unsigned -- cannot be less than zero.
241 */
242 if (unit < MAX_TEXTURE_COORD_UNITS)
243 {
244 GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit];
245 dest[0] = v[0];
246 dest[1] = v[1];
247 dest[2] = v[2];
248 dest[3] = 1;
249 }
250 }
251
252 void GLAPIENTRY _mesa_noop_MultiTexCoord4fARB( GLenum target, GLfloat a, GLfloat b,
253 GLfloat c, GLfloat d )
254 {
255 GET_CURRENT_CONTEXT(ctx);
256 GLuint unit = target - GL_TEXTURE0_ARB;
257
258 /* unit is unsigned -- cannot be less than zero.
259 */
260 if (unit < MAX_TEXTURE_COORD_UNITS)
261 {
262 GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit];
263 dest[0] = a;
264 dest[1] = b;
265 dest[2] = c;
266 dest[3] = d;
267 }
268 }
269
270 void GLAPIENTRY _mesa_noop_MultiTexCoord4fvARB( GLenum target, const GLfloat *v )
271 {
272 GET_CURRENT_CONTEXT(ctx);
273 GLuint unit = target - GL_TEXTURE0_ARB;
274
275 /* unit is unsigned -- cannot be less than zero.
276 */
277 if (unit < MAX_TEXTURE_COORD_UNITS)
278 {
279 GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit];
280 dest[0] = v[0];
281 dest[1] = v[1];
282 dest[2] = v[2];
283 dest[3] = v[3];
284 }
285 }
286
287 void GLAPIENTRY _mesa_noop_SecondaryColor3fEXT( GLfloat a, GLfloat b, GLfloat c )
288 {
289 GET_CURRENT_CONTEXT(ctx);
290 GLfloat *color = ctx->Current.Attrib[VERT_ATTRIB_COLOR1];
291 color[0] = a;
292 color[1] = b;
293 color[2] = c;
294 color[3] = 1.0;
295 }
296
297 void GLAPIENTRY _mesa_noop_SecondaryColor3fvEXT( const GLfloat *v )
298 {
299 GET_CURRENT_CONTEXT(ctx);
300 GLfloat *color = ctx->Current.Attrib[VERT_ATTRIB_COLOR1];
301 color[0] = v[0];
302 color[1] = v[1];
303 color[2] = v[2];
304 color[3] = 1.0;
305 }
306
307 void GLAPIENTRY _mesa_noop_TexCoord1f( GLfloat a )
308 {
309 GET_CURRENT_CONTEXT(ctx);
310 GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_TEX0];
311 dest[0] = a;
312 dest[1] = 0;
313 dest[2] = 0;
314 dest[3] = 1;
315 }
316
317 void GLAPIENTRY _mesa_noop_TexCoord1fv( const GLfloat *v )
318 {
319 GET_CURRENT_CONTEXT(ctx);
320 GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_TEX0];
321 dest[0] = v[0];
322 dest[1] = 0;
323 dest[2] = 0;
324 dest[3] = 1;
325 }
326
327 void GLAPIENTRY _mesa_noop_TexCoord2f( GLfloat a, GLfloat b )
328 {
329 GET_CURRENT_CONTEXT(ctx);
330 GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_TEX0];
331 dest[0] = a;
332 dest[1] = b;
333 dest[2] = 0;
334 dest[3] = 1;
335 }
336
337 void GLAPIENTRY _mesa_noop_TexCoord2fv( const GLfloat *v )
338 {
339 GET_CURRENT_CONTEXT(ctx);
340 GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_TEX0];
341 dest[0] = v[0];
342 dest[1] = v[1];
343 dest[2] = 0;
344 dest[3] = 1;
345 }
346
347 void GLAPIENTRY _mesa_noop_TexCoord3f( GLfloat a, GLfloat b, GLfloat c )
348 {
349 GET_CURRENT_CONTEXT(ctx);
350 GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_TEX0];
351 dest[0] = a;
352 dest[1] = b;
353 dest[2] = c;
354 dest[3] = 1;
355 }
356
357 void GLAPIENTRY _mesa_noop_TexCoord3fv( const GLfloat *v )
358 {
359 GET_CURRENT_CONTEXT(ctx);
360 GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_TEX0];
361 dest[0] = v[0];
362 dest[1] = v[1];
363 dest[2] = v[2];
364 dest[3] = 1;
365 }
366
367 void GLAPIENTRY _mesa_noop_TexCoord4f( GLfloat a, GLfloat b, GLfloat c, GLfloat d )
368 {
369 GET_CURRENT_CONTEXT(ctx);
370 GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_TEX0];
371 dest[0] = a;
372 dest[1] = b;
373 dest[2] = c;
374 dest[3] = d;
375 }
376
377 void GLAPIENTRY _mesa_noop_TexCoord4fv( const GLfloat *v )
378 {
379 GET_CURRENT_CONTEXT(ctx);
380 GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_TEX0];
381 dest[0] = v[0];
382 dest[1] = v[1];
383 dest[2] = v[2];
384 dest[3] = v[3];
385 }
386
387
388
389 void GLAPIENTRY _mesa_noop_VertexAttrib1fNV( GLuint index, GLfloat x )
390 {
391 GET_CURRENT_CONTEXT(ctx);
392 if (index < VERT_ATTRIB_MAX) {
393 ASSIGN_4V(ctx->Current.Attrib[index], x, 0, 0, 1);
394 }
395 else
396 _mesa_error( ctx, GL_INVALID_ENUM, "glVertexAttrib1f" );
397 }
398
399 void GLAPIENTRY _mesa_noop_VertexAttrib1fvNV( GLuint index, const GLfloat *v )
400 {
401 GET_CURRENT_CONTEXT(ctx);
402 if (index < VERT_ATTRIB_MAX) {
403 ASSIGN_4V(ctx->Current.Attrib[index], v[0], 0, 0, 1);
404 }
405 else
406 _mesa_error( ctx, GL_INVALID_ENUM, "glVertexAttrib1fv" );
407 }
408
409 void GLAPIENTRY _mesa_noop_VertexAttrib2fNV( GLuint index, GLfloat x, GLfloat y )
410 {
411 GET_CURRENT_CONTEXT(ctx);
412 if (index < VERT_ATTRIB_MAX) {
413 ASSIGN_4V(ctx->Current.Attrib[index], x, y, 0, 1);
414 }
415 else
416 _mesa_error( ctx, GL_INVALID_ENUM, "glVertexAttrib2f" );
417 }
418
419 void GLAPIENTRY _mesa_noop_VertexAttrib2fvNV( GLuint index, const GLfloat *v )
420 {
421 GET_CURRENT_CONTEXT(ctx);
422 if (index < VERT_ATTRIB_MAX) {
423 ASSIGN_4V(ctx->Current.Attrib[index], v[0], v[1], 0, 1);
424 }
425 else
426 _mesa_error( ctx, GL_INVALID_ENUM, "glVertexAttrib2fv" );
427 }
428
429 void GLAPIENTRY _mesa_noop_VertexAttrib3fNV( GLuint index, GLfloat x,
430 GLfloat y, GLfloat z )
431 {
432 GET_CURRENT_CONTEXT(ctx);
433 if (index < VERT_ATTRIB_MAX) {
434 ASSIGN_4V(ctx->Current.Attrib[index], x, y, z, 1);
435 }
436 else
437 _mesa_error( ctx, GL_INVALID_ENUM, "glVertexAttrib3f" );
438 }
439
440 void GLAPIENTRY _mesa_noop_VertexAttrib3fvNV( GLuint index, const GLfloat *v )
441 {
442 GET_CURRENT_CONTEXT(ctx);
443 if (index < VERT_ATTRIB_MAX) {
444 ASSIGN_4V(ctx->Current.Attrib[index], v[0], v[1], v[2], 1);
445 }
446 else
447 _mesa_error( ctx, GL_INVALID_ENUM, "glVertexAttrib3fv" );
448 }
449
450 void GLAPIENTRY _mesa_noop_VertexAttrib4fNV( GLuint index, GLfloat x,
451 GLfloat y, GLfloat z, GLfloat w )
452 {
453 GET_CURRENT_CONTEXT(ctx);
454 if (index < VERT_ATTRIB_MAX) {
455 ASSIGN_4V(ctx->Current.Attrib[index], x, y, z, w);
456 }
457 else
458 _mesa_error( ctx, GL_INVALID_ENUM, "glVertexAttrib4f" );
459 }
460
461 void GLAPIENTRY _mesa_noop_VertexAttrib4fvNV( GLuint index, const GLfloat *v )
462 {
463 GET_CURRENT_CONTEXT(ctx);
464 if (index < VERT_ATTRIB_MAX) {
465 ASSIGN_4V(ctx->Current.Attrib[index], v[0], v[1], v[2], v[3]);
466 }
467 else
468 _mesa_error( ctx, GL_INVALID_ENUM, "glVertexAttrib4fv" );
469 }
470
471 /* Material
472 */
473 void GLAPIENTRY _mesa_noop_Materialfv( GLenum face, GLenum pname, const GLfloat *params )
474 {
475 GET_CURRENT_CONTEXT(ctx);
476 GLint i, nr;
477 struct gl_material *mat = &ctx->Light.Material;
478 GLuint bitmask = _mesa_material_bitmask( ctx, face, pname, ~0,
479 "_mesa_noop_Materialfv" );
480
481 if (ctx->Light.ColorMaterialEnabled)
482 bitmask &= ~ctx->Light.ColorMaterialBitmask;
483
484 if (bitmask == 0)
485 return;
486
487 switch (face) {
488 case GL_SHININESS: nr = 1; break;
489 case GL_COLOR_INDEXES: nr = 3; break;
490 default: nr = 4 ; break;
491 }
492
493 for (i = 0 ; i < MAT_ATTRIB_MAX ; i++)
494 if (bitmask & (1<<i))
495 COPY_SZ_4V( mat->Attrib[i], nr, params );
496
497 _mesa_update_material( ctx, bitmask );
498 }
499
500 /* These really are noops outside begin/end:
501 */
502 void GLAPIENTRY _mesa_noop_Vertex2fv( const GLfloat *v )
503 {
504 (void) v;
505 }
506
507 void GLAPIENTRY _mesa_noop_Vertex3fv( const GLfloat *v )
508 {
509 (void) v;
510 }
511
512 void GLAPIENTRY _mesa_noop_Vertex4fv( const GLfloat *v )
513 {
514 (void) v;
515 }
516
517 void GLAPIENTRY _mesa_noop_Vertex2f( GLfloat a, GLfloat b )
518 {
519 (void) a; (void) b;
520 }
521
522 void GLAPIENTRY _mesa_noop_Vertex3f( GLfloat a, GLfloat b, GLfloat c )
523 {
524 (void) a; (void) b; (void) c;
525 }
526
527 void GLAPIENTRY _mesa_noop_Vertex4f( GLfloat a, GLfloat b, GLfloat c, GLfloat d )
528 {
529 (void) a; (void) b; (void) c; (void) d;
530 }
531
532 /* Similarly, these have no effect outside begin/end:
533 */
534 void GLAPIENTRY _mesa_noop_EvalCoord1f( GLfloat a )
535 {
536 (void) a;
537 }
538
539 void GLAPIENTRY _mesa_noop_EvalCoord1fv( const GLfloat *v )
540 {
541 (void) v;
542 }
543
544 void GLAPIENTRY _mesa_noop_EvalCoord2f( GLfloat a, GLfloat b )
545 {
546 (void) a; (void) b;
547 }
548
549 void GLAPIENTRY _mesa_noop_EvalCoord2fv( const GLfloat *v )
550 {
551 (void) v;
552 }
553
554 void GLAPIENTRY _mesa_noop_EvalPoint1( GLint a )
555 {
556 (void) a;
557 }
558
559 void GLAPIENTRY _mesa_noop_EvalPoint2( GLint a, GLint b )
560 {
561 (void) a; (void) b;
562 }
563
564
565 /* Begin -- call into driver, should result in the vtxfmt being
566 * swapped out:
567 */
568 void GLAPIENTRY _mesa_noop_Begin( GLenum mode )
569 {
570 }
571
572
573 /* End -- just raise an error
574 */
575 void GLAPIENTRY _mesa_noop_End( void )
576 {
577 GET_CURRENT_CONTEXT(ctx);
578 _mesa_error( ctx, GL_INVALID_OPERATION, "glEnd" );
579 }
580
581
582 /* Execute a glRectf() function. This is not suitable for GL_COMPILE
583 * modes (as the test for outside begin/end is not compiled),
584 * but may be useful for drivers in circumstances which exclude
585 * display list interactions.
586 *
587 * (None of the functions in this file are suitable for GL_COMPILE
588 * modes).
589 */
590 void GLAPIENTRY _mesa_noop_Rectf( GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2 )
591 {
592 {
593 GET_CURRENT_CONTEXT(ctx);
594 ASSERT_OUTSIDE_BEGIN_END(ctx);
595 }
596
597 glBegin( GL_QUADS );
598 glVertex2f( x1, y1 );
599 glVertex2f( x2, y1 );
600 glVertex2f( x2, y2 );
601 glVertex2f( x1, y2 );
602 glEnd();
603 }
604
605
606 /* Some very basic support for arrays. Drivers without explicit array
607 * support can hook these in, but still need to supply an array-elt
608 * implementation.
609 */
610 void GLAPIENTRY _mesa_noop_DrawArrays(GLenum mode, GLint start, GLsizei count)
611 {
612 GET_CURRENT_CONTEXT(ctx);
613 GLint i;
614
615 if (!_mesa_validate_DrawArrays( ctx, mode, start, count ))
616 return;
617
618 glBegin(mode);
619 for (i = start ; i < count ; i++)
620 glArrayElement( i );
621 glEnd();
622 }
623
624
625 void GLAPIENTRY _mesa_noop_DrawElements(GLenum mode, GLsizei count, GLenum type,
626 const GLvoid *indices)
627 {
628 GET_CURRENT_CONTEXT(ctx);
629 GLint i;
630
631 if (!_mesa_validate_DrawElements( ctx, mode, count, type, indices ))
632 return;
633
634 glBegin(mode);
635
636 switch (type) {
637 case GL_UNSIGNED_BYTE:
638 for (i = 0 ; i < count ; i++)
639 glArrayElement( ((GLubyte *)indices)[i] );
640 break;
641 case GL_UNSIGNED_SHORT:
642 for (i = 0 ; i < count ; i++)
643 glArrayElement( ((GLushort *)indices)[i] );
644 break;
645 case GL_UNSIGNED_INT:
646 for (i = 0 ; i < count ; i++)
647 glArrayElement( ((GLuint *)indices)[i] );
648 break;
649 default:
650 _mesa_error( ctx, GL_INVALID_ENUM, "glDrawElements(type)" );
651 break;
652 }
653
654 glEnd();
655 }
656
657 void GLAPIENTRY _mesa_noop_DrawRangeElements(GLenum mode,
658 GLuint start, GLuint end,
659 GLsizei count, GLenum type,
660 const GLvoid *indices)
661 {
662 GET_CURRENT_CONTEXT(ctx);
663
664 if (_mesa_validate_DrawRangeElements( ctx, mode,
665 start, end,
666 count, type, indices ))
667 glDrawElements( mode, count, type, indices );
668 }
669
670 /*
671 * Eval Mesh
672 */
673
674 /* KW: If are compiling, we don't know whether eval will produce a
675 * vertex when it is run in the future. If this is pure immediate
676 * mode, eval is a noop if neither vertex map is enabled.
677 *
678 * Thus we need to have a check in the display list code or
679 * elsewhere for eval(1,2) vertices in the case where
680 * map(1,2)_vertex is disabled, and to purge those vertices from
681 * the vb.
682 */
683 void GLAPIENTRY _mesa_noop_EvalMesh1( GLenum mode, GLint i1, GLint i2 )
684 {
685 GET_CURRENT_CONTEXT(ctx);
686 GLint i;
687 GLfloat u, du;
688 GLenum prim;
689
690 switch (mode) {
691 case GL_POINT:
692 prim = GL_POINTS;
693 break;
694 case GL_LINE:
695 prim = GL_LINE_STRIP;
696 break;
697 default:
698 _mesa_error( ctx, GL_INVALID_ENUM, "glEvalMesh1(mode)" );
699 return;
700 }
701
702 /* No effect if vertex maps disabled.
703 */
704 if (!ctx->Eval.Map1Vertex4 &&
705 !ctx->Eval.Map1Vertex3 &&
706 !(ctx->VertexProgram.Enabled && ctx->Eval.Map1Attrib[VERT_ATTRIB_POS]))
707 return;
708
709 du = ctx->Eval.MapGrid1du;
710 u = ctx->Eval.MapGrid1u1 + i1 * du;
711
712 glBegin( prim );
713 for (i=i1;i<=i2;i++,u+=du) {
714 glEvalCoord1f( u );
715 }
716 glEnd();
717 }
718
719
720
721 void GLAPIENTRY _mesa_noop_EvalMesh2( GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2 )
722 {
723 GET_CURRENT_CONTEXT(ctx);
724 GLfloat u, du, v, dv, v1, u1;
725 GLint i, j;
726
727 switch (mode) {
728 case GL_POINT:
729 case GL_LINE:
730 case GL_FILL:
731 break;
732 default:
733 _mesa_error( ctx, GL_INVALID_ENUM, "glEvalMesh2(mode)" );
734 return;
735 }
736
737 /* No effect if vertex maps disabled.
738 */
739 if (!ctx->Eval.Map2Vertex4 &&
740 !ctx->Eval.Map2Vertex3 &&
741 !(ctx->VertexProgram.Enabled && ctx->Eval.Map2Attrib[VERT_ATTRIB_POS]))
742 return;
743
744 du = ctx->Eval.MapGrid2du;
745 dv = ctx->Eval.MapGrid2dv;
746 v1 = ctx->Eval.MapGrid2v1 + j1 * dv;
747 u1 = ctx->Eval.MapGrid2u1 + i1 * du;
748
749 switch (mode) {
750 case GL_POINT:
751 glBegin( GL_POINTS );
752 for (v=v1,j=j1;j<=j2;j++,v+=dv) {
753 for (u=u1,i=i1;i<=i2;i++,u+=du) {
754 glEvalCoord2f(u, v );
755 }
756 }
757 glEnd();
758 break;
759 case GL_LINE:
760 for (v=v1,j=j1;j<=j2;j++,v+=dv) {
761 glBegin( GL_LINE_STRIP );
762 for (u=u1,i=i1;i<=i2;i++,u+=du) {
763 glEvalCoord2f(u, v );
764 }
765 glEnd();
766 }
767 for (u=u1,i=i1;i<=i2;i++,u+=du) {
768 glBegin( GL_LINE_STRIP );
769 for (v=v1,j=j1;j<=j2;j++,v+=dv) {
770 glEvalCoord2f(u, v );
771 }
772 glEnd();
773 }
774 break;
775 case GL_FILL:
776 for (v=v1,j=j1;j<j2;j++,v+=dv) {
777 glBegin( GL_TRIANGLE_STRIP );
778 for (u=u1,i=i1;i<=i2;i++,u+=du) {
779 glEvalCoord2f(u, v );
780 glEvalCoord2f(u, v+dv );
781 }
782 glEnd();
783 }
784 break;
785 default:
786 _mesa_error( ctx, GL_INVALID_ENUM, "glEvalMesh2(mode)" );
787 return;
788 }
789 }
790
791
792
793 /* Build a vertexformat full of things to use outside begin/end pairs.
794 *
795 * TODO -- build a whole dispatch table for this purpose, and likewise
796 * for inside begin/end.
797 */
798 void _mesa_noop_vtxfmt_init( GLvertexformat *vfmt )
799 {
800 vfmt->ArrayElement = _ae_loopback_array_elt; /* generic helper */
801 vfmt->Begin = _mesa_noop_Begin;
802 vfmt->CallList = _mesa_CallList;
803 vfmt->CallLists = _mesa_CallLists;
804 vfmt->Color3f = _mesa_noop_Color3f;
805 vfmt->Color3fv = _mesa_noop_Color3fv;
806 vfmt->Color4f = _mesa_noop_Color4f;
807 vfmt->Color4fv = _mesa_noop_Color4fv;
808 vfmt->EdgeFlag = _mesa_noop_EdgeFlag;
809 vfmt->EdgeFlagv = _mesa_noop_EdgeFlagv;
810 vfmt->End = _mesa_noop_End;
811 vfmt->EvalCoord1f = _mesa_noop_EvalCoord1f;
812 vfmt->EvalCoord1fv = _mesa_noop_EvalCoord1fv;
813 vfmt->EvalCoord2f = _mesa_noop_EvalCoord2f;
814 vfmt->EvalCoord2fv = _mesa_noop_EvalCoord2fv;
815 vfmt->EvalPoint1 = _mesa_noop_EvalPoint1;
816 vfmt->EvalPoint2 = _mesa_noop_EvalPoint2;
817 vfmt->FogCoordfEXT = _mesa_noop_FogCoordfEXT;
818 vfmt->FogCoordfvEXT = _mesa_noop_FogCoordfvEXT;
819 vfmt->Indexf = _mesa_noop_Indexf;
820 vfmt->Indexfv = _mesa_noop_Indexfv;
821 vfmt->Materialfv = _mesa_noop_Materialfv;
822 vfmt->MultiTexCoord1fARB = _mesa_noop_MultiTexCoord1fARB;
823 vfmt->MultiTexCoord1fvARB = _mesa_noop_MultiTexCoord1fvARB;
824 vfmt->MultiTexCoord2fARB = _mesa_noop_MultiTexCoord2fARB;
825 vfmt->MultiTexCoord2fvARB = _mesa_noop_MultiTexCoord2fvARB;
826 vfmt->MultiTexCoord3fARB = _mesa_noop_MultiTexCoord3fARB;
827 vfmt->MultiTexCoord3fvARB = _mesa_noop_MultiTexCoord3fvARB;
828 vfmt->MultiTexCoord4fARB = _mesa_noop_MultiTexCoord4fARB;
829 vfmt->MultiTexCoord4fvARB = _mesa_noop_MultiTexCoord4fvARB;
830 vfmt->Normal3f = _mesa_noop_Normal3f;
831 vfmt->Normal3fv = _mesa_noop_Normal3fv;
832 vfmt->SecondaryColor3fEXT = _mesa_noop_SecondaryColor3fEXT;
833 vfmt->SecondaryColor3fvEXT = _mesa_noop_SecondaryColor3fvEXT;
834 vfmt->TexCoord1f = _mesa_noop_TexCoord1f;
835 vfmt->TexCoord1fv = _mesa_noop_TexCoord1fv;
836 vfmt->TexCoord2f = _mesa_noop_TexCoord2f;
837 vfmt->TexCoord2fv = _mesa_noop_TexCoord2fv;
838 vfmt->TexCoord3f = _mesa_noop_TexCoord3f;
839 vfmt->TexCoord3fv = _mesa_noop_TexCoord3fv;
840 vfmt->TexCoord4f = _mesa_noop_TexCoord4f;
841 vfmt->TexCoord4fv = _mesa_noop_TexCoord4fv;
842 vfmt->Vertex2f = _mesa_noop_Vertex2f;
843 vfmt->Vertex2fv = _mesa_noop_Vertex2fv;
844 vfmt->Vertex3f = _mesa_noop_Vertex3f;
845 vfmt->Vertex3fv = _mesa_noop_Vertex3fv;
846 vfmt->Vertex4f = _mesa_noop_Vertex4f;
847 vfmt->Vertex4fv = _mesa_noop_Vertex4fv;
848 vfmt->VertexAttrib1fNV = _mesa_noop_VertexAttrib1fNV;
849 vfmt->VertexAttrib1fvNV = _mesa_noop_VertexAttrib1fvNV;
850 vfmt->VertexAttrib2fNV = _mesa_noop_VertexAttrib2fNV;
851 vfmt->VertexAttrib2fvNV = _mesa_noop_VertexAttrib2fvNV;
852 vfmt->VertexAttrib3fNV = _mesa_noop_VertexAttrib3fNV;
853 vfmt->VertexAttrib3fvNV = _mesa_noop_VertexAttrib3fvNV;
854 vfmt->VertexAttrib4fNV = _mesa_noop_VertexAttrib4fNV;
855 vfmt->VertexAttrib4fvNV = _mesa_noop_VertexAttrib4fvNV;
856
857 vfmt->Rectf = _mesa_noop_Rectf;
858
859 vfmt->DrawArrays = _mesa_noop_DrawArrays;
860 vfmt->DrawElements = _mesa_noop_DrawElements;
861 vfmt->DrawRangeElements = _mesa_noop_DrawRangeElements;
862 vfmt->EvalMesh1 = _mesa_noop_EvalMesh1;
863 vfmt->EvalMesh2 = _mesa_noop_EvalMesh2;
864 }