Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1901 | serge | 1 | |
2 | * Mesa 3-D graphics library |
||
3 | * Version: 3.5 |
||
4 | * |
||
5 | * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. |
||
6 | * |
||
7 | * Permission is hereby granted, free of charge, to any person obtaining a |
||
8 | * copy of this software and associated documentation files (the "Software"), |
||
9 | * to deal in the Software without restriction, including without limitation |
||
10 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
||
11 | * and/or sell copies of the Software, and to permit persons to whom the |
||
12 | * Software is furnished to do so, subject to the following conditions: |
||
13 | * |
||
14 | * The above copyright notice and this permission notice shall be included |
||
15 | * in all copies or substantial portions of the Software. |
||
16 | * |
||
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
||
18 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||
19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
||
20 | * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN |
||
21 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
||
22 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
||
23 | * |
||
24 | * Authors: |
||
25 | * Gareth Hughes |
||
26 | */ |
||
27 | |||
28 | |||
29 | * |
||
30 | * FIXME: Floating-point color versions of these... |
||
31 | */ |
||
32 | |||
33 | |||
34 | |||
35 | { |
||
36 | GET_CURRENT; |
||
37 | #ifdef COLOR_IS_FLOAT |
||
38 | CURRENT_COLOR( RCOMP ) = CLAMP(r, 0.0f, 1.0f); |
||
39 | CURRENT_COLOR( GCOMP ) = CLAMP(g, 0.0f, 1.0f); |
||
40 | CURRENT_COLOR( BCOMP ) = CLAMP(b, 0.0f, 1.0f); |
||
41 | CURRENT_COLOR( ACOMP ) = 1.0f; |
||
42 | #else |
||
43 | UNCLAMPED_FLOAT_TO_UBYTE( CURRENT_COLOR( RCOMP ), r ); |
||
44 | UNCLAMPED_FLOAT_TO_UBYTE( CURRENT_COLOR( GCOMP ), g ); |
||
45 | UNCLAMPED_FLOAT_TO_UBYTE( CURRENT_COLOR( BCOMP ), b ); |
||
46 | CURRENT_COLOR( ACOMP ) = 255; |
||
47 | #endif |
||
48 | } |
||
49 | |||
50 | |||
51 | { |
||
52 | GET_CURRENT; |
||
53 | #ifdef COLOR_IS_FLOAT |
||
54 | CURRENT_COLOR( RCOMP ) = CLAMP(v[0], 0.0f, 1.0f); |
||
55 | CURRENT_COLOR( GCOMP ) = CLAMP(v[1], 0.0f, 1.0f); |
||
56 | CURRENT_COLOR( BCOMP ) = CLAMP(v[2], 0.0f, 1.0f); |
||
57 | CURRENT_COLOR( ACOMP ) = 1.0f; |
||
58 | #else |
||
59 | UNCLAMPED_FLOAT_TO_UBYTE( CURRENT_COLOR( RCOMP ), v[0] ); |
||
60 | UNCLAMPED_FLOAT_TO_UBYTE( CURRENT_COLOR( GCOMP ), v[1] ); |
||
61 | UNCLAMPED_FLOAT_TO_UBYTE( CURRENT_COLOR( BCOMP ), v[2] ); |
||
62 | CURRENT_COLOR( ACOMP ) = 255; |
||
63 | #endif |
||
64 | } |
||
65 | |||
66 | |||
67 | { |
||
68 | GET_CURRENT; |
||
69 | #ifdef COLOR_IS_FLOAT |
||
70 | CURRENT_COLOR( RCOMP ) = UBYTE_TO_FLOAT( r ); |
||
71 | CURRENT_COLOR( GCOMP ) = UBYTE_TO_FLOAT( g ); |
||
72 | CURRENT_COLOR( BCOMP ) = UBYTE_TO_FLOAT( b ); |
||
73 | CURRENT_COLOR( ACOMP ) = 1.0f; |
||
74 | #else |
||
75 | CURRENT_COLOR( RCOMP ) = r; |
||
76 | CURRENT_COLOR( GCOMP ) = g; |
||
77 | CURRENT_COLOR( BCOMP ) = b; |
||
78 | CURRENT_COLOR( ACOMP ) = 255; |
||
79 | #endif |
||
80 | } |
||
81 | |||
82 | |||
83 | { |
||
84 | GET_CURRENT; |
||
85 | #ifdef COLOR_IS_FLOAT |
||
86 | CURRENT_COLOR( RCOMP ) = UBYTE_TO_FLOAT( v[0] ); |
||
87 | CURRENT_COLOR( GCOMP ) = UBYTE_TO_FLOAT( v[1] ); |
||
88 | CURRENT_COLOR( BCOMP ) = UBYTE_TO_FLOAT( v[2] ); |
||
89 | CURRENT_COLOR( ACOMP ) = 1.0f; |
||
90 | #else |
||
91 | CURRENT_COLOR( RCOMP ) = v[0]; |
||
92 | CURRENT_COLOR( GCOMP ) = v[1]; |
||
93 | CURRENT_COLOR( BCOMP ) = v[2]; |
||
94 | CURRENT_COLOR( ACOMP ) = 255; |
||
95 | #endif |
||
96 | } |
||
97 | |||
98 | |||
99 | { |
||
100 | GET_CURRENT; |
||
101 | #ifdef COLOR_IS_FLOAT |
||
102 | CURRENT_COLOR( RCOMP ) = CLAMP(r, 0.0f, 1.0f); |
||
103 | CURRENT_COLOR( GCOMP ) = CLAMP(g, 0.0f, 1.0f); |
||
104 | CURRENT_COLOR( BCOMP ) = CLAMP(b, 0.0f, 1.0f); |
||
105 | CURRENT_COLOR( ACOMP ) = CLAMP(a, 0.0f, 1.0f); |
||
106 | #else |
||
107 | UNCLAMPED_FLOAT_TO_UBYTE( CURRENT_COLOR( RCOMP ), r ); |
||
108 | UNCLAMPED_FLOAT_TO_UBYTE( CURRENT_COLOR( GCOMP ), g ); |
||
109 | UNCLAMPED_FLOAT_TO_UBYTE( CURRENT_COLOR( BCOMP ), b ); |
||
110 | UNCLAMPED_FLOAT_TO_UBYTE( CURRENT_COLOR( ACOMP ), a ); |
||
111 | #endif |
||
112 | } |
||
113 | |||
114 | |||
115 | { |
||
116 | GET_CURRENT; |
||
117 | #ifdef COLOR_IS_FLOAT |
||
118 | CURRENT_COLOR( RCOMP ) = CLAMP(v[0], 0.0f, 1.0f); |
||
119 | CURRENT_COLOR( GCOMP ) = CLAMP(v[1], 0.0f, 1.0f); |
||
120 | CURRENT_COLOR( BCOMP ) = CLAMP(v[2], 0.0f, 1.0f); |
||
121 | CURRENT_COLOR( ACOMP ) = CLAMP(v[3], 0.0f, 1.0f); |
||
122 | #else |
||
123 | UNCLAMPED_FLOAT_TO_UBYTE( CURRENT_COLOR( RCOMP ), v[0] ); |
||
124 | UNCLAMPED_FLOAT_TO_UBYTE( CURRENT_COLOR( GCOMP ), v[1] ); |
||
125 | UNCLAMPED_FLOAT_TO_UBYTE( CURRENT_COLOR( BCOMP ), v[2] ); |
||
126 | UNCLAMPED_FLOAT_TO_UBYTE( CURRENT_COLOR( ACOMP ), v[3] ); |
||
127 | #endif |
||
128 | } |
||
129 | |||
130 | |||
131 | { |
||
132 | GET_CURRENT; |
||
133 | #ifdef COLOR_IS_FLOAT |
||
134 | CURRENT_COLOR( RCOMP ) = UBYTE_TO_FLOAT( r ); |
||
135 | CURRENT_COLOR( GCOMP ) = UBYTE_TO_FLOAT( g ); |
||
136 | CURRENT_COLOR( BCOMP ) = UBYTE_TO_FLOAT( b ); |
||
137 | CURRENT_COLOR( ACOMP ) = UBYTE_TO_FLOAT( a ); |
||
138 | #else |
||
139 | CURRENT_COLOR( RCOMP ) = r; |
||
140 | CURRENT_COLOR( GCOMP ) = g; |
||
141 | CURRENT_COLOR( BCOMP ) = b; |
||
142 | CURRENT_COLOR( ACOMP ) = a; |
||
143 | #endif |
||
144 | } |
||
145 | |||
146 | |||
147 | { |
||
148 | GET_CURRENT; |
||
149 | #ifdef COLOR_IS_FLOAT |
||
150 | CURRENT_COLOR( RCOMP ) = UBYTE_TO_FLOAT( v[0] ); |
||
151 | CURRENT_COLOR( GCOMP ) = UBYTE_TO_FLOAT( v[1] ); |
||
152 | CURRENT_COLOR( BCOMP ) = UBYTE_TO_FLOAT( v[2] ); |
||
153 | CURRENT_COLOR( ACOMP ) = UBYTE_TO_FLOAT( v[3] ); |
||
154 | #else |
||
155 | CURRENT_COLOR( RCOMP ) = v[0]; |
||
156 | CURRENT_COLOR( GCOMP ) = v[1]; |
||
157 | CURRENT_COLOR( BCOMP ) = v[2]; |
||
158 | CURRENT_COLOR( ACOMP ) = v[3]; |
||
159 | #endif |
||
160 | } |
||
161 | |||
162 | |||
163 | |||
164 | { |
||
165 | GET_CURRENT_CONTEXT(ctx); |
||
166 | GLfloat *color = ctx->Current.Color; |
||
167 | |||
168 | |||
169 | color[1] = g; |
||
170 | color[2] = b; |
||
171 | color[3] = 1.0; |
||
172 | |||
173 | |||
174 | RECALC_BASE_COLOR( ctx ); |
||
175 | } |
||
176 | |||
177 | |||
178 | { |
||
179 | GET_CURRENT_CONTEXT(ctx); |
||
180 | GLfloat *color = ctx->Current.Color; |
||
181 | |||
182 | |||
183 | color[1] = v[1]; |
||
184 | color[2] = v[2]; |
||
185 | color[3] = 1.0; |
||
186 | |||
187 | |||
188 | RECALC_BASE_COLOR( ctx ); |
||
189 | } |
||
190 | |||
191 | |||
192 | { |
||
193 | GET_CURRENT_CONTEXT(ctx); |
||
194 | GLfloat *color = ctx->Current.Color; |
||
195 | |||
196 | |||
197 | color[1] = UBYTE_TO_FLOAT( g ); |
||
198 | color[2] = UBYTE_TO_FLOAT( b ); |
||
199 | color[3] = 1.0; |
||
200 | |||
201 | |||
202 | RECALC_BASE_COLOR( ctx ); |
||
203 | } |
||
204 | |||
205 | |||
206 | { |
||
207 | GET_CURRENT_CONTEXT(ctx); |
||
208 | GLfloat *color = ctx->Current.Color; |
||
209 | |||
210 | |||
211 | color[1] = UBYTE_TO_FLOAT( v[1] ); |
||
212 | color[2] = UBYTE_TO_FLOAT( v[2] ); |
||
213 | color[3] = 1.0; |
||
214 | |||
215 | |||
216 | RECALC_BASE_COLOR( ctx ); |
||
217 | } |
||
218 | |||
219 | |||
220 | { |
||
221 | GET_CURRENT_CONTEXT(ctx); |
||
222 | GLfloat *color = ctx->Current.Color; |
||
223 | |||
224 | |||
225 | color[1] = g; |
||
226 | color[2] = b; |
||
227 | color[3] = a; |
||
228 | |||
229 | |||
230 | RECALC_BASE_COLOR( ctx ); |
||
231 | } |
||
232 | |||
233 | |||
234 | { |
||
235 | GET_CURRENT_CONTEXT(ctx); |
||
236 | GLfloat *color = ctx->Current.Color; |
||
237 | |||
238 | |||
239 | color[1] = v[1]; |
||
240 | color[2] = v[2]; |
||
241 | color[3] = v[3]; |
||
242 | |||
243 | |||
244 | RECALC_BASE_COLOR( ctx ); |
||
245 | } |
||
246 | |||
247 | |||
248 | { |
||
249 | GET_CURRENT_CONTEXT(ctx); |
||
250 | GLfloat *color = ctx->Current.Color; |
||
251 | |||
252 | |||
253 | color[1] = UBYTE_TO_FLOAT( g ); |
||
254 | color[2] = UBYTE_TO_FLOAT( b ); |
||
255 | color[3] = UBYTE_TO_FLOAT( a ); |
||
256 | |||
257 | |||
258 | RECALC_BASE_COLOR( ctx ); |
||
259 | } |
||
260 | |||
261 | |||
262 | { |
||
263 | GET_CURRENT_CONTEXT(ctx); |
||
264 | GLfloat *color = ctx->Current.Color; |
||
265 | |||
266 | |||
267 | color[1] = UBYTE_TO_FLOAT( v[1] ); |
||
268 | color[2] = UBYTE_TO_FLOAT( v[2] ); |
||
269 | color[3] = UBYTE_TO_FLOAT( v[3] ); |
||
270 | |||
271 | |||
272 | RECALC_BASE_COLOR( ctx ); |
||
273 | } |
||
274 | |||
275 | |||
276 | |||
277 | |||
278 | |||
279 | |||
280 | * Color chooser functions: |
||
281 | */ |
||
282 | |||
283 | |||
284 | { |
||
285 | GET_CURRENT_CONTEXT(ctx); |
||
286 | |||
287 | |||
288 | if ( ctx->Light.ColorMaterialEnabled ) { |
||
289 | SET_Color3f(ctx->Exec, TAG(ColorMaterial3f)); |
||
290 | } else { |
||
291 | SET_Color3f(ctx->Exec, _mesa_noop_Color3f); |
||
292 | } |
||
293 | } else { |
||
294 | SET_Color3f(ctx->Exec, TAG(Color3f)); |
||
295 | } |
||
296 | glColor3f( r, g, b ); |
||
297 | } |
||
298 | |||
299 | |||
300 | { |
||
301 | GET_CURRENT_CONTEXT(ctx); |
||
302 | |||
303 | |||
304 | if ( ctx->Light.ColorMaterialEnabled ) { |
||
305 | SET_Color3fv(ctx->Exec, TAG(ColorMaterial3fv)); |
||
306 | } else { |
||
307 | SET_Color3fv(ctx->Exec, _mesa_noop_Color3fv); |
||
308 | } |
||
309 | } else { |
||
310 | SET_Color3fv(ctx->Exec, TAG(Color3fv)); |
||
311 | } |
||
312 | glColor3fv( v ); |
||
313 | } |
||
314 | |||
315 | |||
316 | { |
||
317 | GET_CURRENT_CONTEXT(ctx); |
||
318 | |||
319 | |||
320 | if ( ctx->Light.ColorMaterialEnabled ) { |
||
321 | SET_Color3ub(ctx->Exec, TAG(ColorMaterial3ub)); |
||
322 | } else { |
||
323 | SET_Color3ub(ctx->Exec, _mesa_noop_Color3ub); |
||
324 | } |
||
325 | } else { |
||
326 | SET_Color3ub(ctx->Exec, TAG(Color3ub)); |
||
327 | } |
||
328 | glColor3ub( r, g, b ); |
||
329 | } |
||
330 | |||
331 | |||
332 | { |
||
333 | GET_CURRENT_CONTEXT(ctx); |
||
334 | |||
335 | |||
336 | if ( ctx->Light.ColorMaterialEnabled ) { |
||
337 | SET_Color3ubv(ctx->Exec, TAG(ColorMaterial3ubv)); |
||
338 | } else { |
||
339 | SET_Color3ubv(ctx->Exec, _mesa_noop_Color3ubv); |
||
340 | } |
||
341 | } else { |
||
342 | SET_Color3ubv(ctx->Exec, TAG(Color3ubv)); |
||
343 | } |
||
344 | glColor3ubv( v ); |
||
345 | } |
||
346 | |||
347 | |||
348 | { |
||
349 | GET_CURRENT_CONTEXT(ctx); |
||
350 | |||
351 | |||
352 | if ( ctx->Light.ColorMaterialEnabled ) { |
||
353 | SET_Color4f(ctx->Exec, TAG(ColorMaterial4f)); |
||
354 | } else { |
||
355 | SET_Color4f(ctx->Exec, _mesa_noop_Color4f); |
||
356 | } |
||
357 | } else { |
||
358 | SET_Color4f(ctx->Exec, TAG(Color4f)); |
||
359 | } |
||
360 | glColor4f( r, g, b, a ); |
||
361 | } |
||
362 | |||
363 | |||
364 | { |
||
365 | GET_CURRENT_CONTEXT(ctx); |
||
366 | |||
367 | |||
368 | if ( ctx->Light.ColorMaterialEnabled ) { |
||
369 | SET_Color4fv(ctx->Exec, TAG(ColorMaterial4fv)); |
||
370 | } else { |
||
371 | SET_Color4fv(ctx->Exec, _mesa_noop_Color4fv); |
||
372 | } |
||
373 | } else { |
||
374 | SET_Color4fv(ctx->Exec, TAG(Color4fv)); |
||
375 | } |
||
376 | glColor4fv( v ); |
||
377 | } |
||
378 | |||
379 | |||
380 | { |
||
381 | GET_CURRENT_CONTEXT(ctx); |
||
382 | |||
383 | |||
384 | if ( ctx->Light.ColorMaterialEnabled ) { |
||
385 | SET_Color4ub(ctx->Exec, TAG(ColorMaterial4ub)); |
||
386 | } else { |
||
387 | SET_Color4ub(ctx->Exec, _mesa_noop_Color4ub); |
||
388 | } |
||
389 | } else { |
||
390 | SET_Color4ub(ctx->Exec, TAG(Color4ub)); |
||
391 | } |
||
392 | glColor4ub( r, g, b, a ); |
||
393 | } |
||
394 | |||
395 | |||
396 | { |
||
397 | GET_CURRENT_CONTEXT(ctx); |
||
398 | |||
399 | |||
400 | if ( ctx->Light.ColorMaterialEnabled ) { |
||
401 | SET_Color4ubv(ctx->Exec, TAG(ColorMaterial4ubv)); |
||
402 | } else { |
||
403 | SET_Color4ubv(ctx->Exec, _mesa_noop_Color4ubv); |
||
404 | } |
||
405 | } else { |
||
406 | SET_Color4ubv(ctx->Exec, TAG(Color4ubv)); |
||
407 | } |
||
408 | glColor4ubv( v ); |
||
409 | } |
||
410 | |||
411 | |||
412 | |||
413 | |||
414 | #undef CURRENT_COLOR |
||
415 | #undef CURRENT_SPECULAR |
||
416 | #undef COLOR_IS_FLOAT |
||
417 | #undef RECALC_BASE_COLOR |
||
418 | #undef TAG |
||
419 |