1 /* $Id: api_noop.c,v 1.5 2001/03/03 20:33:27 brianp 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 #define COPY_FLOAT(a,b) *(int*)&(a) = *(int*)&(b)
41 #define COPY_FLOAT(a,b) (a) = (b)
44 /* In states where certain vertex components are required for t&l or
45 * rasterization, we still need to keep track of the current values.
46 * These functions provide this service by keeping uptodate the
47 * 'ctx->Current' struct for all data elements not included in the
48 * currently enabled hardware vertex.
51 void _mesa_noop_EdgeFlag( GLboolean b
)
53 GET_CURRENT_CONTEXT(ctx
);
54 ctx
->Current
.EdgeFlag
= b
;
57 void _mesa_noop_EdgeFlagv( const GLboolean
*b
)
59 GET_CURRENT_CONTEXT(ctx
);
60 ctx
->Current
.EdgeFlag
= *b
;
63 void _mesa_noop_FogCoordfEXT( GLfloat a
)
65 GET_CURRENT_CONTEXT(ctx
);
66 ctx
->Current
.FogCoord
= a
;
69 void _mesa_noop_FogCoordfvEXT( const GLfloat
*v
)
71 GET_CURRENT_CONTEXT(ctx
);
72 ctx
->Current
.FogCoord
= *v
;
75 void _mesa_noop_Indexi( GLint i
)
77 GET_CURRENT_CONTEXT(ctx
);
78 ctx
->Current
.Index
= i
;
81 void _mesa_noop_Indexiv( const GLint
*v
)
83 GET_CURRENT_CONTEXT(ctx
);
84 ctx
->Current
.Index
= *v
;
87 void _mesa_noop_Normal3f( GLfloat a
, GLfloat b
, GLfloat c
)
89 GET_CURRENT_CONTEXT(ctx
);
90 GLfloat
*dest
= ctx
->Current
.Normal
;
91 COPY_FLOAT(dest
[0], a
);
92 COPY_FLOAT(dest
[1], b
);
93 COPY_FLOAT(dest
[2], c
);
96 void _mesa_noop_Normal3fv( const GLfloat
*v
)
98 GET_CURRENT_CONTEXT(ctx
);
99 GLfloat
*dest
= ctx
->Current
.Normal
;
100 COPY_FLOAT(dest
[0], v
[0]);
101 COPY_FLOAT(dest
[1], v
[1]);
102 COPY_FLOAT(dest
[2], v
[2]);
105 void _mesa_noop_Materialfv( GLenum face
, GLenum pname
, const GLfloat
*params
)
107 GET_CURRENT_CONTEXT(ctx
);
108 struct gl_material mat
[2];
109 GLuint bitmask
= _mesa_material_bitmask( ctx
, face
, pname
, ~0,
110 "_mesa_noop_Materialfv" );
114 if (bitmask
& FRONT_AMBIENT_BIT
) {
115 COPY_4FV( mat
[0].Ambient
, params
);
117 if (bitmask
& BACK_AMBIENT_BIT
) {
118 COPY_4FV( mat
[1].Ambient
, params
);
120 if (bitmask
& FRONT_DIFFUSE_BIT
) {
121 COPY_4FV( mat
[0].Diffuse
, params
);
123 if (bitmask
& BACK_DIFFUSE_BIT
) {
124 COPY_4FV( mat
[1].Diffuse
, params
);
126 if (bitmask
& FRONT_SPECULAR_BIT
) {
127 COPY_4FV( mat
[0].Specular
, params
);
129 if (bitmask
& BACK_SPECULAR_BIT
) {
130 COPY_4FV( mat
[1].Specular
, params
);
132 if (bitmask
& FRONT_EMISSION_BIT
) {
133 COPY_4FV( mat
[0].Emission
, params
);
135 if (bitmask
& BACK_EMISSION_BIT
) {
136 COPY_4FV( mat
[1].Emission
, params
);
138 if (bitmask
& FRONT_SHININESS_BIT
) {
139 GLfloat shininess
= CLAMP( params
[0], 0.0F
, 128.0F
);
140 mat
[0].Shininess
= shininess
;
142 if (bitmask
& BACK_SHININESS_BIT
) {
143 GLfloat shininess
= CLAMP( params
[0], 0.0F
, 128.0F
);
144 mat
[1].Shininess
= shininess
;
146 if (bitmask
& FRONT_INDEXES_BIT
) {
147 mat
[0].AmbientIndex
= params
[0];
148 mat
[0].DiffuseIndex
= params
[1];
149 mat
[0].SpecularIndex
= params
[2];
151 if (bitmask
& BACK_INDEXES_BIT
) {
152 mat
[1].AmbientIndex
= params
[0];
153 mat
[1].DiffuseIndex
= params
[1];
154 mat
[1].SpecularIndex
= params
[2];
157 _mesa_update_material( ctx
, mat
, bitmask
);
160 void _mesa_noop_Color4ub( GLubyte a
, GLubyte b
, GLubyte c
, GLubyte d
)
162 GET_CURRENT_CONTEXT(ctx
);
163 GLchan
*color
= ctx
->Current
.Color
;
164 color
[0] = UBYTE_TO_CHAN(a
);
165 color
[1] = UBYTE_TO_CHAN(b
);
166 color
[2] = UBYTE_TO_CHAN(c
);
167 color
[3] = UBYTE_TO_CHAN(d
);
170 void _mesa_noop_Color4ubv( const GLubyte
*v
)
172 GET_CURRENT_CONTEXT(ctx
);
173 GLchan
*color
= ctx
->Current
.Color
;
174 #if CHAN_TYPE == GL_UNSIGNED_BYTE
175 COPY_4UBV( color
, v
);
177 color
[0] = UBYTE_TO_CHAN(v
[0]);
178 color
[1] = UBYTE_TO_CHAN(v
[1]);
179 color
[2] = UBYTE_TO_CHAN(v
[2]);
180 color
[3] = UBYTE_TO_CHAN(v
[3]);
184 void _mesa_noop_Color4f( GLfloat a
, GLfloat b
, GLfloat c
, GLfloat d
)
186 GET_CURRENT_CONTEXT(ctx
);
187 GLchan
*color
= ctx
->Current
.Color
;
188 UNCLAMPED_FLOAT_TO_CHAN(color
[0], a
);
189 UNCLAMPED_FLOAT_TO_CHAN(color
[1], b
);
190 UNCLAMPED_FLOAT_TO_CHAN(color
[2], c
);
191 UNCLAMPED_FLOAT_TO_CHAN(color
[3], d
);
194 void _mesa_noop_Color4fv( const GLfloat
*v
)
196 GET_CURRENT_CONTEXT(ctx
);
197 GLchan
*color
= ctx
->Current
.Color
;
198 UNCLAMPED_FLOAT_TO_CHAN(color
[0], v
[0]);
199 UNCLAMPED_FLOAT_TO_CHAN(color
[1], v
[1]);
200 UNCLAMPED_FLOAT_TO_CHAN(color
[2], v
[2]);
203 void _mesa_noop_Color3ub( GLubyte a
, GLubyte b
, GLubyte c
)
205 GET_CURRENT_CONTEXT(ctx
);
206 GLchan
*color
= ctx
->Current
.Color
;
207 color
[0] = UBYTE_TO_CHAN(a
);
208 color
[1] = UBYTE_TO_CHAN(b
);
209 color
[2] = UBYTE_TO_CHAN(c
);
213 void _mesa_noop_Color3ubv( const GLubyte
*v
)
215 GET_CURRENT_CONTEXT(ctx
);
216 GLchan
*color
= ctx
->Current
.Color
;
217 color
[0] = UBYTE_TO_CHAN(v
[0]);
218 color
[1] = UBYTE_TO_CHAN(v
[1]);
219 color
[2] = UBYTE_TO_CHAN(v
[2]);
223 void _mesa_noop_Color3f( GLfloat a
, GLfloat b
, GLfloat c
)
225 GET_CURRENT_CONTEXT(ctx
);
226 GLchan
*color
= ctx
->Current
.Color
;
227 UNCLAMPED_FLOAT_TO_CHAN(color
[0], a
);
228 UNCLAMPED_FLOAT_TO_CHAN(color
[1], b
);
229 UNCLAMPED_FLOAT_TO_CHAN(color
[2], c
);
233 void _mesa_noop_Color3fv( const GLfloat
*v
)
235 GET_CURRENT_CONTEXT(ctx
);
236 GLchan
*color
= ctx
->Current
.Color
;
237 UNCLAMPED_FLOAT_TO_CHAN(color
[0], v
[0]);
238 UNCLAMPED_FLOAT_TO_CHAN(color
[1], v
[1]);
239 UNCLAMPED_FLOAT_TO_CHAN(color
[2], v
[2]);
243 void _mesa_noop_MultiTexCoord1fARB( GLenum target
, GLfloat a
)
245 GET_CURRENT_CONTEXT(ctx
);
246 GLuint unit
= target
- GL_TEXTURE0_ARB
;
248 /* unit is unsigned -- cannot be less than zero.
250 if (unit
< MAX_TEXTURE_UNITS
)
252 GLfloat
*dest
= ctx
->Current
.Texcoord
[unit
];
253 COPY_FLOAT(dest
[0], a
);
260 void _mesa_noop_MultiTexCoord1fvARB( GLenum target
, GLfloat
*v
)
262 GET_CURRENT_CONTEXT(ctx
);
263 GLuint unit
= target
- GL_TEXTURE0_ARB
;
265 /* unit is unsigned -- cannot be less than zero.
267 if (unit
< MAX_TEXTURE_UNITS
)
269 GLfloat
*dest
= ctx
->Current
.Texcoord
[unit
];
270 COPY_FLOAT(dest
[0], v
[0]);
277 void _mesa_noop_MultiTexCoord2fARB( GLenum target
, GLfloat a
, GLfloat b
)
279 GET_CURRENT_CONTEXT(ctx
);
280 GLuint unit
= target
- GL_TEXTURE0_ARB
;
282 /* unit is unsigned -- cannot be less than zero.
284 if (unit
< MAX_TEXTURE_UNITS
)
286 GLfloat
*dest
= ctx
->Current
.Texcoord
[unit
];
287 COPY_FLOAT(dest
[0], a
);
288 COPY_FLOAT(dest
[1], b
);
294 void _mesa_noop_MultiTexCoord2fvARB( GLenum target
, GLfloat
*v
)
296 GET_CURRENT_CONTEXT(ctx
);
297 GLuint unit
= target
- GL_TEXTURE0_ARB
;
299 /* unit is unsigned -- cannot be less than zero.
301 if (unit
< MAX_TEXTURE_UNITS
)
303 GLfloat
*dest
= ctx
->Current
.Texcoord
[unit
];
304 COPY_FLOAT(dest
[0], v
[0]);
305 COPY_FLOAT(dest
[1], v
[1]);
311 void _mesa_noop_MultiTexCoord3fARB( GLenum target
, GLfloat a
, GLfloat b
, GLfloat c
)
313 GET_CURRENT_CONTEXT(ctx
);
314 GLuint unit
= target
- GL_TEXTURE0_ARB
;
316 /* unit is unsigned -- cannot be less than zero.
318 if (unit
< MAX_TEXTURE_UNITS
)
320 GLfloat
*dest
= ctx
->Current
.Texcoord
[unit
];
321 COPY_FLOAT(dest
[0], a
);
322 COPY_FLOAT(dest
[1], b
);
323 COPY_FLOAT(dest
[2], c
);
328 void _mesa_noop_MultiTexCoord3fvARB( GLenum target
, GLfloat
*v
)
330 GET_CURRENT_CONTEXT(ctx
);
331 GLuint unit
= target
- GL_TEXTURE0_ARB
;
333 /* unit is unsigned -- cannot be less than zero.
335 if (unit
< MAX_TEXTURE_UNITS
)
337 GLfloat
*dest
= ctx
->Current
.Texcoord
[unit
];
338 COPY_FLOAT(dest
[0], v
[0]);
339 COPY_FLOAT(dest
[1], v
[1]);
340 COPY_FLOAT(dest
[2], v
[2]);
345 void _mesa_noop_MultiTexCoord4fARB( GLenum target
, GLfloat a
, GLfloat b
,
346 GLfloat c
, GLfloat d
)
348 GET_CURRENT_CONTEXT(ctx
);
349 GLuint unit
= target
- GL_TEXTURE0_ARB
;
351 /* unit is unsigned -- cannot be less than zero.
353 if (unit
< MAX_TEXTURE_UNITS
)
355 GLfloat
*dest
= ctx
->Current
.Texcoord
[unit
];
356 COPY_FLOAT(dest
[0], a
);
357 COPY_FLOAT(dest
[1], b
);
358 COPY_FLOAT(dest
[2], c
);
363 void _mesa_noop_MultiTexCoord4fvARB( GLenum target
, GLfloat
*v
)
365 GET_CURRENT_CONTEXT(ctx
);
366 GLuint unit
= target
- GL_TEXTURE0_ARB
;
368 /* unit is unsigned -- cannot be less than zero.
370 if (unit
< MAX_TEXTURE_UNITS
)
372 GLfloat
*dest
= ctx
->Current
.Texcoord
[unit
];
373 COPY_FLOAT(dest
[0], v
[0]);
374 COPY_FLOAT(dest
[1], v
[1]);
375 COPY_FLOAT(dest
[2], v
[2]);
376 COPY_FLOAT(dest
[3], v
[3]);
380 void _mesa_noop_SecondaryColor3ubEXT( GLubyte a
, GLubyte b
, GLubyte c
)
382 GET_CURRENT_CONTEXT(ctx
);
383 GLchan
*color
= ctx
->Current
.SecondaryColor
;
384 color
[0] = UBYTE_TO_CHAN(a
);
385 color
[1] = UBYTE_TO_CHAN(b
);
386 color
[2] = UBYTE_TO_CHAN(c
);
390 void _mesa_noop_SecondaryColor3ubvEXT( const GLubyte
*v
)
392 GET_CURRENT_CONTEXT(ctx
);
393 GLchan
*color
= ctx
->Current
.SecondaryColor
;
394 color
[0] = UBYTE_TO_CHAN(v
[0]);
395 color
[1] = UBYTE_TO_CHAN(v
[1]);
396 color
[2] = UBYTE_TO_CHAN(v
[2]);
400 void _mesa_noop_SecondaryColor3fEXT( GLfloat a
, GLfloat b
, GLfloat c
)
402 GET_CURRENT_CONTEXT(ctx
);
403 GLchan
*color
= ctx
->Current
.SecondaryColor
;
404 UNCLAMPED_FLOAT_TO_CHAN(color
[0], a
);
405 UNCLAMPED_FLOAT_TO_CHAN(color
[1], b
);
406 UNCLAMPED_FLOAT_TO_CHAN(color
[2], c
);
410 void _mesa_noop_SecondaryColor3fvEXT( const GLfloat
*v
)
412 GET_CURRENT_CONTEXT(ctx
);
413 GLchan
*color
= ctx
->Current
.SecondaryColor
;
414 UNCLAMPED_FLOAT_TO_CHAN(color
[0], v
[0]);
415 UNCLAMPED_FLOAT_TO_CHAN(color
[1], v
[1]);
416 UNCLAMPED_FLOAT_TO_CHAN(color
[2], v
[2]);
420 void _mesa_noop_TexCoord1f( GLfloat a
)
422 GET_CURRENT_CONTEXT(ctx
);
423 GLfloat
*dest
= ctx
->Current
.Texcoord
[0];
424 COPY_FLOAT(dest
[0], a
);
430 void _mesa_noop_TexCoord1fv( GLfloat
*v
)
432 GET_CURRENT_CONTEXT(ctx
);
433 GLfloat
*dest
= ctx
->Current
.Texcoord
[0];
434 COPY_FLOAT(dest
[0], v
[0]);
440 void _mesa_noop_TexCoord2f( GLfloat a
, GLfloat b
)
442 GET_CURRENT_CONTEXT(ctx
);
443 GLfloat
*dest
= ctx
->Current
.Texcoord
[0];
444 COPY_FLOAT(dest
[0], a
);
445 COPY_FLOAT(dest
[1], b
);
450 void _mesa_noop_TexCoord2fv( GLfloat
*v
)
452 GET_CURRENT_CONTEXT(ctx
);
453 GLfloat
*dest
= ctx
->Current
.Texcoord
[0];
454 COPY_FLOAT(dest
[0], v
[0]);
455 COPY_FLOAT(dest
[1], v
[1]);
460 void _mesa_noop_TexCoord3f( GLfloat a
, GLfloat b
, GLfloat c
)
462 GET_CURRENT_CONTEXT(ctx
);
463 GLfloat
*dest
= ctx
->Current
.Texcoord
[0];
464 COPY_FLOAT(dest
[0], a
);
465 COPY_FLOAT(dest
[1], b
);
466 COPY_FLOAT(dest
[2], c
);
470 void _mesa_noop_TexCoord3fv( GLfloat
*v
)
472 GET_CURRENT_CONTEXT(ctx
);
473 GLfloat
*dest
= ctx
->Current
.Texcoord
[0];
474 COPY_FLOAT(dest
[0], v
[0]);
475 COPY_FLOAT(dest
[1], v
[1]);
476 COPY_FLOAT(dest
[2], v
[2]);
480 void _mesa_noop_TexCoord4f( GLfloat a
, GLfloat b
, GLfloat c
, GLfloat d
)
482 GET_CURRENT_CONTEXT(ctx
);
483 GLfloat
*dest
= ctx
->Current
.Texcoord
[0];
484 COPY_FLOAT(dest
[0], a
);
485 COPY_FLOAT(dest
[1], b
);
486 COPY_FLOAT(dest
[2], c
);
487 COPY_FLOAT(dest
[3], d
);
490 void _mesa_noop_TexCoord4fv( GLfloat
*v
)
492 GET_CURRENT_CONTEXT(ctx
);
493 GLfloat
*dest
= ctx
->Current
.Texcoord
[0];
494 COPY_FLOAT(dest
[0], v
[0]);
495 COPY_FLOAT(dest
[1], v
[1]);
496 COPY_FLOAT(dest
[2], v
[2]);
497 COPY_FLOAT(dest
[3], v
[3]);
500 /* Execute a glRectf() function. This is not suitable for GL_COMPILE
501 * modes (as the test for outside begin/end is not compiled),
502 * but may be useful for drivers in circumstances which exclude
503 * display list interactions.
505 * (None of the functions in this file are suitable for GL_COMPILE
508 void _mesa_noop_Rectf( GLfloat x1
, GLfloat y1
, GLfloat x2
, GLfloat y2
)
511 GET_CURRENT_CONTEXT(ctx
);
512 ASSERT_OUTSIDE_BEGIN_END(ctx
);
516 glVertex2f( x1
, y1
);
517 glVertex2f( x2
, y1
);
518 glVertex2f( x2
, y2
);
519 glVertex2f( x1
, y2
);
524 /* Some very basic support for arrays. Drivers without explicit array
525 * support can hook these in, but still need to supply an array-elt
528 void _mesa_noop_DrawArrays(GLenum mode
, GLint start
, GLsizei count
)
530 GET_CURRENT_CONTEXT(ctx
);
533 if (!_mesa_validate_DrawArrays( ctx
, mode
, start
, count
))
537 for (i
= start
; i
<= count
; i
++)
543 void _mesa_noop_DrawElements(GLenum mode
, GLsizei count
, GLenum type
,
544 const GLvoid
*indices
)
546 GET_CURRENT_CONTEXT(ctx
);
549 if (!_mesa_validate_DrawElements( ctx
, mode
, count
, type
, indices
))
555 case GL_UNSIGNED_BYTE
:
556 for (i
= 0 ; i
< count
; i
++)
557 glArrayElement( ((GLubyte
*)indices
)[i
] );
559 case GL_UNSIGNED_SHORT
:
560 for (i
= 0 ; i
< count
; i
++)
561 glArrayElement( ((GLushort
*)indices
)[i
] );
563 case GL_UNSIGNED_INT
:
564 for (i
= 0 ; i
< count
; i
++)
565 glArrayElement( ((GLuint
*)indices
)[i
] );
568 _mesa_error( ctx
, GL_INVALID_ENUM
, "glDrawElements(type)" );
575 void _mesa_noop_DrawRangeElements(GLenum mode
,
576 GLuint start
, GLuint end
,
577 GLsizei count
, GLenum type
,
578 const GLvoid
*indices
)
580 GET_CURRENT_CONTEXT(ctx
);
582 if (_mesa_validate_DrawRangeElements( ctx
, mode
,
584 count
, type
, indices
))
585 glDrawElements( mode
, count
, type
, indices
);