1 /* $Id: api_noop.c,v 1.9 2001/12/14 02:50:01 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 /* 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
, 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
, 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
, 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
, 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( 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( 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( 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( 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 void _mesa_noop_VertexAttrib4fNV( GLuint index
, GLfloat x
,
493 GLfloat y
, GLfloat z
, GLfloat w
)
495 GET_CURRENT_CONTEXT(ctx
);
497 ASSIGN_4V(ctx
->Current
.Attrib
[index
], x
, y
, z
, w
);
501 void _mesa_noop_VertexAttrib4fvNV( GLuint index
, const GLfloat
*v
)
503 GET_CURRENT_CONTEXT(ctx
);
505 ASSIGN_4V(ctx
->Current
.Attrib
[index
], v
[0], v
[1], v
[2], v
[3]);
511 /* Execute a glRectf() function. This is not suitable for GL_COMPILE
512 * modes (as the test for outside begin/end is not compiled),
513 * but may be useful for drivers in circumstances which exclude
514 * display list interactions.
516 * (None of the functions in this file are suitable for GL_COMPILE
519 void _mesa_noop_Rectf( GLfloat x1
, GLfloat y1
, GLfloat x2
, GLfloat y2
)
522 GET_CURRENT_CONTEXT(ctx
);
523 ASSERT_OUTSIDE_BEGIN_END(ctx
);
527 glVertex2f( x1
, y1
);
528 glVertex2f( x2
, y1
);
529 glVertex2f( x2
, y2
);
530 glVertex2f( x1
, y2
);
535 /* Some very basic support for arrays. Drivers without explicit array
536 * support can hook these in, but still need to supply an array-elt
539 void _mesa_noop_DrawArrays(GLenum mode
, GLint start
, GLsizei count
)
541 GET_CURRENT_CONTEXT(ctx
);
544 if (!_mesa_validate_DrawArrays( ctx
, mode
, start
, count
))
548 for (i
= start
; i
<= count
; i
++)
554 void _mesa_noop_DrawElements(GLenum mode
, GLsizei count
, GLenum type
,
555 const GLvoid
*indices
)
557 GET_CURRENT_CONTEXT(ctx
);
560 if (!_mesa_validate_DrawElements( ctx
, mode
, count
, type
, indices
))
566 case GL_UNSIGNED_BYTE
:
567 for (i
= 0 ; i
< count
; i
++)
568 glArrayElement( ((GLubyte
*)indices
)[i
] );
570 case GL_UNSIGNED_SHORT
:
571 for (i
= 0 ; i
< count
; i
++)
572 glArrayElement( ((GLushort
*)indices
)[i
] );
574 case GL_UNSIGNED_INT
:
575 for (i
= 0 ; i
< count
; i
++)
576 glArrayElement( ((GLuint
*)indices
)[i
] );
579 _mesa_error( ctx
, GL_INVALID_ENUM
, "glDrawElements(type)" );
586 void _mesa_noop_DrawRangeElements(GLenum mode
,
587 GLuint start
, GLuint end
,
588 GLsizei count
, GLenum type
,
589 const GLvoid
*indices
)
591 GET_CURRENT_CONTEXT(ctx
);
593 if (_mesa_validate_DrawRangeElements( ctx
, mode
,
595 count
, type
, indices
))
596 glDrawElements( mode
, count
, type
, indices
);