1 /* $Id: api_noop.c,v 1.6 2001/03/07 18:16:40 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 #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]);
201 UNCLAMPED_FLOAT_TO_CHAN(color
[3], v
[3]);
204 void _mesa_noop_Color3ub( GLubyte a
, GLubyte b
, GLubyte c
)
206 GET_CURRENT_CONTEXT(ctx
);
207 GLchan
*color
= ctx
->Current
.Color
;
208 color
[0] = UBYTE_TO_CHAN(a
);
209 color
[1] = UBYTE_TO_CHAN(b
);
210 color
[2] = UBYTE_TO_CHAN(c
);
214 void _mesa_noop_Color3ubv( const GLubyte
*v
)
216 GET_CURRENT_CONTEXT(ctx
);
217 GLchan
*color
= ctx
->Current
.Color
;
218 color
[0] = UBYTE_TO_CHAN(v
[0]);
219 color
[1] = UBYTE_TO_CHAN(v
[1]);
220 color
[2] = UBYTE_TO_CHAN(v
[2]);
224 void _mesa_noop_Color3f( GLfloat a
, GLfloat b
, GLfloat c
)
226 GET_CURRENT_CONTEXT(ctx
);
227 GLchan
*color
= ctx
->Current
.Color
;
228 UNCLAMPED_FLOAT_TO_CHAN(color
[0], a
);
229 UNCLAMPED_FLOAT_TO_CHAN(color
[1], b
);
230 UNCLAMPED_FLOAT_TO_CHAN(color
[2], c
);
234 void _mesa_noop_Color3fv( const GLfloat
*v
)
236 GET_CURRENT_CONTEXT(ctx
);
237 GLchan
*color
= ctx
->Current
.Color
;
238 UNCLAMPED_FLOAT_TO_CHAN(color
[0], v
[0]);
239 UNCLAMPED_FLOAT_TO_CHAN(color
[1], v
[1]);
240 UNCLAMPED_FLOAT_TO_CHAN(color
[2], v
[2]);
244 void _mesa_noop_MultiTexCoord1fARB( GLenum target
, GLfloat a
)
246 GET_CURRENT_CONTEXT(ctx
);
247 GLuint unit
= target
- GL_TEXTURE0_ARB
;
249 /* unit is unsigned -- cannot be less than zero.
251 if (unit
< MAX_TEXTURE_UNITS
)
253 GLfloat
*dest
= ctx
->Current
.Texcoord
[unit
];
254 COPY_FLOAT(dest
[0], a
);
261 void _mesa_noop_MultiTexCoord1fvARB( GLenum target
, GLfloat
*v
)
263 GET_CURRENT_CONTEXT(ctx
);
264 GLuint unit
= target
- GL_TEXTURE0_ARB
;
266 /* unit is unsigned -- cannot be less than zero.
268 if (unit
< MAX_TEXTURE_UNITS
)
270 GLfloat
*dest
= ctx
->Current
.Texcoord
[unit
];
271 COPY_FLOAT(dest
[0], v
[0]);
278 void _mesa_noop_MultiTexCoord2fARB( GLenum target
, GLfloat a
, GLfloat b
)
280 GET_CURRENT_CONTEXT(ctx
);
281 GLuint unit
= target
- GL_TEXTURE0_ARB
;
283 /* unit is unsigned -- cannot be less than zero.
285 if (unit
< MAX_TEXTURE_UNITS
)
287 GLfloat
*dest
= ctx
->Current
.Texcoord
[unit
];
288 COPY_FLOAT(dest
[0], a
);
289 COPY_FLOAT(dest
[1], b
);
295 void _mesa_noop_MultiTexCoord2fvARB( GLenum target
, GLfloat
*v
)
297 GET_CURRENT_CONTEXT(ctx
);
298 GLuint unit
= target
- GL_TEXTURE0_ARB
;
300 /* unit is unsigned -- cannot be less than zero.
302 if (unit
< MAX_TEXTURE_UNITS
)
304 GLfloat
*dest
= ctx
->Current
.Texcoord
[unit
];
305 COPY_FLOAT(dest
[0], v
[0]);
306 COPY_FLOAT(dest
[1], v
[1]);
312 void _mesa_noop_MultiTexCoord3fARB( GLenum target
, GLfloat a
, GLfloat b
, GLfloat c
)
314 GET_CURRENT_CONTEXT(ctx
);
315 GLuint unit
= target
- GL_TEXTURE0_ARB
;
317 /* unit is unsigned -- cannot be less than zero.
319 if (unit
< MAX_TEXTURE_UNITS
)
321 GLfloat
*dest
= ctx
->Current
.Texcoord
[unit
];
322 COPY_FLOAT(dest
[0], a
);
323 COPY_FLOAT(dest
[1], b
);
324 COPY_FLOAT(dest
[2], c
);
329 void _mesa_noop_MultiTexCoord3fvARB( GLenum target
, GLfloat
*v
)
331 GET_CURRENT_CONTEXT(ctx
);
332 GLuint unit
= target
- GL_TEXTURE0_ARB
;
334 /* unit is unsigned -- cannot be less than zero.
336 if (unit
< MAX_TEXTURE_UNITS
)
338 GLfloat
*dest
= ctx
->Current
.Texcoord
[unit
];
339 COPY_FLOAT(dest
[0], v
[0]);
340 COPY_FLOAT(dest
[1], v
[1]);
341 COPY_FLOAT(dest
[2], v
[2]);
346 void _mesa_noop_MultiTexCoord4fARB( GLenum target
, GLfloat a
, GLfloat b
,
347 GLfloat c
, GLfloat d
)
349 GET_CURRENT_CONTEXT(ctx
);
350 GLuint unit
= target
- GL_TEXTURE0_ARB
;
352 /* unit is unsigned -- cannot be less than zero.
354 if (unit
< MAX_TEXTURE_UNITS
)
356 GLfloat
*dest
= ctx
->Current
.Texcoord
[unit
];
357 COPY_FLOAT(dest
[0], a
);
358 COPY_FLOAT(dest
[1], b
);
359 COPY_FLOAT(dest
[2], c
);
364 void _mesa_noop_MultiTexCoord4fvARB( GLenum target
, GLfloat
*v
)
366 GET_CURRENT_CONTEXT(ctx
);
367 GLuint unit
= target
- GL_TEXTURE0_ARB
;
369 /* unit is unsigned -- cannot be less than zero.
371 if (unit
< MAX_TEXTURE_UNITS
)
373 GLfloat
*dest
= ctx
->Current
.Texcoord
[unit
];
374 COPY_FLOAT(dest
[0], v
[0]);
375 COPY_FLOAT(dest
[1], v
[1]);
376 COPY_FLOAT(dest
[2], v
[2]);
377 COPY_FLOAT(dest
[3], v
[3]);
381 void _mesa_noop_SecondaryColor3ubEXT( GLubyte a
, GLubyte b
, GLubyte c
)
383 GET_CURRENT_CONTEXT(ctx
);
384 GLchan
*color
= ctx
->Current
.SecondaryColor
;
385 color
[0] = UBYTE_TO_CHAN(a
);
386 color
[1] = UBYTE_TO_CHAN(b
);
387 color
[2] = UBYTE_TO_CHAN(c
);
391 void _mesa_noop_SecondaryColor3ubvEXT( const GLubyte
*v
)
393 GET_CURRENT_CONTEXT(ctx
);
394 GLchan
*color
= ctx
->Current
.SecondaryColor
;
395 color
[0] = UBYTE_TO_CHAN(v
[0]);
396 color
[1] = UBYTE_TO_CHAN(v
[1]);
397 color
[2] = UBYTE_TO_CHAN(v
[2]);
401 void _mesa_noop_SecondaryColor3fEXT( GLfloat a
, GLfloat b
, GLfloat c
)
403 GET_CURRENT_CONTEXT(ctx
);
404 GLchan
*color
= ctx
->Current
.SecondaryColor
;
405 UNCLAMPED_FLOAT_TO_CHAN(color
[0], a
);
406 UNCLAMPED_FLOAT_TO_CHAN(color
[1], b
);
407 UNCLAMPED_FLOAT_TO_CHAN(color
[2], c
);
411 void _mesa_noop_SecondaryColor3fvEXT( const GLfloat
*v
)
413 GET_CURRENT_CONTEXT(ctx
);
414 GLchan
*color
= ctx
->Current
.SecondaryColor
;
415 UNCLAMPED_FLOAT_TO_CHAN(color
[0], v
[0]);
416 UNCLAMPED_FLOAT_TO_CHAN(color
[1], v
[1]);
417 UNCLAMPED_FLOAT_TO_CHAN(color
[2], v
[2]);
421 void _mesa_noop_TexCoord1f( GLfloat a
)
423 GET_CURRENT_CONTEXT(ctx
);
424 GLfloat
*dest
= ctx
->Current
.Texcoord
[0];
425 COPY_FLOAT(dest
[0], a
);
431 void _mesa_noop_TexCoord1fv( GLfloat
*v
)
433 GET_CURRENT_CONTEXT(ctx
);
434 GLfloat
*dest
= ctx
->Current
.Texcoord
[0];
435 COPY_FLOAT(dest
[0], v
[0]);
441 void _mesa_noop_TexCoord2f( GLfloat a
, GLfloat b
)
443 GET_CURRENT_CONTEXT(ctx
);
444 GLfloat
*dest
= ctx
->Current
.Texcoord
[0];
445 COPY_FLOAT(dest
[0], a
);
446 COPY_FLOAT(dest
[1], b
);
451 void _mesa_noop_TexCoord2fv( GLfloat
*v
)
453 GET_CURRENT_CONTEXT(ctx
);
454 GLfloat
*dest
= ctx
->Current
.Texcoord
[0];
455 COPY_FLOAT(dest
[0], v
[0]);
456 COPY_FLOAT(dest
[1], v
[1]);
461 void _mesa_noop_TexCoord3f( GLfloat a
, GLfloat b
, GLfloat c
)
463 GET_CURRENT_CONTEXT(ctx
);
464 GLfloat
*dest
= ctx
->Current
.Texcoord
[0];
465 COPY_FLOAT(dest
[0], a
);
466 COPY_FLOAT(dest
[1], b
);
467 COPY_FLOAT(dest
[2], c
);
471 void _mesa_noop_TexCoord3fv( GLfloat
*v
)
473 GET_CURRENT_CONTEXT(ctx
);
474 GLfloat
*dest
= ctx
->Current
.Texcoord
[0];
475 COPY_FLOAT(dest
[0], v
[0]);
476 COPY_FLOAT(dest
[1], v
[1]);
477 COPY_FLOAT(dest
[2], v
[2]);
481 void _mesa_noop_TexCoord4f( GLfloat a
, GLfloat b
, GLfloat c
, GLfloat d
)
483 GET_CURRENT_CONTEXT(ctx
);
484 GLfloat
*dest
= ctx
->Current
.Texcoord
[0];
485 COPY_FLOAT(dest
[0], a
);
486 COPY_FLOAT(dest
[1], b
);
487 COPY_FLOAT(dest
[2], c
);
488 COPY_FLOAT(dest
[3], d
);
491 void _mesa_noop_TexCoord4fv( GLfloat
*v
)
493 GET_CURRENT_CONTEXT(ctx
);
494 GLfloat
*dest
= ctx
->Current
.Texcoord
[0];
495 COPY_FLOAT(dest
[0], v
[0]);
496 COPY_FLOAT(dest
[1], v
[1]);
497 COPY_FLOAT(dest
[2], v
[2]);
498 COPY_FLOAT(dest
[3], v
[3]);
501 /* Execute a glRectf() function. This is not suitable for GL_COMPILE
502 * modes (as the test for outside begin/end is not compiled),
503 * but may be useful for drivers in circumstances which exclude
504 * display list interactions.
506 * (None of the functions in this file are suitable for GL_COMPILE
509 void _mesa_noop_Rectf( GLfloat x1
, GLfloat y1
, GLfloat x2
, GLfloat y2
)
512 GET_CURRENT_CONTEXT(ctx
);
513 ASSERT_OUTSIDE_BEGIN_END(ctx
);
517 glVertex2f( x1
, y1
);
518 glVertex2f( x2
, y1
);
519 glVertex2f( x2
, y2
);
520 glVertex2f( x1
, y2
);
525 /* Some very basic support for arrays. Drivers without explicit array
526 * support can hook these in, but still need to supply an array-elt
529 void _mesa_noop_DrawArrays(GLenum mode
, GLint start
, GLsizei count
)
531 GET_CURRENT_CONTEXT(ctx
);
534 if (!_mesa_validate_DrawArrays( ctx
, mode
, start
, count
))
538 for (i
= start
; i
<= count
; i
++)
544 void _mesa_noop_DrawElements(GLenum mode
, GLsizei count
, GLenum type
,
545 const GLvoid
*indices
)
547 GET_CURRENT_CONTEXT(ctx
);
550 if (!_mesa_validate_DrawElements( ctx
, mode
, count
, type
, indices
))
556 case GL_UNSIGNED_BYTE
:
557 for (i
= 0 ; i
< count
; i
++)
558 glArrayElement( ((GLubyte
*)indices
)[i
] );
560 case GL_UNSIGNED_SHORT
:
561 for (i
= 0 ; i
< count
; i
++)
562 glArrayElement( ((GLushort
*)indices
)[i
] );
564 case GL_UNSIGNED_INT
:
565 for (i
= 0 ; i
< count
; i
++)
566 glArrayElement( ((GLuint
*)indices
)[i
] );
569 _mesa_error( ctx
, GL_INVALID_ENUM
, "glDrawElements(type)" );
576 void _mesa_noop_DrawRangeElements(GLenum mode
,
577 GLuint start
, GLuint end
,
578 GLsizei count
, GLenum type
,
579 const GLvoid
*indices
)
581 GET_CURRENT_CONTEXT(ctx
);
583 if (_mesa_validate_DrawRangeElements( ctx
, mode
,
585 count
, type
, indices
))
586 glDrawElements( mode
, count
, type
, indices
);