1 /* $Id: api_noop.c,v 1.7 2001/03/20 18:35:23 gareth 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
.FogCoord
= a
;
64 void _mesa_noop_FogCoordfvEXT( const GLfloat
*v
)
66 GET_CURRENT_CONTEXT(ctx
);
67 ctx
->Current
.FogCoord
= *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
.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
.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 GLchan
*color
= ctx
->Current
.Color
;
159 color
[0] = UBYTE_TO_CHAN(a
);
160 color
[1] = UBYTE_TO_CHAN(b
);
161 color
[2] = UBYTE_TO_CHAN(c
);
162 color
[3] = UBYTE_TO_CHAN(d
);
165 void _mesa_noop_Color4ubv( const GLubyte
*v
)
167 GET_CURRENT_CONTEXT(ctx
);
168 GLchan
*color
= ctx
->Current
.Color
;
169 #if CHAN_TYPE == GL_UNSIGNED_BYTE
170 COPY_4UBV( color
, v
);
172 color
[0] = UBYTE_TO_CHAN(v
[0]);
173 color
[1] = UBYTE_TO_CHAN(v
[1]);
174 color
[2] = UBYTE_TO_CHAN(v
[2]);
175 color
[3] = UBYTE_TO_CHAN(v
[3]);
179 void _mesa_noop_Color4f( GLfloat a
, GLfloat b
, GLfloat c
, GLfloat d
)
181 GET_CURRENT_CONTEXT(ctx
);
182 GLchan
*color
= ctx
->Current
.Color
;
183 UNCLAMPED_FLOAT_TO_CHAN(color
[0], a
);
184 UNCLAMPED_FLOAT_TO_CHAN(color
[1], b
);
185 UNCLAMPED_FLOAT_TO_CHAN(color
[2], c
);
186 UNCLAMPED_FLOAT_TO_CHAN(color
[3], d
);
189 void _mesa_noop_Color4fv( const GLfloat
*v
)
191 GET_CURRENT_CONTEXT(ctx
);
192 GLchan
*color
= ctx
->Current
.Color
;
193 UNCLAMPED_FLOAT_TO_CHAN(color
[0], v
[0]);
194 UNCLAMPED_FLOAT_TO_CHAN(color
[1], v
[1]);
195 UNCLAMPED_FLOAT_TO_CHAN(color
[2], v
[2]);
196 UNCLAMPED_FLOAT_TO_CHAN(color
[3], v
[3]);
199 void _mesa_noop_Color3ub( GLubyte a
, GLubyte b
, GLubyte c
)
201 GET_CURRENT_CONTEXT(ctx
);
202 GLchan
*color
= ctx
->Current
.Color
;
203 color
[0] = UBYTE_TO_CHAN(a
);
204 color
[1] = UBYTE_TO_CHAN(b
);
205 color
[2] = UBYTE_TO_CHAN(c
);
209 void _mesa_noop_Color3ubv( const GLubyte
*v
)
211 GET_CURRENT_CONTEXT(ctx
);
212 GLchan
*color
= ctx
->Current
.Color
;
213 color
[0] = UBYTE_TO_CHAN(v
[0]);
214 color
[1] = UBYTE_TO_CHAN(v
[1]);
215 color
[2] = UBYTE_TO_CHAN(v
[2]);
219 void _mesa_noop_Color3f( GLfloat a
, GLfloat b
, GLfloat c
)
221 GET_CURRENT_CONTEXT(ctx
);
222 GLchan
*color
= ctx
->Current
.Color
;
223 UNCLAMPED_FLOAT_TO_CHAN(color
[0], a
);
224 UNCLAMPED_FLOAT_TO_CHAN(color
[1], b
);
225 UNCLAMPED_FLOAT_TO_CHAN(color
[2], c
);
229 void _mesa_noop_Color3fv( const GLfloat
*v
)
231 GET_CURRENT_CONTEXT(ctx
);
232 GLchan
*color
= ctx
->Current
.Color
;
233 UNCLAMPED_FLOAT_TO_CHAN(color
[0], v
[0]);
234 UNCLAMPED_FLOAT_TO_CHAN(color
[1], v
[1]);
235 UNCLAMPED_FLOAT_TO_CHAN(color
[2], v
[2]);
239 void _mesa_noop_MultiTexCoord1fARB( GLenum target
, GLfloat a
)
241 GET_CURRENT_CONTEXT(ctx
);
242 GLuint unit
= target
- GL_TEXTURE0_ARB
;
244 /* unit is unsigned -- cannot be less than zero.
246 if (unit
< MAX_TEXTURE_UNITS
)
248 GLfloat
*dest
= ctx
->Current
.Texcoord
[unit
];
249 COPY_FLOAT(dest
[0], a
);
256 void _mesa_noop_MultiTexCoord1fvARB( GLenum target
, GLfloat
*v
)
258 GET_CURRENT_CONTEXT(ctx
);
259 GLuint unit
= target
- GL_TEXTURE0_ARB
;
261 /* unit is unsigned -- cannot be less than zero.
263 if (unit
< MAX_TEXTURE_UNITS
)
265 GLfloat
*dest
= ctx
->Current
.Texcoord
[unit
];
266 COPY_FLOAT(dest
[0], v
[0]);
273 void _mesa_noop_MultiTexCoord2fARB( GLenum target
, GLfloat a
, GLfloat b
)
275 GET_CURRENT_CONTEXT(ctx
);
276 GLuint unit
= target
- GL_TEXTURE0_ARB
;
278 /* unit is unsigned -- cannot be less than zero.
280 if (unit
< MAX_TEXTURE_UNITS
)
282 GLfloat
*dest
= ctx
->Current
.Texcoord
[unit
];
283 COPY_FLOAT(dest
[0], a
);
284 COPY_FLOAT(dest
[1], b
);
290 void _mesa_noop_MultiTexCoord2fvARB( GLenum target
, GLfloat
*v
)
292 GET_CURRENT_CONTEXT(ctx
);
293 GLuint unit
= target
- GL_TEXTURE0_ARB
;
295 /* unit is unsigned -- cannot be less than zero.
297 if (unit
< MAX_TEXTURE_UNITS
)
299 GLfloat
*dest
= ctx
->Current
.Texcoord
[unit
];
300 COPY_FLOAT(dest
[0], v
[0]);
301 COPY_FLOAT(dest
[1], v
[1]);
307 void _mesa_noop_MultiTexCoord3fARB( GLenum target
, GLfloat a
, GLfloat b
, GLfloat c
)
309 GET_CURRENT_CONTEXT(ctx
);
310 GLuint unit
= target
- GL_TEXTURE0_ARB
;
312 /* unit is unsigned -- cannot be less than zero.
314 if (unit
< MAX_TEXTURE_UNITS
)
316 GLfloat
*dest
= ctx
->Current
.Texcoord
[unit
];
317 COPY_FLOAT(dest
[0], a
);
318 COPY_FLOAT(dest
[1], b
);
319 COPY_FLOAT(dest
[2], c
);
324 void _mesa_noop_MultiTexCoord3fvARB( GLenum target
, GLfloat
*v
)
326 GET_CURRENT_CONTEXT(ctx
);
327 GLuint unit
= target
- GL_TEXTURE0_ARB
;
329 /* unit is unsigned -- cannot be less than zero.
331 if (unit
< MAX_TEXTURE_UNITS
)
333 GLfloat
*dest
= ctx
->Current
.Texcoord
[unit
];
334 COPY_FLOAT(dest
[0], v
[0]);
335 COPY_FLOAT(dest
[1], v
[1]);
336 COPY_FLOAT(dest
[2], v
[2]);
341 void _mesa_noop_MultiTexCoord4fARB( GLenum target
, GLfloat a
, GLfloat b
,
342 GLfloat c
, GLfloat d
)
344 GET_CURRENT_CONTEXT(ctx
);
345 GLuint unit
= target
- GL_TEXTURE0_ARB
;
347 /* unit is unsigned -- cannot be less than zero.
349 if (unit
< MAX_TEXTURE_UNITS
)
351 GLfloat
*dest
= ctx
->Current
.Texcoord
[unit
];
352 COPY_FLOAT(dest
[0], a
);
353 COPY_FLOAT(dest
[1], b
);
354 COPY_FLOAT(dest
[2], c
);
359 void _mesa_noop_MultiTexCoord4fvARB( GLenum target
, GLfloat
*v
)
361 GET_CURRENT_CONTEXT(ctx
);
362 GLuint unit
= target
- GL_TEXTURE0_ARB
;
364 /* unit is unsigned -- cannot be less than zero.
366 if (unit
< MAX_TEXTURE_UNITS
)
368 GLfloat
*dest
= ctx
->Current
.Texcoord
[unit
];
369 COPY_FLOAT(dest
[0], v
[0]);
370 COPY_FLOAT(dest
[1], v
[1]);
371 COPY_FLOAT(dest
[2], v
[2]);
372 COPY_FLOAT(dest
[3], v
[3]);
376 void _mesa_noop_SecondaryColor3ubEXT( GLubyte a
, GLubyte b
, GLubyte c
)
378 GET_CURRENT_CONTEXT(ctx
);
379 GLchan
*color
= ctx
->Current
.SecondaryColor
;
380 color
[0] = UBYTE_TO_CHAN(a
);
381 color
[1] = UBYTE_TO_CHAN(b
);
382 color
[2] = UBYTE_TO_CHAN(c
);
386 void _mesa_noop_SecondaryColor3ubvEXT( const GLubyte
*v
)
388 GET_CURRENT_CONTEXT(ctx
);
389 GLchan
*color
= ctx
->Current
.SecondaryColor
;
390 color
[0] = UBYTE_TO_CHAN(v
[0]);
391 color
[1] = UBYTE_TO_CHAN(v
[1]);
392 color
[2] = UBYTE_TO_CHAN(v
[2]);
396 void _mesa_noop_SecondaryColor3fEXT( GLfloat a
, GLfloat b
, GLfloat c
)
398 GET_CURRENT_CONTEXT(ctx
);
399 GLchan
*color
= ctx
->Current
.SecondaryColor
;
400 UNCLAMPED_FLOAT_TO_CHAN(color
[0], a
);
401 UNCLAMPED_FLOAT_TO_CHAN(color
[1], b
);
402 UNCLAMPED_FLOAT_TO_CHAN(color
[2], c
);
406 void _mesa_noop_SecondaryColor3fvEXT( const GLfloat
*v
)
408 GET_CURRENT_CONTEXT(ctx
);
409 GLchan
*color
= ctx
->Current
.SecondaryColor
;
410 UNCLAMPED_FLOAT_TO_CHAN(color
[0], v
[0]);
411 UNCLAMPED_FLOAT_TO_CHAN(color
[1], v
[1]);
412 UNCLAMPED_FLOAT_TO_CHAN(color
[2], v
[2]);
416 void _mesa_noop_TexCoord1f( GLfloat a
)
418 GET_CURRENT_CONTEXT(ctx
);
419 GLfloat
*dest
= ctx
->Current
.Texcoord
[0];
420 COPY_FLOAT(dest
[0], a
);
426 void _mesa_noop_TexCoord1fv( GLfloat
*v
)
428 GET_CURRENT_CONTEXT(ctx
);
429 GLfloat
*dest
= ctx
->Current
.Texcoord
[0];
430 COPY_FLOAT(dest
[0], v
[0]);
436 void _mesa_noop_TexCoord2f( GLfloat a
, GLfloat b
)
438 GET_CURRENT_CONTEXT(ctx
);
439 GLfloat
*dest
= ctx
->Current
.Texcoord
[0];
440 COPY_FLOAT(dest
[0], a
);
441 COPY_FLOAT(dest
[1], b
);
446 void _mesa_noop_TexCoord2fv( GLfloat
*v
)
448 GET_CURRENT_CONTEXT(ctx
);
449 GLfloat
*dest
= ctx
->Current
.Texcoord
[0];
450 COPY_FLOAT(dest
[0], v
[0]);
451 COPY_FLOAT(dest
[1], v
[1]);
456 void _mesa_noop_TexCoord3f( GLfloat a
, GLfloat b
, GLfloat c
)
458 GET_CURRENT_CONTEXT(ctx
);
459 GLfloat
*dest
= ctx
->Current
.Texcoord
[0];
460 COPY_FLOAT(dest
[0], a
);
461 COPY_FLOAT(dest
[1], b
);
462 COPY_FLOAT(dest
[2], c
);
466 void _mesa_noop_TexCoord3fv( GLfloat
*v
)
468 GET_CURRENT_CONTEXT(ctx
);
469 GLfloat
*dest
= ctx
->Current
.Texcoord
[0];
470 COPY_FLOAT(dest
[0], v
[0]);
471 COPY_FLOAT(dest
[1], v
[1]);
472 COPY_FLOAT(dest
[2], v
[2]);
476 void _mesa_noop_TexCoord4f( GLfloat a
, GLfloat b
, GLfloat c
, GLfloat d
)
478 GET_CURRENT_CONTEXT(ctx
);
479 GLfloat
*dest
= ctx
->Current
.Texcoord
[0];
480 COPY_FLOAT(dest
[0], a
);
481 COPY_FLOAT(dest
[1], b
);
482 COPY_FLOAT(dest
[2], c
);
483 COPY_FLOAT(dest
[3], d
);
486 void _mesa_noop_TexCoord4fv( GLfloat
*v
)
488 GET_CURRENT_CONTEXT(ctx
);
489 GLfloat
*dest
= ctx
->Current
.Texcoord
[0];
490 COPY_FLOAT(dest
[0], v
[0]);
491 COPY_FLOAT(dest
[1], v
[1]);
492 COPY_FLOAT(dest
[2], v
[2]);
493 COPY_FLOAT(dest
[3], v
[3]);
496 /* Execute a glRectf() function. This is not suitable for GL_COMPILE
497 * modes (as the test for outside begin/end is not compiled),
498 * but may be useful for drivers in circumstances which exclude
499 * display list interactions.
501 * (None of the functions in this file are suitable for GL_COMPILE
504 void _mesa_noop_Rectf( GLfloat x1
, GLfloat y1
, GLfloat x2
, GLfloat y2
)
507 GET_CURRENT_CONTEXT(ctx
);
508 ASSERT_OUTSIDE_BEGIN_END(ctx
);
512 glVertex2f( x1
, y1
);
513 glVertex2f( x2
, y1
);
514 glVertex2f( x2
, y2
);
515 glVertex2f( x1
, y2
);
520 /* Some very basic support for arrays. Drivers without explicit array
521 * support can hook these in, but still need to supply an array-elt
524 void _mesa_noop_DrawArrays(GLenum mode
, GLint start
, GLsizei count
)
526 GET_CURRENT_CONTEXT(ctx
);
529 if (!_mesa_validate_DrawArrays( ctx
, mode
, start
, count
))
533 for (i
= start
; i
<= count
; i
++)
539 void _mesa_noop_DrawElements(GLenum mode
, GLsizei count
, GLenum type
,
540 const GLvoid
*indices
)
542 GET_CURRENT_CONTEXT(ctx
);
545 if (!_mesa_validate_DrawElements( ctx
, mode
, count
, type
, indices
))
551 case GL_UNSIGNED_BYTE
:
552 for (i
= 0 ; i
< count
; i
++)
553 glArrayElement( ((GLubyte
*)indices
)[i
] );
555 case GL_UNSIGNED_SHORT
:
556 for (i
= 0 ; i
< count
; i
++)
557 glArrayElement( ((GLushort
*)indices
)[i
] );
559 case GL_UNSIGNED_INT
:
560 for (i
= 0 ; i
< count
; i
++)
561 glArrayElement( ((GLuint
*)indices
)[i
] );
564 _mesa_error( ctx
, GL_INVALID_ENUM
, "glDrawElements(type)" );
571 void _mesa_noop_DrawRangeElements(GLenum mode
,
572 GLuint start
, GLuint end
,
573 GLsizei count
, GLenum type
,
574 const GLvoid
*indices
)
576 GET_CURRENT_CONTEXT(ctx
);
578 if (_mesa_validate_DrawRangeElements( ctx
, mode
,
580 count
, type
, indices
))
581 glDrawElements( mode
, count
, type
, indices
);