bab333dca8a1269f3aa53c2723383c7351b95055
3 * Mesa 3-D graphics library
6 * Copyright (C) 1999-2003 Brian Paul All Rights Reserved.
8 * Permission is hereby granted, free of charge, to any person obtaining a
9 * copy of this software and associated documentation files (the "Software"),
10 * to deal in the Software without restriction, including without limitation
11 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
12 * and/or sell copies of the Software, and to permit persons to whom the
13 * Software is furnished to do so, subject to the following conditions:
15 * The above copyright notice and this permission notice shall be included
16 * in all copies or substantial portions of the Software.
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
22 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 #include "api_validate.h"
37 /* In states where certain vertex components are required for t&l or
38 * rasterization, we still need to keep track of the current values.
39 * These functions provide this service by keeping uptodate the
40 * 'ctx->Current' struct for all data elements not included in the
41 * currently enabled hardware vertex.
44 void _mesa_noop_EdgeFlag( GLboolean b
)
46 GET_CURRENT_CONTEXT(ctx
);
47 ctx
->Current
.EdgeFlag
= b
;
50 void _mesa_noop_EdgeFlagv( const GLboolean
*b
)
52 GET_CURRENT_CONTEXT(ctx
);
53 ctx
->Current
.EdgeFlag
= *b
;
56 void _mesa_noop_FogCoordfEXT( GLfloat a
)
58 GET_CURRENT_CONTEXT(ctx
);
59 ctx
->Current
.Attrib
[VERT_ATTRIB_FOG
][0] = a
;
62 void _mesa_noop_FogCoordfvEXT( const GLfloat
*v
)
64 GET_CURRENT_CONTEXT(ctx
);
65 ctx
->Current
.Attrib
[VERT_ATTRIB_FOG
][0] = *v
;
68 void _mesa_noop_Indexi( GLint i
)
70 GET_CURRENT_CONTEXT(ctx
);
71 ctx
->Current
.Index
= i
;
74 void _mesa_noop_Indexiv( const GLint
*v
)
76 GET_CURRENT_CONTEXT(ctx
);
77 ctx
->Current
.Index
= *v
;
80 void _mesa_noop_Normal3f( GLfloat a
, GLfloat b
, GLfloat c
)
82 GET_CURRENT_CONTEXT(ctx
);
83 GLfloat
*dest
= ctx
->Current
.Attrib
[VERT_ATTRIB_NORMAL
];
84 COPY_FLOAT(dest
[0], a
);
85 COPY_FLOAT(dest
[1], b
);
86 COPY_FLOAT(dest
[2], c
);
89 void _mesa_noop_Normal3fv( const GLfloat
*v
)
91 GET_CURRENT_CONTEXT(ctx
);
92 GLfloat
*dest
= ctx
->Current
.Attrib
[VERT_ATTRIB_NORMAL
];
93 COPY_FLOAT(dest
[0], v
[0]);
94 COPY_FLOAT(dest
[1], v
[1]);
95 COPY_FLOAT(dest
[2], v
[2]);
98 void _mesa_noop_Materialfv( GLenum face
, GLenum pname
, const GLfloat
*params
)
100 GET_CURRENT_CONTEXT(ctx
);
102 struct gl_material
*mat
= &ctx
->Light
.Material
;
103 GLuint bitmask
= _mesa_material_bitmask( ctx
, face
, pname
, ~0,
104 "_mesa_noop_Materialfv" );
106 if (ctx
->Light
.ColorMaterialEnabled
)
107 bitmask
&= ~ctx
->Light
.ColorMaterialBitmask
;
113 case GL_SHININESS
: nr
= 1; break;
114 case GL_COLOR_INDEXES
: nr
= 3; break;
115 default: nr
= 4 ; break;
118 for (i
= 0 ; i
< MAT_ATTRIB_MAX
; i
++)
119 if (bitmask
& (1<<i
))
120 COPY_SZ_4V( mat
->Attrib
[i
], nr
, params
);
122 _mesa_update_material( ctx
, bitmask
);
125 void _mesa_noop_Color4ub( GLubyte a
, GLubyte b
, GLubyte c
, GLubyte d
)
127 GET_CURRENT_CONTEXT(ctx
);
128 GLfloat
*color
= ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR0
];
129 color
[0] = UBYTE_TO_FLOAT(a
);
130 color
[1] = UBYTE_TO_FLOAT(b
);
131 color
[2] = UBYTE_TO_FLOAT(c
);
132 color
[3] = UBYTE_TO_FLOAT(d
);
135 void _mesa_noop_Color4ubv( const GLubyte
*v
)
137 GET_CURRENT_CONTEXT(ctx
);
138 GLfloat
*color
= ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR0
];
139 color
[0] = UBYTE_TO_FLOAT(v
[0]);
140 color
[1] = UBYTE_TO_FLOAT(v
[1]);
141 color
[2] = UBYTE_TO_FLOAT(v
[2]);
142 color
[3] = UBYTE_TO_FLOAT(v
[3]);
145 void _mesa_noop_Color4f( GLfloat a
, GLfloat b
, GLfloat c
, GLfloat d
)
147 GET_CURRENT_CONTEXT(ctx
);
148 GLfloat
*color
= ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR0
];
155 void _mesa_noop_Color4fv( const GLfloat
*v
)
157 GET_CURRENT_CONTEXT(ctx
);
158 GLfloat
*color
= ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR0
];
165 void _mesa_noop_Color3ub( GLubyte a
, GLubyte b
, GLubyte c
)
167 GET_CURRENT_CONTEXT(ctx
);
168 GLfloat
*color
= ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR0
];
169 color
[0] = UBYTE_TO_FLOAT(a
);
170 color
[1] = UBYTE_TO_FLOAT(b
);
171 color
[2] = UBYTE_TO_FLOAT(c
);
175 void _mesa_noop_Color3ubv( const GLubyte
*v
)
177 GET_CURRENT_CONTEXT(ctx
);
178 GLfloat
*color
= ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR0
];
179 color
[0] = UBYTE_TO_FLOAT(v
[0]);
180 color
[1] = UBYTE_TO_FLOAT(v
[1]);
181 color
[2] = UBYTE_TO_FLOAT(v
[2]);
185 void _mesa_noop_Color3f( GLfloat a
, GLfloat b
, GLfloat c
)
187 GET_CURRENT_CONTEXT(ctx
);
188 GLfloat
*color
= ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR0
];
195 void _mesa_noop_Color3fv( const GLfloat
*v
)
197 GET_CURRENT_CONTEXT(ctx
);
198 GLfloat
*color
= ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR0
];
205 void _mesa_noop_MultiTexCoord1fARB( GLenum target
, GLfloat a
)
207 GET_CURRENT_CONTEXT(ctx
);
208 GLuint unit
= target
- GL_TEXTURE0_ARB
;
210 /* unit is unsigned -- cannot be less than zero.
212 if (unit
< MAX_TEXTURE_COORD_UNITS
)
214 GLfloat
*dest
= ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
+ unit
];
215 COPY_FLOAT(dest
[0], a
);
222 void _mesa_noop_MultiTexCoord1fvARB( GLenum target
, const GLfloat
*v
)
224 GET_CURRENT_CONTEXT(ctx
);
225 GLuint unit
= target
- GL_TEXTURE0_ARB
;
227 /* unit is unsigned -- cannot be less than zero.
229 if (unit
< MAX_TEXTURE_COORD_UNITS
)
231 GLfloat
*dest
= ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
+ unit
];
232 COPY_FLOAT(dest
[0], v
[0]);
239 void _mesa_noop_MultiTexCoord2fARB( GLenum target
, GLfloat a
, GLfloat b
)
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_COORD_UNITS
)
248 GLfloat
*dest
= ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
+ unit
];
249 COPY_FLOAT(dest
[0], a
);
250 COPY_FLOAT(dest
[1], b
);
256 void _mesa_noop_MultiTexCoord2fvARB( GLenum target
, const 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_COORD_UNITS
)
265 GLfloat
*dest
= ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
+ unit
];
266 COPY_FLOAT(dest
[0], v
[0]);
267 COPY_FLOAT(dest
[1], v
[1]);
273 void _mesa_noop_MultiTexCoord3fARB( GLenum target
, GLfloat a
, GLfloat b
, GLfloat c
)
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_COORD_UNITS
)
282 GLfloat
*dest
= ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
+ unit
];
283 COPY_FLOAT(dest
[0], a
);
284 COPY_FLOAT(dest
[1], b
);
285 COPY_FLOAT(dest
[2], c
);
290 void _mesa_noop_MultiTexCoord3fvARB( GLenum target
, const 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_COORD_UNITS
)
299 GLfloat
*dest
= ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
+ unit
];
300 COPY_FLOAT(dest
[0], v
[0]);
301 COPY_FLOAT(dest
[1], v
[1]);
302 COPY_FLOAT(dest
[2], v
[2]);
307 void _mesa_noop_MultiTexCoord4fARB( GLenum target
, GLfloat a
, GLfloat b
,
308 GLfloat c
, GLfloat d
)
310 GET_CURRENT_CONTEXT(ctx
);
311 GLuint unit
= target
- GL_TEXTURE0_ARB
;
313 /* unit is unsigned -- cannot be less than zero.
315 if (unit
< MAX_TEXTURE_COORD_UNITS
)
317 GLfloat
*dest
= ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
+ unit
];
318 COPY_FLOAT(dest
[0], a
);
319 COPY_FLOAT(dest
[1], b
);
320 COPY_FLOAT(dest
[2], c
);
325 void _mesa_noop_MultiTexCoord4fvARB( GLenum target
, const GLfloat
*v
)
327 GET_CURRENT_CONTEXT(ctx
);
328 GLuint unit
= target
- GL_TEXTURE0_ARB
;
330 /* unit is unsigned -- cannot be less than zero.
332 if (unit
< MAX_TEXTURE_COORD_UNITS
)
334 GLfloat
*dest
= ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
+ unit
];
335 COPY_FLOAT(dest
[0], v
[0]);
336 COPY_FLOAT(dest
[1], v
[1]);
337 COPY_FLOAT(dest
[2], v
[2]);
338 COPY_FLOAT(dest
[3], v
[3]);
342 void _mesa_noop_SecondaryColor3ubEXT( GLubyte a
, GLubyte b
, GLubyte c
)
344 GET_CURRENT_CONTEXT(ctx
);
345 GLfloat
*color
= ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR1
];
346 color
[0] = UBYTE_TO_FLOAT(a
);
347 color
[1] = UBYTE_TO_FLOAT(b
);
348 color
[2] = UBYTE_TO_FLOAT(c
);
352 void _mesa_noop_SecondaryColor3ubvEXT( const GLubyte
*v
)
354 GET_CURRENT_CONTEXT(ctx
);
355 GLfloat
*color
= ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR1
];
356 color
[0] = UBYTE_TO_FLOAT(v
[0]);
357 color
[1] = UBYTE_TO_FLOAT(v
[1]);
358 color
[2] = UBYTE_TO_FLOAT(v
[2]);
362 void _mesa_noop_SecondaryColor3fEXT( GLfloat a
, GLfloat b
, GLfloat c
)
364 GET_CURRENT_CONTEXT(ctx
);
365 GLfloat
*color
= ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR1
];
372 void _mesa_noop_SecondaryColor3fvEXT( const GLfloat
*v
)
374 GET_CURRENT_CONTEXT(ctx
);
375 GLfloat
*color
= ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR1
];
382 void _mesa_noop_TexCoord1f( GLfloat a
)
384 GET_CURRENT_CONTEXT(ctx
);
385 GLfloat
*dest
= ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
];
386 COPY_FLOAT(dest
[0], a
);
392 void _mesa_noop_TexCoord1fv( const GLfloat
*v
)
394 GET_CURRENT_CONTEXT(ctx
);
395 GLfloat
*dest
= ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
];
396 COPY_FLOAT(dest
[0], v
[0]);
402 void _mesa_noop_TexCoord2f( GLfloat a
, GLfloat b
)
404 GET_CURRENT_CONTEXT(ctx
);
405 GLfloat
*dest
= ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
];
406 COPY_FLOAT(dest
[0], a
);
407 COPY_FLOAT(dest
[1], b
);
412 void _mesa_noop_TexCoord2fv( const GLfloat
*v
)
414 GET_CURRENT_CONTEXT(ctx
);
415 GLfloat
*dest
= ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
];
416 COPY_FLOAT(dest
[0], v
[0]);
417 COPY_FLOAT(dest
[1], v
[1]);
422 void _mesa_noop_TexCoord3f( GLfloat a
, GLfloat b
, GLfloat c
)
424 GET_CURRENT_CONTEXT(ctx
);
425 GLfloat
*dest
= ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
];
426 COPY_FLOAT(dest
[0], a
);
427 COPY_FLOAT(dest
[1], b
);
428 COPY_FLOAT(dest
[2], c
);
432 void _mesa_noop_TexCoord3fv( const GLfloat
*v
)
434 GET_CURRENT_CONTEXT(ctx
);
435 GLfloat
*dest
= ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
];
436 COPY_FLOAT(dest
[0], v
[0]);
437 COPY_FLOAT(dest
[1], v
[1]);
438 COPY_FLOAT(dest
[2], v
[2]);
442 void _mesa_noop_TexCoord4f( GLfloat a
, GLfloat b
, GLfloat c
, GLfloat d
)
444 GET_CURRENT_CONTEXT(ctx
);
445 GLfloat
*dest
= ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
];
446 COPY_FLOAT(dest
[0], a
);
447 COPY_FLOAT(dest
[1], b
);
448 COPY_FLOAT(dest
[2], c
);
449 COPY_FLOAT(dest
[3], d
);
452 void _mesa_noop_TexCoord4fv( const GLfloat
*v
)
454 GET_CURRENT_CONTEXT(ctx
);
455 GLfloat
*dest
= ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
];
456 COPY_FLOAT(dest
[0], v
[0]);
457 COPY_FLOAT(dest
[1], v
[1]);
458 COPY_FLOAT(dest
[2], v
[2]);
459 COPY_FLOAT(dest
[3], v
[3]);
462 /* Useful outside begin/end?
464 void _mesa_noop_Vertex2fv( const GLfloat
*v
)
469 void _mesa_noop_Vertex3fv( const GLfloat
*v
)
474 void _mesa_noop_Vertex4fv( const GLfloat
*v
)
479 void _mesa_noop_Vertex2f( GLfloat a
, GLfloat b
)
484 void _mesa_noop_Vertex3f( GLfloat a
, GLfloat b
, GLfloat c
)
486 (void) a
; (void) b
; (void) c
;
489 void _mesa_noop_Vertex4f( GLfloat a
, GLfloat b
, GLfloat c
, GLfloat d
)
491 (void) a
; (void) b
; (void) c
; (void) d
;
496 void _mesa_noop_VertexAttrib4fNV( GLuint index
, GLfloat x
,
497 GLfloat y
, GLfloat z
, GLfloat w
)
499 GET_CURRENT_CONTEXT(ctx
);
501 ASSIGN_4V(ctx
->Current
.Attrib
[index
], x
, y
, z
, w
);
505 void _mesa_noop_VertexAttrib4fvNV( GLuint index
, const GLfloat
*v
)
507 GET_CURRENT_CONTEXT(ctx
);
509 ASSIGN_4V(ctx
->Current
.Attrib
[index
], v
[0], v
[1], v
[2], v
[3]);
515 /* Execute a glRectf() function. This is not suitable for GL_COMPILE
516 * modes (as the test for outside begin/end is not compiled),
517 * but may be useful for drivers in circumstances which exclude
518 * display list interactions.
520 * (None of the functions in this file are suitable for GL_COMPILE
523 void _mesa_noop_Rectf( GLfloat x1
, GLfloat y1
, GLfloat x2
, GLfloat y2
)
526 GET_CURRENT_CONTEXT(ctx
);
527 ASSERT_OUTSIDE_BEGIN_END(ctx
);
531 glVertex2f( x1
, y1
);
532 glVertex2f( x2
, y1
);
533 glVertex2f( x2
, y2
);
534 glVertex2f( x1
, y2
);
539 /* Some very basic support for arrays. Drivers without explicit array
540 * support can hook these in, but still need to supply an array-elt
543 void _mesa_noop_DrawArrays(GLenum mode
, GLint start
, GLsizei count
)
545 GET_CURRENT_CONTEXT(ctx
);
548 if (!_mesa_validate_DrawArrays( ctx
, mode
, start
, count
))
552 for (i
= start
; i
<= count
; i
++)
558 void _mesa_noop_DrawElements(GLenum mode
, GLsizei count
, GLenum type
,
559 const GLvoid
*indices
)
561 GET_CURRENT_CONTEXT(ctx
);
564 if (!_mesa_validate_DrawElements( ctx
, mode
, count
, type
, indices
))
570 case GL_UNSIGNED_BYTE
:
571 for (i
= 0 ; i
< count
; i
++)
572 glArrayElement( ((GLubyte
*)indices
)[i
] );
574 case GL_UNSIGNED_SHORT
:
575 for (i
= 0 ; i
< count
; i
++)
576 glArrayElement( ((GLushort
*)indices
)[i
] );
578 case GL_UNSIGNED_INT
:
579 for (i
= 0 ; i
< count
; i
++)
580 glArrayElement( ((GLuint
*)indices
)[i
] );
583 _mesa_error( ctx
, GL_INVALID_ENUM
, "glDrawElements(type)" );
590 void _mesa_noop_DrawRangeElements(GLenum mode
,
591 GLuint start
, GLuint end
,
592 GLsizei count
, GLenum type
,
593 const GLvoid
*indices
)
595 GET_CURRENT_CONTEXT(ctx
);
597 if (_mesa_validate_DrawRangeElements( ctx
, mode
,
599 count
, type
, indices
))
600 glDrawElements( mode
, count
, type
, indices
);