a44322749e223308c389f255285435a0c12fd724
1 /* $Id: api_noop.c,v 1.10 2002/04/09 16:56:50 keithw Exp $ */
4 * Mesa 3-D graphics library
7 * Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
9 * Permission is hereby granted, free of charge, to any person obtaining a
10 * copy of this software and associated documentation files (the "Software"),
11 * to deal in the Software without restriction, including without limitation
12 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
13 * and/or sell copies of the Software, and to permit persons to whom the
14 * Software is furnished to do so, subject to the following conditions:
16 * The above copyright notice and this permission notice shall be included
17 * in all copies or substantial portions of the Software.
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
23 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
24 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30 #include "api_validate.h"
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.
46 void _mesa_noop_EdgeFlag( GLboolean b
)
48 GET_CURRENT_CONTEXT(ctx
);
49 ctx
->Current
.EdgeFlag
= b
;
52 void _mesa_noop_EdgeFlagv( const GLboolean
*b
)
54 GET_CURRENT_CONTEXT(ctx
);
55 ctx
->Current
.EdgeFlag
= *b
;
58 void _mesa_noop_FogCoordfEXT( GLfloat a
)
60 GET_CURRENT_CONTEXT(ctx
);
61 ctx
->Current
.Attrib
[VERT_ATTRIB_FOG
][0] = a
;
64 void _mesa_noop_FogCoordfvEXT( const GLfloat
*v
)
66 GET_CURRENT_CONTEXT(ctx
);
67 ctx
->Current
.Attrib
[VERT_ATTRIB_FOG
][0] = *v
;
70 void _mesa_noop_Indexi( GLint i
)
72 GET_CURRENT_CONTEXT(ctx
);
73 ctx
->Current
.Index
= i
;
76 void _mesa_noop_Indexiv( const GLint
*v
)
78 GET_CURRENT_CONTEXT(ctx
);
79 ctx
->Current
.Index
= *v
;
82 void _mesa_noop_Normal3f( GLfloat a
, GLfloat b
, GLfloat c
)
84 GET_CURRENT_CONTEXT(ctx
);
85 GLfloat
*dest
= ctx
->Current
.Attrib
[VERT_ATTRIB_NORMAL
];
86 COPY_FLOAT(dest
[0], a
);
87 COPY_FLOAT(dest
[1], b
);
88 COPY_FLOAT(dest
[2], c
);
91 void _mesa_noop_Normal3fv( const GLfloat
*v
)
93 GET_CURRENT_CONTEXT(ctx
);
94 GLfloat
*dest
= ctx
->Current
.Attrib
[VERT_ATTRIB_NORMAL
];
95 COPY_FLOAT(dest
[0], v
[0]);
96 COPY_FLOAT(dest
[1], v
[1]);
97 COPY_FLOAT(dest
[2], v
[2]);
100 void _mesa_noop_Materialfv( GLenum face
, GLenum pname
, const GLfloat
*params
)
102 GET_CURRENT_CONTEXT(ctx
);
103 struct gl_material mat
[2];
104 GLuint bitmask
= _mesa_material_bitmask( ctx
, face
, pname
, ~0,
105 "_mesa_noop_Materialfv" );
109 if (bitmask
& FRONT_AMBIENT_BIT
) {
110 COPY_4FV( mat
[0].Ambient
, params
);
112 if (bitmask
& BACK_AMBIENT_BIT
) {
113 COPY_4FV( mat
[1].Ambient
, params
);
115 if (bitmask
& FRONT_DIFFUSE_BIT
) {
116 COPY_4FV( mat
[0].Diffuse
, params
);
118 if (bitmask
& BACK_DIFFUSE_BIT
) {
119 COPY_4FV( mat
[1].Diffuse
, params
);
121 if (bitmask
& FRONT_SPECULAR_BIT
) {
122 COPY_4FV( mat
[0].Specular
, params
);
124 if (bitmask
& BACK_SPECULAR_BIT
) {
125 COPY_4FV( mat
[1].Specular
, params
);
127 if (bitmask
& FRONT_EMISSION_BIT
) {
128 COPY_4FV( mat
[0].Emission
, params
);
130 if (bitmask
& BACK_EMISSION_BIT
) {
131 COPY_4FV( mat
[1].Emission
, params
);
133 if (bitmask
& FRONT_SHININESS_BIT
) {
134 GLfloat shininess
= CLAMP( params
[0], 0.0F
, 128.0F
);
135 mat
[0].Shininess
= shininess
;
137 if (bitmask
& BACK_SHININESS_BIT
) {
138 GLfloat shininess
= CLAMP( params
[0], 0.0F
, 128.0F
);
139 mat
[1].Shininess
= shininess
;
141 if (bitmask
& FRONT_INDEXES_BIT
) {
142 mat
[0].AmbientIndex
= params
[0];
143 mat
[0].DiffuseIndex
= params
[1];
144 mat
[0].SpecularIndex
= params
[2];
146 if (bitmask
& BACK_INDEXES_BIT
) {
147 mat
[1].AmbientIndex
= params
[0];
148 mat
[1].DiffuseIndex
= params
[1];
149 mat
[1].SpecularIndex
= params
[2];
152 _mesa_update_material( ctx
, mat
, bitmask
);
155 void _mesa_noop_Color4ub( GLubyte a
, GLubyte b
, GLubyte c
, GLubyte d
)
157 GET_CURRENT_CONTEXT(ctx
);
158 GLfloat
*color
= ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR0
];
159 color
[0] = UBYTE_TO_FLOAT(a
);
160 color
[1] = UBYTE_TO_FLOAT(b
);
161 color
[2] = UBYTE_TO_FLOAT(c
);
162 color
[3] = UBYTE_TO_FLOAT(d
);
165 void _mesa_noop_Color4ubv( const GLubyte
*v
)
167 GET_CURRENT_CONTEXT(ctx
);
168 GLfloat
*color
= ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR0
];
169 color
[0] = UBYTE_TO_FLOAT(v
[0]);
170 color
[1] = UBYTE_TO_FLOAT(v
[1]);
171 color
[2] = UBYTE_TO_FLOAT(v
[2]);
172 color
[3] = UBYTE_TO_FLOAT(v
[3]);
175 void _mesa_noop_Color4f( GLfloat a
, GLfloat b
, GLfloat c
, GLfloat d
)
177 GET_CURRENT_CONTEXT(ctx
);
178 GLfloat
*color
= ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR0
];
185 void _mesa_noop_Color4fv( const GLfloat
*v
)
187 GET_CURRENT_CONTEXT(ctx
);
188 GLfloat
*color
= ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR0
];
195 void _mesa_noop_Color3ub( GLubyte a
, GLubyte b
, GLubyte c
)
197 GET_CURRENT_CONTEXT(ctx
);
198 GLfloat
*color
= ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR0
];
199 color
[0] = UBYTE_TO_FLOAT(a
);
200 color
[1] = UBYTE_TO_FLOAT(b
);
201 color
[2] = UBYTE_TO_FLOAT(c
);
205 void _mesa_noop_Color3ubv( const GLubyte
*v
)
207 GET_CURRENT_CONTEXT(ctx
);
208 GLfloat
*color
= ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR0
];
209 color
[0] = UBYTE_TO_FLOAT(v
[0]);
210 color
[1] = UBYTE_TO_FLOAT(v
[1]);
211 color
[2] = UBYTE_TO_FLOAT(v
[2]);
215 void _mesa_noop_Color3f( GLfloat a
, GLfloat b
, GLfloat c
)
217 GET_CURRENT_CONTEXT(ctx
);
218 GLfloat
*color
= ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR0
];
225 void _mesa_noop_Color3fv( const GLfloat
*v
)
227 GET_CURRENT_CONTEXT(ctx
);
228 GLfloat
*color
= ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR0
];
235 void _mesa_noop_MultiTexCoord1fARB( GLenum target
, GLfloat a
)
237 GET_CURRENT_CONTEXT(ctx
);
238 GLuint unit
= target
- GL_TEXTURE0_ARB
;
240 /* unit is unsigned -- cannot be less than zero.
242 if (unit
< MAX_TEXTURE_UNITS
)
244 GLfloat
*dest
= ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
+ unit
];
245 COPY_FLOAT(dest
[0], a
);
252 void _mesa_noop_MultiTexCoord1fvARB( GLenum target
, const GLfloat
*v
)
254 GET_CURRENT_CONTEXT(ctx
);
255 GLuint unit
= target
- GL_TEXTURE0_ARB
;
257 /* unit is unsigned -- cannot be less than zero.
259 if (unit
< MAX_TEXTURE_UNITS
)
261 GLfloat
*dest
= ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
+ unit
];
262 COPY_FLOAT(dest
[0], v
[0]);
269 void _mesa_noop_MultiTexCoord2fARB( GLenum target
, GLfloat a
, GLfloat b
)
271 GET_CURRENT_CONTEXT(ctx
);
272 GLuint unit
= target
- GL_TEXTURE0_ARB
;
274 /* unit is unsigned -- cannot be less than zero.
276 if (unit
< MAX_TEXTURE_UNITS
)
278 GLfloat
*dest
= ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
+ unit
];
279 COPY_FLOAT(dest
[0], a
);
280 COPY_FLOAT(dest
[1], b
);
286 void _mesa_noop_MultiTexCoord2fvARB( GLenum target
, const GLfloat
*v
)
288 GET_CURRENT_CONTEXT(ctx
);
289 GLuint unit
= target
- GL_TEXTURE0_ARB
;
291 /* unit is unsigned -- cannot be less than zero.
293 if (unit
< MAX_TEXTURE_UNITS
)
295 GLfloat
*dest
= ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
+ unit
];
296 COPY_FLOAT(dest
[0], v
[0]);
297 COPY_FLOAT(dest
[1], v
[1]);
303 void _mesa_noop_MultiTexCoord3fARB( GLenum target
, GLfloat a
, GLfloat b
, GLfloat c
)
305 GET_CURRENT_CONTEXT(ctx
);
306 GLuint unit
= target
- GL_TEXTURE0_ARB
;
308 /* unit is unsigned -- cannot be less than zero.
310 if (unit
< MAX_TEXTURE_UNITS
)
312 GLfloat
*dest
= ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
+ unit
];
313 COPY_FLOAT(dest
[0], a
);
314 COPY_FLOAT(dest
[1], b
);
315 COPY_FLOAT(dest
[2], c
);
320 void _mesa_noop_MultiTexCoord3fvARB( GLenum target
, const GLfloat
*v
)
322 GET_CURRENT_CONTEXT(ctx
);
323 GLuint unit
= target
- GL_TEXTURE0_ARB
;
325 /* unit is unsigned -- cannot be less than zero.
327 if (unit
< MAX_TEXTURE_UNITS
)
329 GLfloat
*dest
= ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
+ unit
];
330 COPY_FLOAT(dest
[0], v
[0]);
331 COPY_FLOAT(dest
[1], v
[1]);
332 COPY_FLOAT(dest
[2], v
[2]);
337 void _mesa_noop_MultiTexCoord4fARB( GLenum target
, GLfloat a
, GLfloat b
,
338 GLfloat c
, GLfloat d
)
340 GET_CURRENT_CONTEXT(ctx
);
341 GLuint unit
= target
- GL_TEXTURE0_ARB
;
343 /* unit is unsigned -- cannot be less than zero.
345 if (unit
< MAX_TEXTURE_UNITS
)
347 GLfloat
*dest
= ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
+ unit
];
348 COPY_FLOAT(dest
[0], a
);
349 COPY_FLOAT(dest
[1], b
);
350 COPY_FLOAT(dest
[2], c
);
355 void _mesa_noop_MultiTexCoord4fvARB( GLenum target
, const GLfloat
*v
)
357 GET_CURRENT_CONTEXT(ctx
);
358 GLuint unit
= target
- GL_TEXTURE0_ARB
;
360 /* unit is unsigned -- cannot be less than zero.
362 if (unit
< MAX_TEXTURE_UNITS
)
364 GLfloat
*dest
= ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
+ unit
];
365 COPY_FLOAT(dest
[0], v
[0]);
366 COPY_FLOAT(dest
[1], v
[1]);
367 COPY_FLOAT(dest
[2], v
[2]);
368 COPY_FLOAT(dest
[3], v
[3]);
372 void _mesa_noop_SecondaryColor3ubEXT( GLubyte a
, GLubyte b
, GLubyte c
)
374 GET_CURRENT_CONTEXT(ctx
);
375 GLfloat
*color
= ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR1
];
376 color
[0] = UBYTE_TO_FLOAT(a
);
377 color
[1] = UBYTE_TO_FLOAT(b
);
378 color
[2] = UBYTE_TO_FLOAT(c
);
382 void _mesa_noop_SecondaryColor3ubvEXT( const GLubyte
*v
)
384 GET_CURRENT_CONTEXT(ctx
);
385 GLfloat
*color
= ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR1
];
386 color
[0] = UBYTE_TO_FLOAT(v
[0]);
387 color
[1] = UBYTE_TO_FLOAT(v
[1]);
388 color
[2] = UBYTE_TO_FLOAT(v
[2]);
392 void _mesa_noop_SecondaryColor3fEXT( GLfloat a
, GLfloat b
, GLfloat c
)
394 GET_CURRENT_CONTEXT(ctx
);
395 GLfloat
*color
= ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR1
];
402 void _mesa_noop_SecondaryColor3fvEXT( const GLfloat
*v
)
404 GET_CURRENT_CONTEXT(ctx
);
405 GLfloat
*color
= ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR1
];
412 void _mesa_noop_TexCoord1f( GLfloat a
)
414 GET_CURRENT_CONTEXT(ctx
);
415 GLfloat
*dest
= ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
];
416 COPY_FLOAT(dest
[0], a
);
422 void _mesa_noop_TexCoord1fv( const GLfloat
*v
)
424 GET_CURRENT_CONTEXT(ctx
);
425 GLfloat
*dest
= ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
];
426 COPY_FLOAT(dest
[0], v
[0]);
432 void _mesa_noop_TexCoord2f( GLfloat a
, GLfloat b
)
434 GET_CURRENT_CONTEXT(ctx
);
435 GLfloat
*dest
= ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
];
436 COPY_FLOAT(dest
[0], a
);
437 COPY_FLOAT(dest
[1], b
);
442 void _mesa_noop_TexCoord2fv( const GLfloat
*v
)
444 GET_CURRENT_CONTEXT(ctx
);
445 GLfloat
*dest
= ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
];
446 COPY_FLOAT(dest
[0], v
[0]);
447 COPY_FLOAT(dest
[1], v
[1]);
452 void _mesa_noop_TexCoord3f( GLfloat a
, GLfloat b
, GLfloat c
)
454 GET_CURRENT_CONTEXT(ctx
);
455 GLfloat
*dest
= ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
];
456 COPY_FLOAT(dest
[0], a
);
457 COPY_FLOAT(dest
[1], b
);
458 COPY_FLOAT(dest
[2], c
);
462 void _mesa_noop_TexCoord3fv( const GLfloat
*v
)
464 GET_CURRENT_CONTEXT(ctx
);
465 GLfloat
*dest
= ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
];
466 COPY_FLOAT(dest
[0], v
[0]);
467 COPY_FLOAT(dest
[1], v
[1]);
468 COPY_FLOAT(dest
[2], v
[2]);
472 void _mesa_noop_TexCoord4f( GLfloat a
, GLfloat b
, GLfloat c
, GLfloat d
)
474 GET_CURRENT_CONTEXT(ctx
);
475 GLfloat
*dest
= ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
];
476 COPY_FLOAT(dest
[0], a
);
477 COPY_FLOAT(dest
[1], b
);
478 COPY_FLOAT(dest
[2], c
);
479 COPY_FLOAT(dest
[3], d
);
482 void _mesa_noop_TexCoord4fv( const GLfloat
*v
)
484 GET_CURRENT_CONTEXT(ctx
);
485 GLfloat
*dest
= ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
];
486 COPY_FLOAT(dest
[0], v
[0]);
487 COPY_FLOAT(dest
[1], v
[1]);
488 COPY_FLOAT(dest
[2], v
[2]);
489 COPY_FLOAT(dest
[3], v
[3]);
492 /* Useful outside begin/end?
494 void _mesa_noop_Vertex2fv( const GLfloat
*v
)
499 void _mesa_noop_Vertex3fv( const GLfloat
*v
)
504 void _mesa_noop_Vertex4fv( const GLfloat
*v
)
509 void _mesa_noop_Vertex2f( GLfloat a
, GLfloat b
)
514 void _mesa_noop_Vertex3f( GLfloat a
, GLfloat b
, GLfloat c
)
516 (void) a
; (void) b
; (void) c
;
519 void _mesa_noop_Vertex4f( GLfloat a
, GLfloat b
, GLfloat c
, GLfloat d
)
521 (void) a
; (void) b
; (void) c
; (void) d
;
526 void _mesa_noop_VertexAttrib4fNV( GLuint index
, GLfloat x
,
527 GLfloat y
, GLfloat z
, GLfloat w
)
529 GET_CURRENT_CONTEXT(ctx
);
531 ASSIGN_4V(ctx
->Current
.Attrib
[index
], x
, y
, z
, w
);
535 void _mesa_noop_VertexAttrib4fvNV( GLuint index
, const GLfloat
*v
)
537 GET_CURRENT_CONTEXT(ctx
);
539 ASSIGN_4V(ctx
->Current
.Attrib
[index
], v
[0], v
[1], v
[2], v
[3]);
545 /* Execute a glRectf() function. This is not suitable for GL_COMPILE
546 * modes (as the test for outside begin/end is not compiled),
547 * but may be useful for drivers in circumstances which exclude
548 * display list interactions.
550 * (None of the functions in this file are suitable for GL_COMPILE
553 void _mesa_noop_Rectf( GLfloat x1
, GLfloat y1
, GLfloat x2
, GLfloat y2
)
556 GET_CURRENT_CONTEXT(ctx
);
557 ASSERT_OUTSIDE_BEGIN_END(ctx
);
561 glVertex2f( x1
, y1
);
562 glVertex2f( x2
, y1
);
563 glVertex2f( x2
, y2
);
564 glVertex2f( x1
, y2
);
569 /* Some very basic support for arrays. Drivers without explicit array
570 * support can hook these in, but still need to supply an array-elt
573 void _mesa_noop_DrawArrays(GLenum mode
, GLint start
, GLsizei count
)
575 GET_CURRENT_CONTEXT(ctx
);
578 if (!_mesa_validate_DrawArrays( ctx
, mode
, start
, count
))
582 for (i
= start
; i
<= count
; i
++)
588 void _mesa_noop_DrawElements(GLenum mode
, GLsizei count
, GLenum type
,
589 const GLvoid
*indices
)
591 GET_CURRENT_CONTEXT(ctx
);
594 if (!_mesa_validate_DrawElements( ctx
, mode
, count
, type
, indices
))
600 case GL_UNSIGNED_BYTE
:
601 for (i
= 0 ; i
< count
; i
++)
602 glArrayElement( ((GLubyte
*)indices
)[i
] );
604 case GL_UNSIGNED_SHORT
:
605 for (i
= 0 ; i
< count
; i
++)
606 glArrayElement( ((GLushort
*)indices
)[i
] );
608 case GL_UNSIGNED_INT
:
609 for (i
= 0 ; i
< count
; i
++)
610 glArrayElement( ((GLuint
*)indices
)[i
] );
613 _mesa_error( ctx
, GL_INVALID_ENUM
, "glDrawElements(type)" );
620 void _mesa_noop_DrawRangeElements(GLenum mode
,
621 GLuint start
, GLuint end
,
622 GLsizei count
, GLenum type
,
623 const GLvoid
*indices
)
625 GET_CURRENT_CONTEXT(ctx
);
627 if (_mesa_validate_DrawRangeElements( ctx
, mode
,
629 count
, type
, indices
))
630 glDrawElements( mode
, count
, type
, indices
);