f15e3b61423dd3c547e57c9447fb2ff242f9eccc
1 /* $Id: api_noop.c,v 1.13 2003/05/30 21:37:14 idr Exp $ */
4 * Mesa 3-D graphics library
7 * Copyright (C) 1999-2003 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"
38 /* In states where certain vertex components are required for t&l or
39 * rasterization, we still need to keep track of the current values.
40 * These functions provide this service by keeping uptodate the
41 * 'ctx->Current' struct for all data elements not included in the
42 * currently enabled hardware vertex.
45 void _mesa_noop_EdgeFlag( GLboolean b
)
47 GET_CURRENT_CONTEXT(ctx
);
48 ctx
->Current
.EdgeFlag
= b
;
51 void _mesa_noop_EdgeFlagv( const GLboolean
*b
)
53 GET_CURRENT_CONTEXT(ctx
);
54 ctx
->Current
.EdgeFlag
= *b
;
57 void _mesa_noop_FogCoordfEXT( GLfloat a
)
59 GET_CURRENT_CONTEXT(ctx
);
60 ctx
->Current
.Attrib
[VERT_ATTRIB_FOG
][0] = a
;
63 void _mesa_noop_FogCoordfvEXT( const GLfloat
*v
)
65 GET_CURRENT_CONTEXT(ctx
);
66 ctx
->Current
.Attrib
[VERT_ATTRIB_FOG
][0] = *v
;
69 void _mesa_noop_Indexi( GLint i
)
71 GET_CURRENT_CONTEXT(ctx
);
72 ctx
->Current
.Index
= i
;
75 void _mesa_noop_Indexiv( const GLint
*v
)
77 GET_CURRENT_CONTEXT(ctx
);
78 ctx
->Current
.Index
= *v
;
81 void _mesa_noop_Normal3f( GLfloat a
, GLfloat b
, GLfloat c
)
83 GET_CURRENT_CONTEXT(ctx
);
84 GLfloat
*dest
= ctx
->Current
.Attrib
[VERT_ATTRIB_NORMAL
];
85 COPY_FLOAT(dest
[0], a
);
86 COPY_FLOAT(dest
[1], b
);
87 COPY_FLOAT(dest
[2], c
);
90 void _mesa_noop_Normal3fv( const GLfloat
*v
)
92 GET_CURRENT_CONTEXT(ctx
);
93 GLfloat
*dest
= ctx
->Current
.Attrib
[VERT_ATTRIB_NORMAL
];
94 COPY_FLOAT(dest
[0], v
[0]);
95 COPY_FLOAT(dest
[1], v
[1]);
96 COPY_FLOAT(dest
[2], v
[2]);
99 void _mesa_noop_Materialfv( GLenum face
, GLenum pname
, const GLfloat
*params
)
101 GET_CURRENT_CONTEXT(ctx
);
102 struct gl_material mat
[2];
103 GLuint bitmask
= _mesa_material_bitmask( ctx
, face
, pname
, ~0,
104 "_mesa_noop_Materialfv" );
108 if (bitmask
& FRONT_AMBIENT_BIT
) {
109 COPY_4FV( mat
[0].Ambient
, params
);
111 if (bitmask
& BACK_AMBIENT_BIT
) {
112 COPY_4FV( mat
[1].Ambient
, params
);
114 if (bitmask
& FRONT_DIFFUSE_BIT
) {
115 COPY_4FV( mat
[0].Diffuse
, params
);
117 if (bitmask
& BACK_DIFFUSE_BIT
) {
118 COPY_4FV( mat
[1].Diffuse
, params
);
120 if (bitmask
& FRONT_SPECULAR_BIT
) {
121 COPY_4FV( mat
[0].Specular
, params
);
123 if (bitmask
& BACK_SPECULAR_BIT
) {
124 COPY_4FV( mat
[1].Specular
, params
);
126 if (bitmask
& FRONT_EMISSION_BIT
) {
127 COPY_4FV( mat
[0].Emission
, params
);
129 if (bitmask
& BACK_EMISSION_BIT
) {
130 COPY_4FV( mat
[1].Emission
, params
);
132 if (bitmask
& FRONT_SHININESS_BIT
) {
133 GLfloat shininess
= CLAMP( params
[0], 0.0F
, ctx
->Const
.MaxShininess
);
134 mat
[0].Shininess
= shininess
;
136 if (bitmask
& BACK_SHININESS_BIT
) {
137 GLfloat shininess
= CLAMP( params
[0], 0.0F
, ctx
->Const
.MaxShininess
);
138 mat
[1].Shininess
= shininess
;
140 if (bitmask
& FRONT_INDEXES_BIT
) {
141 mat
[0].AmbientIndex
= params
[0];
142 mat
[0].DiffuseIndex
= params
[1];
143 mat
[0].SpecularIndex
= params
[2];
145 if (bitmask
& BACK_INDEXES_BIT
) {
146 mat
[1].AmbientIndex
= params
[0];
147 mat
[1].DiffuseIndex
= params
[1];
148 mat
[1].SpecularIndex
= params
[2];
151 _mesa_update_material( ctx
, mat
, bitmask
);
154 void _mesa_noop_Color4ub( GLubyte a
, GLubyte b
, GLubyte c
, GLubyte d
)
156 GET_CURRENT_CONTEXT(ctx
);
157 GLfloat
*color
= ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR0
];
158 color
[0] = UBYTE_TO_FLOAT(a
);
159 color
[1] = UBYTE_TO_FLOAT(b
);
160 color
[2] = UBYTE_TO_FLOAT(c
);
161 color
[3] = UBYTE_TO_FLOAT(d
);
164 void _mesa_noop_Color4ubv( const GLubyte
*v
)
166 GET_CURRENT_CONTEXT(ctx
);
167 GLfloat
*color
= ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR0
];
168 color
[0] = UBYTE_TO_FLOAT(v
[0]);
169 color
[1] = UBYTE_TO_FLOAT(v
[1]);
170 color
[2] = UBYTE_TO_FLOAT(v
[2]);
171 color
[3] = UBYTE_TO_FLOAT(v
[3]);
174 void _mesa_noop_Color4f( GLfloat a
, GLfloat b
, GLfloat c
, GLfloat d
)
176 GET_CURRENT_CONTEXT(ctx
);
177 GLfloat
*color
= ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR0
];
184 void _mesa_noop_Color4fv( const GLfloat
*v
)
186 GET_CURRENT_CONTEXT(ctx
);
187 GLfloat
*color
= ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR0
];
194 void _mesa_noop_Color3ub( GLubyte a
, GLubyte b
, GLubyte c
)
196 GET_CURRENT_CONTEXT(ctx
);
197 GLfloat
*color
= ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR0
];
198 color
[0] = UBYTE_TO_FLOAT(a
);
199 color
[1] = UBYTE_TO_FLOAT(b
);
200 color
[2] = UBYTE_TO_FLOAT(c
);
204 void _mesa_noop_Color3ubv( const GLubyte
*v
)
206 GET_CURRENT_CONTEXT(ctx
);
207 GLfloat
*color
= ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR0
];
208 color
[0] = UBYTE_TO_FLOAT(v
[0]);
209 color
[1] = UBYTE_TO_FLOAT(v
[1]);
210 color
[2] = UBYTE_TO_FLOAT(v
[2]);
214 void _mesa_noop_Color3f( GLfloat a
, GLfloat b
, GLfloat c
)
216 GET_CURRENT_CONTEXT(ctx
);
217 GLfloat
*color
= ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR0
];
224 void _mesa_noop_Color3fv( const GLfloat
*v
)
226 GET_CURRENT_CONTEXT(ctx
);
227 GLfloat
*color
= ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR0
];
234 void _mesa_noop_MultiTexCoord1fARB( GLenum target
, GLfloat a
)
236 GET_CURRENT_CONTEXT(ctx
);
237 GLuint unit
= target
- GL_TEXTURE0_ARB
;
239 /* unit is unsigned -- cannot be less than zero.
241 if (unit
< MAX_TEXTURE_COORD_UNITS
)
243 GLfloat
*dest
= ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
+ unit
];
244 COPY_FLOAT(dest
[0], a
);
251 void _mesa_noop_MultiTexCoord1fvARB( GLenum target
, const GLfloat
*v
)
253 GET_CURRENT_CONTEXT(ctx
);
254 GLuint unit
= target
- GL_TEXTURE0_ARB
;
256 /* unit is unsigned -- cannot be less than zero.
258 if (unit
< MAX_TEXTURE_COORD_UNITS
)
260 GLfloat
*dest
= ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
+ unit
];
261 COPY_FLOAT(dest
[0], v
[0]);
268 void _mesa_noop_MultiTexCoord2fARB( GLenum target
, GLfloat a
, GLfloat b
)
270 GET_CURRENT_CONTEXT(ctx
);
271 GLuint unit
= target
- GL_TEXTURE0_ARB
;
273 /* unit is unsigned -- cannot be less than zero.
275 if (unit
< MAX_TEXTURE_COORD_UNITS
)
277 GLfloat
*dest
= ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
+ unit
];
278 COPY_FLOAT(dest
[0], a
);
279 COPY_FLOAT(dest
[1], b
);
285 void _mesa_noop_MultiTexCoord2fvARB( GLenum target
, const GLfloat
*v
)
287 GET_CURRENT_CONTEXT(ctx
);
288 GLuint unit
= target
- GL_TEXTURE0_ARB
;
290 /* unit is unsigned -- cannot be less than zero.
292 if (unit
< MAX_TEXTURE_COORD_UNITS
)
294 GLfloat
*dest
= ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
+ unit
];
295 COPY_FLOAT(dest
[0], v
[0]);
296 COPY_FLOAT(dest
[1], v
[1]);
302 void _mesa_noop_MultiTexCoord3fARB( GLenum target
, GLfloat a
, GLfloat b
, GLfloat c
)
304 GET_CURRENT_CONTEXT(ctx
);
305 GLuint unit
= target
- GL_TEXTURE0_ARB
;
307 /* unit is unsigned -- cannot be less than zero.
309 if (unit
< MAX_TEXTURE_COORD_UNITS
)
311 GLfloat
*dest
= ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
+ unit
];
312 COPY_FLOAT(dest
[0], a
);
313 COPY_FLOAT(dest
[1], b
);
314 COPY_FLOAT(dest
[2], c
);
319 void _mesa_noop_MultiTexCoord3fvARB( GLenum target
, const GLfloat
*v
)
321 GET_CURRENT_CONTEXT(ctx
);
322 GLuint unit
= target
- GL_TEXTURE0_ARB
;
324 /* unit is unsigned -- cannot be less than zero.
326 if (unit
< MAX_TEXTURE_COORD_UNITS
)
328 GLfloat
*dest
= ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
+ unit
];
329 COPY_FLOAT(dest
[0], v
[0]);
330 COPY_FLOAT(dest
[1], v
[1]);
331 COPY_FLOAT(dest
[2], v
[2]);
336 void _mesa_noop_MultiTexCoord4fARB( GLenum target
, GLfloat a
, GLfloat b
,
337 GLfloat c
, GLfloat d
)
339 GET_CURRENT_CONTEXT(ctx
);
340 GLuint unit
= target
- GL_TEXTURE0_ARB
;
342 /* unit is unsigned -- cannot be less than zero.
344 if (unit
< MAX_TEXTURE_COORD_UNITS
)
346 GLfloat
*dest
= ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
+ unit
];
347 COPY_FLOAT(dest
[0], a
);
348 COPY_FLOAT(dest
[1], b
);
349 COPY_FLOAT(dest
[2], c
);
354 void _mesa_noop_MultiTexCoord4fvARB( GLenum target
, const GLfloat
*v
)
356 GET_CURRENT_CONTEXT(ctx
);
357 GLuint unit
= target
- GL_TEXTURE0_ARB
;
359 /* unit is unsigned -- cannot be less than zero.
361 if (unit
< MAX_TEXTURE_COORD_UNITS
)
363 GLfloat
*dest
= ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
+ unit
];
364 COPY_FLOAT(dest
[0], v
[0]);
365 COPY_FLOAT(dest
[1], v
[1]);
366 COPY_FLOAT(dest
[2], v
[2]);
367 COPY_FLOAT(dest
[3], v
[3]);
371 void _mesa_noop_SecondaryColor3ubEXT( GLubyte a
, GLubyte b
, GLubyte c
)
373 GET_CURRENT_CONTEXT(ctx
);
374 GLfloat
*color
= ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR1
];
375 color
[0] = UBYTE_TO_FLOAT(a
);
376 color
[1] = UBYTE_TO_FLOAT(b
);
377 color
[2] = UBYTE_TO_FLOAT(c
);
381 void _mesa_noop_SecondaryColor3ubvEXT( const GLubyte
*v
)
383 GET_CURRENT_CONTEXT(ctx
);
384 GLfloat
*color
= ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR1
];
385 color
[0] = UBYTE_TO_FLOAT(v
[0]);
386 color
[1] = UBYTE_TO_FLOAT(v
[1]);
387 color
[2] = UBYTE_TO_FLOAT(v
[2]);
391 void _mesa_noop_SecondaryColor3fEXT( GLfloat a
, GLfloat b
, GLfloat c
)
393 GET_CURRENT_CONTEXT(ctx
);
394 GLfloat
*color
= ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR1
];
401 void _mesa_noop_SecondaryColor3fvEXT( const GLfloat
*v
)
403 GET_CURRENT_CONTEXT(ctx
);
404 GLfloat
*color
= ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR1
];
411 void _mesa_noop_TexCoord1f( GLfloat a
)
413 GET_CURRENT_CONTEXT(ctx
);
414 GLfloat
*dest
= ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
];
415 COPY_FLOAT(dest
[0], a
);
421 void _mesa_noop_TexCoord1fv( const GLfloat
*v
)
423 GET_CURRENT_CONTEXT(ctx
);
424 GLfloat
*dest
= ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
];
425 COPY_FLOAT(dest
[0], v
[0]);
431 void _mesa_noop_TexCoord2f( GLfloat a
, GLfloat b
)
433 GET_CURRENT_CONTEXT(ctx
);
434 GLfloat
*dest
= ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
];
435 COPY_FLOAT(dest
[0], a
);
436 COPY_FLOAT(dest
[1], b
);
441 void _mesa_noop_TexCoord2fv( const GLfloat
*v
)
443 GET_CURRENT_CONTEXT(ctx
);
444 GLfloat
*dest
= ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
];
445 COPY_FLOAT(dest
[0], v
[0]);
446 COPY_FLOAT(dest
[1], v
[1]);
451 void _mesa_noop_TexCoord3f( GLfloat a
, GLfloat b
, GLfloat c
)
453 GET_CURRENT_CONTEXT(ctx
);
454 GLfloat
*dest
= ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
];
455 COPY_FLOAT(dest
[0], a
);
456 COPY_FLOAT(dest
[1], b
);
457 COPY_FLOAT(dest
[2], c
);
461 void _mesa_noop_TexCoord3fv( const GLfloat
*v
)
463 GET_CURRENT_CONTEXT(ctx
);
464 GLfloat
*dest
= ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
];
465 COPY_FLOAT(dest
[0], v
[0]);
466 COPY_FLOAT(dest
[1], v
[1]);
467 COPY_FLOAT(dest
[2], v
[2]);
471 void _mesa_noop_TexCoord4f( GLfloat a
, GLfloat b
, GLfloat c
, GLfloat d
)
473 GET_CURRENT_CONTEXT(ctx
);
474 GLfloat
*dest
= ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
];
475 COPY_FLOAT(dest
[0], a
);
476 COPY_FLOAT(dest
[1], b
);
477 COPY_FLOAT(dest
[2], c
);
478 COPY_FLOAT(dest
[3], d
);
481 void _mesa_noop_TexCoord4fv( const GLfloat
*v
)
483 GET_CURRENT_CONTEXT(ctx
);
484 GLfloat
*dest
= ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
];
485 COPY_FLOAT(dest
[0], v
[0]);
486 COPY_FLOAT(dest
[1], v
[1]);
487 COPY_FLOAT(dest
[2], v
[2]);
488 COPY_FLOAT(dest
[3], v
[3]);
491 /* Useful outside begin/end?
493 void _mesa_noop_Vertex2fv( const GLfloat
*v
)
498 void _mesa_noop_Vertex3fv( const GLfloat
*v
)
503 void _mesa_noop_Vertex4fv( const GLfloat
*v
)
508 void _mesa_noop_Vertex2f( GLfloat a
, GLfloat b
)
513 void _mesa_noop_Vertex3f( GLfloat a
, GLfloat b
, GLfloat c
)
515 (void) a
; (void) b
; (void) c
;
518 void _mesa_noop_Vertex4f( GLfloat a
, GLfloat b
, GLfloat c
, GLfloat d
)
520 (void) a
; (void) b
; (void) c
; (void) d
;
525 void _mesa_noop_VertexAttrib4fNV( GLuint index
, GLfloat x
,
526 GLfloat y
, GLfloat z
, GLfloat w
)
528 GET_CURRENT_CONTEXT(ctx
);
530 ASSIGN_4V(ctx
->Current
.Attrib
[index
], x
, y
, z
, w
);
534 void _mesa_noop_VertexAttrib4fvNV( GLuint index
, const GLfloat
*v
)
536 GET_CURRENT_CONTEXT(ctx
);
538 ASSIGN_4V(ctx
->Current
.Attrib
[index
], v
[0], v
[1], v
[2], v
[3]);
544 /* Execute a glRectf() function. This is not suitable for GL_COMPILE
545 * modes (as the test for outside begin/end is not compiled),
546 * but may be useful for drivers in circumstances which exclude
547 * display list interactions.
549 * (None of the functions in this file are suitable for GL_COMPILE
552 void _mesa_noop_Rectf( GLfloat x1
, GLfloat y1
, GLfloat x2
, GLfloat y2
)
555 GET_CURRENT_CONTEXT(ctx
);
556 ASSERT_OUTSIDE_BEGIN_END(ctx
);
560 glVertex2f( x1
, y1
);
561 glVertex2f( x2
, y1
);
562 glVertex2f( x2
, y2
);
563 glVertex2f( x1
, y2
);
568 /* Some very basic support for arrays. Drivers without explicit array
569 * support can hook these in, but still need to supply an array-elt
572 void _mesa_noop_DrawArrays(GLenum mode
, GLint start
, GLsizei count
)
574 GET_CURRENT_CONTEXT(ctx
);
577 if (!_mesa_validate_DrawArrays( ctx
, mode
, start
, count
))
581 for (i
= start
; i
<= count
; i
++)
587 void _mesa_noop_DrawElements(GLenum mode
, GLsizei count
, GLenum type
,
588 const GLvoid
*indices
)
590 GET_CURRENT_CONTEXT(ctx
);
593 if (!_mesa_validate_DrawElements( ctx
, mode
, count
, type
, indices
))
599 case GL_UNSIGNED_BYTE
:
600 for (i
= 0 ; i
< count
; i
++)
601 glArrayElement( ((GLubyte
*)indices
)[i
] );
603 case GL_UNSIGNED_SHORT
:
604 for (i
= 0 ; i
< count
; i
++)
605 glArrayElement( ((GLushort
*)indices
)[i
] );
607 case GL_UNSIGNED_INT
:
608 for (i
= 0 ; i
< count
; i
++)
609 glArrayElement( ((GLuint
*)indices
)[i
] );
612 _mesa_error( ctx
, GL_INVALID_ENUM
, "glDrawElements(type)" );
619 void _mesa_noop_DrawRangeElements(GLenum mode
,
620 GLuint start
, GLuint end
,
621 GLsizei count
, GLenum type
,
622 const GLvoid
*indices
)
624 GET_CURRENT_CONTEXT(ctx
);
626 if (_mesa_validate_DrawRangeElements( ctx
, mode
,
628 count
, type
, indices
))
629 glDrawElements( mode
, count
, type
, indices
);