bab333dca8a1269f3aa53c2723383c7351b95055
[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 "context.h"
31 #include "colormac.h"
32 #include "light.h"
33 #include "macros.h"
34 #include "mtypes.h"
35
36
37 /* In states where certain vertex components are required for t&l or
38 * rasterization, we still need to keep track of the current values.
39 * These functions provide this service by keeping uptodate the
40 * 'ctx->Current' struct for all data elements not included in the
41 * currently enabled hardware vertex.
42 *
43 */
44 void _mesa_noop_EdgeFlag( GLboolean b )
45 {
46 GET_CURRENT_CONTEXT(ctx);
47 ctx->Current.EdgeFlag = b;
48 }
49
50 void _mesa_noop_EdgeFlagv( const GLboolean *b )
51 {
52 GET_CURRENT_CONTEXT(ctx);
53 ctx->Current.EdgeFlag = *b;
54 }
55
56 void _mesa_noop_FogCoordfEXT( GLfloat a )
57 {
58 GET_CURRENT_CONTEXT(ctx);
59 ctx->Current.Attrib[VERT_ATTRIB_FOG][0] = a;
60 }
61
62 void _mesa_noop_FogCoordfvEXT( const GLfloat *v )
63 {
64 GET_CURRENT_CONTEXT(ctx);
65 ctx->Current.Attrib[VERT_ATTRIB_FOG][0] = *v;
66 }
67
68 void _mesa_noop_Indexi( GLint i )
69 {
70 GET_CURRENT_CONTEXT(ctx);
71 ctx->Current.Index = i;
72 }
73
74 void _mesa_noop_Indexiv( const GLint *v )
75 {
76 GET_CURRENT_CONTEXT(ctx);
77 ctx->Current.Index = *v;
78 }
79
80 void _mesa_noop_Normal3f( GLfloat a, GLfloat b, GLfloat c )
81 {
82 GET_CURRENT_CONTEXT(ctx);
83 GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_NORMAL];
84 COPY_FLOAT(dest[0], a);
85 COPY_FLOAT(dest[1], b);
86 COPY_FLOAT(dest[2], c);
87 }
88
89 void _mesa_noop_Normal3fv( const GLfloat *v )
90 {
91 GET_CURRENT_CONTEXT(ctx);
92 GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_NORMAL];
93 COPY_FLOAT(dest[0], v[0]);
94 COPY_FLOAT(dest[1], v[1]);
95 COPY_FLOAT(dest[2], v[2]);
96 }
97
98 void _mesa_noop_Materialfv( GLenum face, GLenum pname, const GLfloat *params )
99 {
100 GET_CURRENT_CONTEXT(ctx);
101 GLint i, nr;
102 struct gl_material *mat = &ctx->Light.Material;
103 GLuint bitmask = _mesa_material_bitmask( ctx, face, pname, ~0,
104 "_mesa_noop_Materialfv" );
105
106 if (ctx->Light.ColorMaterialEnabled)
107 bitmask &= ~ctx->Light.ColorMaterialBitmask;
108
109 if (bitmask == 0)
110 return;
111
112 switch (face) {
113 case GL_SHININESS: nr = 1; break;
114 case GL_COLOR_INDEXES: nr = 3; break;
115 default: nr = 4 ; break;
116 }
117
118 for (i = 0 ; i < MAT_ATTRIB_MAX ; i++)
119 if (bitmask & (1<<i))
120 COPY_SZ_4V( mat->Attrib[i], nr, params );
121
122 _mesa_update_material( ctx, bitmask );
123 }
124
125 void _mesa_noop_Color4ub( GLubyte a, GLubyte b, GLubyte c, GLubyte d )
126 {
127 GET_CURRENT_CONTEXT(ctx);
128 GLfloat *color = ctx->Current.Attrib[VERT_ATTRIB_COLOR0];
129 color[0] = UBYTE_TO_FLOAT(a);
130 color[1] = UBYTE_TO_FLOAT(b);
131 color[2] = UBYTE_TO_FLOAT(c);
132 color[3] = UBYTE_TO_FLOAT(d);
133 }
134
135 void _mesa_noop_Color4ubv( const GLubyte *v )
136 {
137 GET_CURRENT_CONTEXT(ctx);
138 GLfloat *color = ctx->Current.Attrib[VERT_ATTRIB_COLOR0];
139 color[0] = UBYTE_TO_FLOAT(v[0]);
140 color[1] = UBYTE_TO_FLOAT(v[1]);
141 color[2] = UBYTE_TO_FLOAT(v[2]);
142 color[3] = UBYTE_TO_FLOAT(v[3]);
143 }
144
145 void _mesa_noop_Color4f( GLfloat a, GLfloat b, GLfloat c, GLfloat d )
146 {
147 GET_CURRENT_CONTEXT(ctx);
148 GLfloat *color = ctx->Current.Attrib[VERT_ATTRIB_COLOR0];
149 color[0] = a;
150 color[1] = b;
151 color[2] = c;
152 color[3] = d;
153 }
154
155 void _mesa_noop_Color4fv( const GLfloat *v )
156 {
157 GET_CURRENT_CONTEXT(ctx);
158 GLfloat *color = ctx->Current.Attrib[VERT_ATTRIB_COLOR0];
159 color[0] = v[0];
160 color[1] = v[1];
161 color[2] = v[2];
162 color[3] = v[3];
163 }
164
165 void _mesa_noop_Color3ub( GLubyte a, GLubyte b, GLubyte c )
166 {
167 GET_CURRENT_CONTEXT(ctx);
168 GLfloat *color = ctx->Current.Attrib[VERT_ATTRIB_COLOR0];
169 color[0] = UBYTE_TO_FLOAT(a);
170 color[1] = UBYTE_TO_FLOAT(b);
171 color[2] = UBYTE_TO_FLOAT(c);
172 color[3] = 1.0;
173 }
174
175 void _mesa_noop_Color3ubv( const GLubyte *v )
176 {
177 GET_CURRENT_CONTEXT(ctx);
178 GLfloat *color = ctx->Current.Attrib[VERT_ATTRIB_COLOR0];
179 color[0] = UBYTE_TO_FLOAT(v[0]);
180 color[1] = UBYTE_TO_FLOAT(v[1]);
181 color[2] = UBYTE_TO_FLOAT(v[2]);
182 color[3] = 1.0;
183 }
184
185 void _mesa_noop_Color3f( GLfloat a, GLfloat b, GLfloat c )
186 {
187 GET_CURRENT_CONTEXT(ctx);
188 GLfloat *color = ctx->Current.Attrib[VERT_ATTRIB_COLOR0];
189 color[0] = a;
190 color[1] = b;
191 color[2] = c;
192 color[3] = 1.0;
193 }
194
195 void _mesa_noop_Color3fv( const GLfloat *v )
196 {
197 GET_CURRENT_CONTEXT(ctx);
198 GLfloat *color = ctx->Current.Attrib[VERT_ATTRIB_COLOR0];
199 color[0] = v[0];
200 color[1] = v[1];
201 color[2] = v[2];
202 color[3] = 1.0;
203 }
204
205 void _mesa_noop_MultiTexCoord1fARB( GLenum target, GLfloat a )
206 {
207 GET_CURRENT_CONTEXT(ctx);
208 GLuint unit = target - GL_TEXTURE0_ARB;
209
210 /* unit is unsigned -- cannot be less than zero.
211 */
212 if (unit < MAX_TEXTURE_COORD_UNITS)
213 {
214 GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit];
215 COPY_FLOAT(dest[0], a);
216 dest[1] = 0;
217 dest[2] = 0;
218 dest[3] = 1;
219 }
220 }
221
222 void _mesa_noop_MultiTexCoord1fvARB( GLenum target, const GLfloat *v )
223 {
224 GET_CURRENT_CONTEXT(ctx);
225 GLuint unit = target - GL_TEXTURE0_ARB;
226
227 /* unit is unsigned -- cannot be less than zero.
228 */
229 if (unit < MAX_TEXTURE_COORD_UNITS)
230 {
231 GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit];
232 COPY_FLOAT(dest[0], v[0]);
233 dest[1] = 0;
234 dest[2] = 0;
235 dest[3] = 1;
236 }
237 }
238
239 void _mesa_noop_MultiTexCoord2fARB( GLenum target, GLfloat a, GLfloat b )
240 {
241 GET_CURRENT_CONTEXT(ctx);
242 GLuint unit = target - GL_TEXTURE0_ARB;
243
244 /* unit is unsigned -- cannot be less than zero.
245 */
246 if (unit < MAX_TEXTURE_COORD_UNITS)
247 {
248 GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit];
249 COPY_FLOAT(dest[0], a);
250 COPY_FLOAT(dest[1], b);
251 dest[2] = 0;
252 dest[3] = 1;
253 }
254 }
255
256 void _mesa_noop_MultiTexCoord2fvARB( GLenum target, const GLfloat *v )
257 {
258 GET_CURRENT_CONTEXT(ctx);
259 GLuint unit = target - GL_TEXTURE0_ARB;
260
261 /* unit is unsigned -- cannot be less than zero.
262 */
263 if (unit < MAX_TEXTURE_COORD_UNITS)
264 {
265 GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit];
266 COPY_FLOAT(dest[0], v[0]);
267 COPY_FLOAT(dest[1], v[1]);
268 dest[2] = 0;
269 dest[3] = 1;
270 }
271 }
272
273 void _mesa_noop_MultiTexCoord3fARB( GLenum target, GLfloat a, GLfloat b, GLfloat c)
274 {
275 GET_CURRENT_CONTEXT(ctx);
276 GLuint unit = target - GL_TEXTURE0_ARB;
277
278 /* unit is unsigned -- cannot be less than zero.
279 */
280 if (unit < MAX_TEXTURE_COORD_UNITS)
281 {
282 GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit];
283 COPY_FLOAT(dest[0], a);
284 COPY_FLOAT(dest[1], b);
285 COPY_FLOAT(dest[2], c);
286 dest[3] = 1;
287 }
288 }
289
290 void _mesa_noop_MultiTexCoord3fvARB( GLenum target, const GLfloat *v )
291 {
292 GET_CURRENT_CONTEXT(ctx);
293 GLuint unit = target - GL_TEXTURE0_ARB;
294
295 /* unit is unsigned -- cannot be less than zero.
296 */
297 if (unit < MAX_TEXTURE_COORD_UNITS)
298 {
299 GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit];
300 COPY_FLOAT(dest[0], v[0]);
301 COPY_FLOAT(dest[1], v[1]);
302 COPY_FLOAT(dest[2], v[2]);
303 dest[3] = 1;
304 }
305 }
306
307 void _mesa_noop_MultiTexCoord4fARB( GLenum target, GLfloat a, GLfloat b,
308 GLfloat c, GLfloat d )
309 {
310 GET_CURRENT_CONTEXT(ctx);
311 GLuint unit = target - GL_TEXTURE0_ARB;
312
313 /* unit is unsigned -- cannot be less than zero.
314 */
315 if (unit < MAX_TEXTURE_COORD_UNITS)
316 {
317 GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit];
318 COPY_FLOAT(dest[0], a);
319 COPY_FLOAT(dest[1], b);
320 COPY_FLOAT(dest[2], c);
321 dest[3] = d;
322 }
323 }
324
325 void _mesa_noop_MultiTexCoord4fvARB( GLenum target, const GLfloat *v )
326 {
327 GET_CURRENT_CONTEXT(ctx);
328 GLuint unit = target - GL_TEXTURE0_ARB;
329
330 /* unit is unsigned -- cannot be less than zero.
331 */
332 if (unit < MAX_TEXTURE_COORD_UNITS)
333 {
334 GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit];
335 COPY_FLOAT(dest[0], v[0]);
336 COPY_FLOAT(dest[1], v[1]);
337 COPY_FLOAT(dest[2], v[2]);
338 COPY_FLOAT(dest[3], v[3]);
339 }
340 }
341
342 void _mesa_noop_SecondaryColor3ubEXT( GLubyte a, GLubyte b, GLubyte c )
343 {
344 GET_CURRENT_CONTEXT(ctx);
345 GLfloat *color = ctx->Current.Attrib[VERT_ATTRIB_COLOR1];
346 color[0] = UBYTE_TO_FLOAT(a);
347 color[1] = UBYTE_TO_FLOAT(b);
348 color[2] = UBYTE_TO_FLOAT(c);
349 color[3] = 1.0;
350 }
351
352 void _mesa_noop_SecondaryColor3ubvEXT( const GLubyte *v )
353 {
354 GET_CURRENT_CONTEXT(ctx);
355 GLfloat *color = ctx->Current.Attrib[VERT_ATTRIB_COLOR1];
356 color[0] = UBYTE_TO_FLOAT(v[0]);
357 color[1] = UBYTE_TO_FLOAT(v[1]);
358 color[2] = UBYTE_TO_FLOAT(v[2]);
359 color[3] = 1.0;
360 }
361
362 void _mesa_noop_SecondaryColor3fEXT( GLfloat a, GLfloat b, GLfloat c )
363 {
364 GET_CURRENT_CONTEXT(ctx);
365 GLfloat *color = ctx->Current.Attrib[VERT_ATTRIB_COLOR1];
366 color[0] = a;
367 color[1] = b;
368 color[2] = c;
369 color[3] = 1.0;
370 }
371
372 void _mesa_noop_SecondaryColor3fvEXT( const GLfloat *v )
373 {
374 GET_CURRENT_CONTEXT(ctx);
375 GLfloat *color = ctx->Current.Attrib[VERT_ATTRIB_COLOR1];
376 color[0] = v[0];
377 color[1] = v[1];
378 color[2] = v[2];
379 color[3] = 1.0;
380 }
381
382 void _mesa_noop_TexCoord1f( GLfloat a )
383 {
384 GET_CURRENT_CONTEXT(ctx);
385 GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_TEX0];
386 COPY_FLOAT(dest[0], a);
387 dest[1] = 0;
388 dest[2] = 0;
389 dest[3] = 1;
390 }
391
392 void _mesa_noop_TexCoord1fv( const GLfloat *v )
393 {
394 GET_CURRENT_CONTEXT(ctx);
395 GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_TEX0];
396 COPY_FLOAT(dest[0], v[0]);
397 dest[1] = 0;
398 dest[2] = 0;
399 dest[3] = 1;
400 }
401
402 void _mesa_noop_TexCoord2f( GLfloat a, GLfloat b )
403 {
404 GET_CURRENT_CONTEXT(ctx);
405 GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_TEX0];
406 COPY_FLOAT(dest[0], a);
407 COPY_FLOAT(dest[1], b);
408 dest[2] = 0;
409 dest[3] = 1;
410 }
411
412 void _mesa_noop_TexCoord2fv( const GLfloat *v )
413 {
414 GET_CURRENT_CONTEXT(ctx);
415 GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_TEX0];
416 COPY_FLOAT(dest[0], v[0]);
417 COPY_FLOAT(dest[1], v[1]);
418 dest[2] = 0;
419 dest[3] = 1;
420 }
421
422 void _mesa_noop_TexCoord3f( GLfloat a, GLfloat b, GLfloat c )
423 {
424 GET_CURRENT_CONTEXT(ctx);
425 GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_TEX0];
426 COPY_FLOAT(dest[0], a);
427 COPY_FLOAT(dest[1], b);
428 COPY_FLOAT(dest[2], c);
429 dest[3] = 1;
430 }
431
432 void _mesa_noop_TexCoord3fv( const GLfloat *v )
433 {
434 GET_CURRENT_CONTEXT(ctx);
435 GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_TEX0];
436 COPY_FLOAT(dest[0], v[0]);
437 COPY_FLOAT(dest[1], v[1]);
438 COPY_FLOAT(dest[2], v[2]);
439 dest[3] = 1;
440 }
441
442 void _mesa_noop_TexCoord4f( GLfloat a, GLfloat b, GLfloat c, GLfloat d )
443 {
444 GET_CURRENT_CONTEXT(ctx);
445 GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_TEX0];
446 COPY_FLOAT(dest[0], a);
447 COPY_FLOAT(dest[1], b);
448 COPY_FLOAT(dest[2], c);
449 COPY_FLOAT(dest[3], d);
450 }
451
452 void _mesa_noop_TexCoord4fv( const GLfloat *v )
453 {
454 GET_CURRENT_CONTEXT(ctx);
455 GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_TEX0];
456 COPY_FLOAT(dest[0], v[0]);
457 COPY_FLOAT(dest[1], v[1]);
458 COPY_FLOAT(dest[2], v[2]);
459 COPY_FLOAT(dest[3], v[3]);
460 }
461
462 /* Useful outside begin/end?
463 */
464 void _mesa_noop_Vertex2fv( const GLfloat *v )
465 {
466 (void) v;
467 }
468
469 void _mesa_noop_Vertex3fv( const GLfloat *v )
470 {
471 (void) v;
472 }
473
474 void _mesa_noop_Vertex4fv( const GLfloat *v )
475 {
476 (void) v;
477 }
478
479 void _mesa_noop_Vertex2f( GLfloat a, GLfloat b )
480 {
481 (void) a; (void) b;
482 }
483
484 void _mesa_noop_Vertex3f( GLfloat a, GLfloat b, GLfloat c )
485 {
486 (void) a; (void) b; (void) c;
487 }
488
489 void _mesa_noop_Vertex4f( GLfloat a, GLfloat b, GLfloat c, GLfloat d )
490 {
491 (void) a; (void) b; (void) c; (void) d;
492 }
493
494
495
496 void _mesa_noop_VertexAttrib4fNV( GLuint index, GLfloat x,
497 GLfloat y, GLfloat z, GLfloat w )
498 {
499 GET_CURRENT_CONTEXT(ctx);
500 if (index < 16) {
501 ASSIGN_4V(ctx->Current.Attrib[index], x, y, z, w);
502 }
503 }
504
505 void _mesa_noop_VertexAttrib4fvNV( GLuint index, const GLfloat *v )
506 {
507 GET_CURRENT_CONTEXT(ctx);
508 if (index < 16) {
509 ASSIGN_4V(ctx->Current.Attrib[index], v[0], v[1], v[2], v[3]);
510 }
511 }
512
513
514
515 /* Execute a glRectf() function. This is not suitable for GL_COMPILE
516 * modes (as the test for outside begin/end is not compiled),
517 * but may be useful for drivers in circumstances which exclude
518 * display list interactions.
519 *
520 * (None of the functions in this file are suitable for GL_COMPILE
521 * modes).
522 */
523 void _mesa_noop_Rectf( GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2 )
524 {
525 {
526 GET_CURRENT_CONTEXT(ctx);
527 ASSERT_OUTSIDE_BEGIN_END(ctx);
528 }
529
530 glBegin( GL_QUADS );
531 glVertex2f( x1, y1 );
532 glVertex2f( x2, y1 );
533 glVertex2f( x2, y2 );
534 glVertex2f( x1, y2 );
535 glEnd();
536 }
537
538
539 /* Some very basic support for arrays. Drivers without explicit array
540 * support can hook these in, but still need to supply an array-elt
541 * implementation.
542 */
543 void _mesa_noop_DrawArrays(GLenum mode, GLint start, GLsizei count)
544 {
545 GET_CURRENT_CONTEXT(ctx);
546 GLint i;
547
548 if (!_mesa_validate_DrawArrays( ctx, mode, start, count ))
549 return;
550
551 glBegin(mode);
552 for (i = start ; i <= count ; i++)
553 glArrayElement( i );
554 glEnd();
555 }
556
557
558 void _mesa_noop_DrawElements(GLenum mode, GLsizei count, GLenum type,
559 const GLvoid *indices)
560 {
561 GET_CURRENT_CONTEXT(ctx);
562 GLint i;
563
564 if (!_mesa_validate_DrawElements( ctx, mode, count, type, indices ))
565 return;
566
567 glBegin(mode);
568
569 switch (type) {
570 case GL_UNSIGNED_BYTE:
571 for (i = 0 ; i < count ; i++)
572 glArrayElement( ((GLubyte *)indices)[i] );
573 break;
574 case GL_UNSIGNED_SHORT:
575 for (i = 0 ; i < count ; i++)
576 glArrayElement( ((GLushort *)indices)[i] );
577 break;
578 case GL_UNSIGNED_INT:
579 for (i = 0 ; i < count ; i++)
580 glArrayElement( ((GLuint *)indices)[i] );
581 break;
582 default:
583 _mesa_error( ctx, GL_INVALID_ENUM, "glDrawElements(type)" );
584 break;
585 }
586
587 glEnd();
588 }
589
590 void _mesa_noop_DrawRangeElements(GLenum mode,
591 GLuint start, GLuint end,
592 GLsizei count, GLenum type,
593 const GLvoid *indices)
594 {
595 GET_CURRENT_CONTEXT(ctx);
596
597 if (_mesa_validate_DrawRangeElements( ctx, mode,
598 start, end,
599 count, type, indices ))
600 glDrawElements( mode, count, type, indices );
601 }