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