VirtualBox

source: vbox/trunk/src/VBox/GuestHost/OpenGL/state_tracker/state_regcombiner.c@ 19099

Last change on this file since 19099 was 15532, checked in by vboxsync, 16 years ago

crOpenGL: export to OSE

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 23.2 KB
Line 
1/* Copyright (c) 2001, Stanford University
2 * All rights reserved
3 *
4 * See the file LICENSE.txt for information on redistributing this software.
5 */
6
7#include "state.h"
8#include "state/cr_statetypes.h"
9
10
11#define UNUSED(x) ((void) (x))
12
13
14void crStateRegCombinerInit( CRContext *ctx )
15{
16 CRRegCombinerState *reg = &ctx->regcombiner;
17 CRStateBits *sb = GetCurrentBits();
18 CRRegCombinerBits *rb = &(sb->regcombiner);
19#ifndef CR_NV_register_combiners
20 UNUSED(reg)
21#else
22 GLcolorf zero_color = {0.0f, 0.0f, 0.0f, 0.0f};
23 int i;
24
25 reg->enabledRegCombiners = GL_FALSE;
26 RESET(rb->enable, ctx->bitid);
27 reg->constantColor0 = zero_color;
28 RESET(rb->regCombinerColor0, ctx->bitid);
29 reg->constantColor1 = zero_color;
30 RESET(rb->regCombinerColor1, ctx->bitid);
31 for( i=0; i<CR_MAX_GENERAL_COMBINERS; i++ )
32 {
33 /* RGB Portion */
34 reg->rgb[i].a = GL_PRIMARY_COLOR_NV;
35 reg->rgb[i].b = GL_ZERO;
36 reg->rgb[i].c = GL_ZERO;
37 reg->rgb[i].d = GL_ZERO;
38 reg->rgb[i].aMapping = GL_UNSIGNED_IDENTITY_NV;
39 reg->rgb[i].bMapping = GL_UNSIGNED_INVERT_NV;
40 reg->rgb[i].cMapping = GL_UNSIGNED_IDENTITY_NV;
41 reg->rgb[i].dMapping = GL_UNSIGNED_IDENTITY_NV;
42 reg->rgb[i].aPortion = GL_RGB;
43 reg->rgb[i].bPortion = GL_RGB;
44 reg->rgb[i].cPortion = GL_RGB;
45 reg->rgb[i].dPortion = GL_RGB;
46 reg->rgb[i].scale = GL_NONE;
47 reg->rgb[i].bias = GL_NONE;
48 reg->rgb[i].abOutput = GL_DISCARD_NV;
49 reg->rgb[i].cdOutput = GL_DISCARD_NV;
50 reg->rgb[i].sumOutput = GL_SPARE0_NV;
51 reg->rgb[i].abDotProduct = GL_FALSE;
52 reg->rgb[i].cdDotProduct = GL_FALSE;
53 reg->rgb[i].muxSum = GL_FALSE;
54
55 /* Alpha Portion */
56 reg->alpha[i].a = GL_PRIMARY_COLOR_NV;
57 reg->alpha[i].b = GL_ZERO;
58 reg->alpha[i].c = GL_ZERO;
59 reg->alpha[i].d = GL_ZERO;
60 reg->alpha[i].aMapping = GL_UNSIGNED_IDENTITY_NV;
61 reg->alpha[i].bMapping = GL_UNSIGNED_INVERT_NV;
62 reg->alpha[i].cMapping = GL_UNSIGNED_IDENTITY_NV;
63 reg->alpha[i].dMapping = GL_UNSIGNED_IDENTITY_NV;
64 reg->alpha[i].aPortion = GL_ALPHA;
65 reg->alpha[i].bPortion = GL_ALPHA;
66 reg->alpha[i].cPortion = GL_ALPHA;
67 reg->alpha[i].dPortion = GL_ALPHA;
68 reg->alpha[i].scale = GL_NONE;
69 reg->alpha[i].bias = GL_NONE;
70 reg->alpha[i].abOutput = GL_DISCARD_NV;
71 reg->alpha[i].cdOutput = GL_DISCARD_NV;
72 reg->alpha[i].sumOutput = GL_SPARE0_NV;
73 reg->alpha[i].abDotProduct = GL_FALSE;
74 reg->alpha[i].cdDotProduct = GL_FALSE;
75 reg->alpha[i].muxSum = GL_FALSE;
76 RESET(rb->regCombinerInput[i], ctx->bitid);
77 RESET(rb->regCombinerOutput[i], ctx->bitid);
78 }
79 RESET(rb->regCombinerVars, ctx->bitid);
80 reg->numGeneralCombiners = 1;
81 reg->colorSumClamp = GL_TRUE;
82 reg->a = GL_FOG;
83 reg->b = GL_SPARE0_PLUS_SECONDARY_COLOR_NV;
84 reg->c = GL_FOG;
85 reg->d = GL_ZERO;
86 reg->e = GL_ZERO;
87 reg->f = GL_ZERO;
88 reg->g = GL_SPARE0_NV;
89 reg->aMapping = GL_UNSIGNED_IDENTITY_NV;
90 reg->bMapping = GL_UNSIGNED_IDENTITY_NV;
91 reg->cMapping = GL_UNSIGNED_IDENTITY_NV;
92 reg->dMapping = GL_UNSIGNED_IDENTITY_NV;
93 reg->eMapping = GL_UNSIGNED_IDENTITY_NV;
94 reg->fMapping = GL_UNSIGNED_IDENTITY_NV;
95 reg->gMapping = GL_UNSIGNED_IDENTITY_NV;
96 reg->aPortion = GL_ALPHA;
97 reg->bPortion = GL_RGB;
98 reg->cPortion = GL_RGB;
99 reg->dPortion = GL_RGB;
100 reg->ePortion = GL_RGB;
101 reg->fPortion = GL_RGB;
102 reg->gPortion = GL_ALPHA;
103 RESET(rb->regCombinerFinalInput, ctx->bitid);
104#ifdef CR_NV_register_combiners2
105 reg->enabledPerStageConstants = GL_FALSE;
106 for( i=0; i<CR_MAX_GENERAL_COMBINERS; i++ )
107 {
108 reg->stageConstantColor0[i] = zero_color;
109 reg->stageConstantColor1[i] = zero_color;
110 RESET(rb->regCombinerStageColor0[i], ctx->bitid);
111 RESET(rb->regCombinerStageColor1[i], ctx->bitid);
112 }
113#endif /* CR_NV_register_combiners2 */
114#endif /* CR_NV_register_combiners */
115
116 RESET(rb->dirty, ctx->bitid);
117}
118
119void STATE_APIENTRY crStateCombinerParameterfvNV( GLenum pname, const GLfloat *params )
120{
121 CRContext *g = GetCurrentContext();
122 CRRegCombinerState *r = &(g->regcombiner);
123 CRStateBits *sb = GetCurrentBits();
124 CRRegCombinerBits *rb = &(sb->regcombiner);
125
126 switch( pname )
127 {
128 case GL_CONSTANT_COLOR0_NV:
129 r->constantColor0.r = params[0];
130 r->constantColor0.g = params[1];
131 r->constantColor0.b = params[2];
132 r->constantColor0.a = params[3];
133 DIRTY(rb->regCombinerColor0, g->neg_bitid);
134 break;
135 case GL_CONSTANT_COLOR1_NV:
136 r->constantColor1.r = params[0];
137 r->constantColor1.g = params[1];
138 r->constantColor1.b = params[2];
139 r->constantColor1.a = params[3];
140 DIRTY(rb->regCombinerColor1, g->neg_bitid);
141 break;
142 case GL_NUM_GENERAL_COMBINERS_NV:
143 if( *params < 1 || *params > g->limits.maxGeneralCombiners )
144 {
145 crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "CombinerParameter passed invalid NUM_GENERAL_COMBINERS param: %d", (GLint)*params );
146 return;
147 }
148 r->numGeneralCombiners = (GLint)*params;
149 DIRTY(rb->regCombinerVars, g->neg_bitid);
150 break;
151 case GL_COLOR_SUM_CLAMP_NV:
152 r->colorSumClamp = (GLboolean)*params;
153 DIRTY(rb->regCombinerVars, g->neg_bitid);
154 break;
155 default:
156 crStateError( __LINE__, __FILE__, GL_INVALID_ENUM, "CombinerParameter passed bogus pname: 0x%x", pname );
157 return;
158 }
159
160 DIRTY(rb->dirty, g->neg_bitid);
161}
162
163void STATE_APIENTRY crStateCombinerParameterivNV( GLenum pname, const GLint *params )
164{
165 GLfloat fparams[4];
166 int i;
167
168 if( pname == GL_CONSTANT_COLOR0_NV || pname == GL_CONSTANT_COLOR1_NV )
169 {
170 for( i=0; i<4; i++ )
171 {
172 fparams[i] = (GLfloat)params[i] * (GLfloat)(1.0/255.0);
173 }
174 }
175 else
176 {
177 /* Only one paramater: */
178 *fparams = (GLfloat) *params;
179 }
180 crStateCombinerParameterfvNV( pname, fparams );
181}
182
183void STATE_APIENTRY crStateCombinerParameterfNV( GLenum pname, GLfloat param )
184{
185 GLfloat fparam[1];
186 *fparam = (GLfloat) param;
187 if( pname == GL_CONSTANT_COLOR0_NV || pname == GL_CONSTANT_COLOR1_NV )
188 {
189 crStateError( __LINE__, __FILE__, GL_INVALID_ENUM, "Invalid pname (CONSTANT_COLOR%d) passed to CombinerParameterfNV: 0x%x", (GLint)param-GL_CONSTANT_COLOR0_NV, pname );
190 return;
191 }
192 crStateCombinerParameterfvNV( pname, fparam );
193}
194
195void STATE_APIENTRY crStateCombinerParameteriNV( GLenum pname, GLint param )
196{
197 GLfloat fparam[1];
198 *fparam = (GLfloat) param;
199 if( pname == GL_CONSTANT_COLOR0_NV || pname == GL_CONSTANT_COLOR1_NV )
200 {
201 crStateError( __LINE__, __FILE__, GL_INVALID_ENUM, "Invalid pname (CONSTANT_COLOR%d) passed to CombinerParameteriNV: 0x%x", param-GL_CONSTANT_COLOR0_NV, pname );
202 return;
203 }
204 crStateCombinerParameterfvNV( pname, fparam );
205}
206
207void STATE_APIENTRY crStateCombinerInputNV( GLenum stage, GLenum portion, GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage )
208{
209 CRContext *g = GetCurrentContext();
210 CRRegCombinerState *r = &(g->regcombiner);
211 CRStateBits *sb = GetCurrentBits();
212 CRRegCombinerBits *rb = &(sb->regcombiner);
213
214 if( stage < GL_COMBINER0_NV || stage >= GL_COMBINER0_NV + g->limits.maxGeneralCombiners )
215 {
216 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "CombinerInputNV passed bogus stage: 0x%x", stage );
217 return;
218 }
219 if( input != GL_ZERO && input != GL_CONSTANT_COLOR0_NV && input != GL_CONSTANT_COLOR1_NV && input != GL_FOG && input != GL_PRIMARY_COLOR_NV && input != GL_SECONDARY_COLOR_NV && input != GL_SPARE0_NV && input != GL_SPARE1_NV && ( input < GL_TEXTURE0_ARB || input >= GL_TEXTURE0_ARB + g->limits.maxTextureUnits ))
220 {
221 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "CombinerInputNV passed bogus input: 0x%x", input );
222 return;
223 }
224 if( mapping != GL_UNSIGNED_IDENTITY_NV && mapping != GL_UNSIGNED_INVERT_NV && mapping != GL_EXPAND_NORMAL_NV && mapping != GL_EXPAND_NEGATE_NV && mapping != GL_HALF_BIAS_NORMAL_NV && mapping != GL_HALF_BIAS_NEGATE_NV && mapping != GL_SIGNED_IDENTITY_NV && mapping != GL_SIGNED_NEGATE_NV )
225 {
226 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "CombinerInputNV passed bogus mapping: 0x%x", mapping );
227 return;
228 }
229 if( componentUsage != GL_RGB && componentUsage != GL_ALPHA && componentUsage != GL_BLUE )
230 {
231 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "CombinerInputNV passed bogus componentUsage: 0x%x", componentUsage );
232 return;
233 }
234
235 if(( componentUsage == GL_RGB && portion == GL_ALPHA )||( componentUsage == GL_BLUE && portion == GL_RGB ))
236 {
237 crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "Incompatible portion and componentUsage passed to CombinerInputNV: portion = 0x%x, componentUsage = 0x%x", portion, componentUsage );
238 return;
239 }
240 if( componentUsage == GL_ALPHA && input == GL_FOG )
241 {
242 crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "CombinerInputNV can not have input of GL_FOG if componentUsage is GL_ALPHA" );
243 return;
244 }
245
246 stage -= GL_COMBINER0_NV;
247 if( portion == GL_RGB )
248 {
249 switch( variable )
250 {
251 case GL_VARIABLE_A_NV:
252 r->rgb[stage].a = input;
253 r->rgb[stage].aMapping = mapping;
254 r->rgb[stage].aPortion = componentUsage;
255 break;
256 case GL_VARIABLE_B_NV:
257 r->rgb[stage].b = input;
258 r->rgb[stage].bMapping = mapping;
259 r->rgb[stage].bPortion = componentUsage;
260 break;
261 case GL_VARIABLE_C_NV:
262 r->rgb[stage].c = input;
263 r->rgb[stage].cMapping = mapping;
264 r->rgb[stage].cPortion = componentUsage;
265 break;
266 case GL_VARIABLE_D_NV:
267 r->rgb[stage].d = input;
268 r->rgb[stage].dMapping = mapping;
269 r->rgb[stage].dPortion = componentUsage;
270 break;
271 default:
272 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "CombinerInputNV passed bogus variable: 0x%x", variable );
273 return;
274 }
275 }
276 else if( portion == GL_ALPHA )
277 {
278 switch( variable )
279 {
280 case GL_VARIABLE_A_NV:
281 r->alpha[stage].a = input;
282 r->alpha[stage].aMapping = mapping;
283 r->alpha[stage].aPortion = componentUsage;
284 break;
285 case GL_VARIABLE_B_NV:
286 r->alpha[stage].b = input;
287 r->alpha[stage].bMapping = mapping;
288 r->alpha[stage].bPortion = componentUsage;
289 break;
290 case GL_VARIABLE_C_NV:
291 r->alpha[stage].c = input;
292 r->alpha[stage].cMapping = mapping;
293 r->alpha[stage].cPortion = componentUsage;
294 break;
295 case GL_VARIABLE_D_NV:
296 r->alpha[stage].d = input;
297 r->alpha[stage].dMapping = mapping;
298 r->alpha[stage].dPortion = componentUsage;
299 break;
300 default:
301 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "CombinerInputNV passed bogus variable: 0x%x", variable );
302 return;
303 }
304 }
305 else
306 {
307 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "CombinerInputNV passed bogus portion: 0x%x", portion );
308 return;
309 }
310
311 DIRTY(rb->regCombinerInput[stage], g->neg_bitid);
312 DIRTY(rb->dirty, g->neg_bitid);
313}
314
315void STATE_APIENTRY crStateCombinerOutputNV( GLenum stage, GLenum portion, GLenum abOutput, GLenum cdOutput, GLenum sumOutput, GLenum scale, GLenum bias, GLboolean abDotProduct, GLboolean cdDotProduct, GLboolean muxSum )
316{
317 CRContext *g = GetCurrentContext();
318 CRRegCombinerState *r = &(g->regcombiner);
319 CRStateBits *sb = GetCurrentBits();
320 CRRegCombinerBits *rb = &(sb->regcombiner);
321
322 /*
323 crDebug("%s(stage=0x%x portion=0x%x abOutput=0x%x cdOutput=0x%x "
324 "sumOutput=0x%x scale=0x%x bias=0x%x abDotProduct=0x%x "
325 "cdDotProduct=%d muxSum=%d)\n",
326 __FUNCTION__,
327 stage, portion, abOutput, cdOutput, sumOutput, scale, bias,
328 abDotProduct, cdDotProduct, muxSum);
329 */
330 if( stage < GL_COMBINER0_NV || stage >= GL_COMBINER0_NV + g->limits.maxGeneralCombiners )
331 {
332 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "CombinerOutputNV passed bogus stage: 0x%x", stage );
333 return;
334 }
335 if( abOutput != GL_DISCARD_NV && abOutput != GL_PRIMARY_COLOR_NV && abOutput != GL_SECONDARY_COLOR_NV && abOutput != GL_SPARE0_NV && abOutput != GL_SPARE1_NV && ( abOutput < GL_TEXTURE0_ARB || abOutput >= g->limits.maxTextureUnits + GL_TEXTURE0_ARB ))
336 {
337 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "CombinerOutputNV passed bogus abOutput: 0x%x", abOutput );
338 return;
339 }
340 if( cdOutput != GL_DISCARD_NV && cdOutput != GL_PRIMARY_COLOR_NV && cdOutput != GL_SECONDARY_COLOR_NV && cdOutput != GL_SPARE0_NV && cdOutput != GL_SPARE1_NV && ( cdOutput < GL_TEXTURE0_ARB || cdOutput >= g->limits.maxTextureUnits + GL_TEXTURE0_ARB ))
341 {
342 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "CombinerOutputNV passed bogus cdOutput: 0x%x", cdOutput );
343 return;
344 }
345 if( sumOutput != GL_DISCARD_NV && sumOutput != GL_PRIMARY_COLOR_NV && sumOutput != GL_SECONDARY_COLOR_NV && sumOutput != GL_SPARE0_NV && sumOutput != GL_SPARE1_NV && sumOutput != GL_TEXTURE0_ARB && sumOutput != GL_TEXTURE1_ARB )
346 {
347 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "CombinerOutputNV passed bogus sumOutput: 0x%x", sumOutput );
348 return;
349 }
350 if( scale != GL_NONE && scale != GL_SCALE_BY_TWO_NV && scale != GL_SCALE_BY_FOUR_NV && scale != GL_SCALE_BY_ONE_HALF_NV )
351 {
352 crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "CombinerOutputNV passed bogus scale: 0x%x", scale );
353 return;
354 }
355 if( bias != GL_NONE && bias != GL_BIAS_BY_NEGATIVE_ONE_HALF_NV )
356 {
357 crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "CombinerOutputNV passed bogus bias: 0x%x", bias );
358 return;
359 }
360
361 if( bias == GL_BIAS_BY_NEGATIVE_ONE_HALF_NV && ( scale == GL_SCALE_BY_ONE_HALF_NV || scale == GL_SCALE_BY_FOUR_NV ))
362 {
363 crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "CombinerOutputNV can't accept bias of -1/2 if scale is by 1/2 or 4" );
364 return;
365 }
366 if(( abOutput == cdOutput && abOutput != GL_DISCARD_NV )||( abOutput == sumOutput && abOutput != GL_DISCARD_NV )||( cdOutput == sumOutput && cdOutput != GL_DISCARD_NV ))
367 {
368 crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "CombinerOutputNV register output names must be unique unless discarded: abOutput = 0x%x, cdOutput = 0x%x, sumOutput = 0x%x", abOutput, cdOutput, sumOutput );
369 return;
370 }
371 if( abDotProduct || cdDotProduct )
372 {
373 if( portion == GL_ALPHA )
374 {
375 crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "CombinerOutputNV can not do Dot Products when portion = GL_ALPHA" );
376 return;
377 }
378 if( sumOutput != GL_DISCARD_NV )
379 {
380 crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "CombinerOutputNV can not do Dot Products when sumOutput is not discarded" );
381 return;
382 }
383 }
384
385 stage -= GL_COMBINER0_NV;
386 if( portion == GL_RGB )
387 {
388 r->rgb[stage].abOutput = abOutput;
389 r->rgb[stage].cdOutput = cdOutput;
390 r->rgb[stage].sumOutput = sumOutput;
391 r->rgb[stage].scale = scale;
392 r->rgb[stage].bias = bias;
393 r->rgb[stage].abDotProduct = abDotProduct;
394 r->rgb[stage].cdDotProduct = cdDotProduct;
395 r->rgb[stage].muxSum = muxSum;
396 }
397 else if( portion == GL_ALPHA )
398 {
399 r->alpha[stage].abOutput = abOutput;
400 r->alpha[stage].cdOutput = cdOutput;
401 r->alpha[stage].sumOutput = sumOutput;
402 r->alpha[stage].scale = scale;
403 r->alpha[stage].bias = bias;
404 r->alpha[stage].abDotProduct = abDotProduct;
405 r->alpha[stage].cdDotProduct = cdDotProduct;
406 r->alpha[stage].muxSum = muxSum;
407 }
408 else
409 {
410 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "CombinerOutputNV passed bogus portion: 0x%x", portion );
411 return;
412 }
413
414 DIRTY(rb->regCombinerOutput[stage], g->neg_bitid);
415 DIRTY(rb->dirty, g->neg_bitid);
416}
417
418void STATE_APIENTRY crStateFinalCombinerInputNV( GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage )
419{
420 CRContext *g = GetCurrentContext();
421 CRRegCombinerState *r = &(g->regcombiner);
422 CRStateBits *sb = GetCurrentBits();
423 CRRegCombinerBits *rb = &(sb->regcombiner);
424
425 if( input != GL_ZERO && input != GL_CONSTANT_COLOR0_NV && input != GL_CONSTANT_COLOR1_NV && input != GL_FOG && input != GL_PRIMARY_COLOR_NV && input != GL_SECONDARY_COLOR_NV && input != GL_SPARE0_NV && input != GL_SPARE1_NV && ( input < GL_TEXTURE0_ARB || input >= GL_TEXTURE0_ARB + g->limits.maxTextureUnits ) && input != GL_E_TIMES_F_NV && input != GL_SPARE0_PLUS_SECONDARY_COLOR_NV )
426 {
427 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "FinalCombinerInputNV passed bogus input: 0x%x", input );
428 return;
429 }
430 if( mapping != GL_UNSIGNED_IDENTITY_NV && mapping != GL_UNSIGNED_INVERT_NV && mapping != GL_EXPAND_NORMAL_NV && mapping != GL_EXPAND_NEGATE_NV && mapping != GL_HALF_BIAS_NORMAL_NV && mapping != GL_HALF_BIAS_NEGATE_NV && mapping != GL_SIGNED_IDENTITY_NV && mapping != GL_SIGNED_NEGATE_NV )
431 {
432 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "FinalCombinerInputNV passed bogus mapping: 0x%x", mapping );
433 return;
434 }
435 if( componentUsage != GL_RGB && componentUsage != GL_ALPHA && componentUsage != GL_BLUE )
436 {
437 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "FinalCombinerInputNV passed bogus componentUsage: 0x%x", componentUsage );
438 return;
439 }
440
441 if( componentUsage == GL_ALPHA && ( input == GL_E_TIMES_F_NV || input == GL_SPARE0_PLUS_SECONDARY_COLOR_NV ))
442 {
443 crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "FinalCombinerInputNV does not allow componentUsage of ALPHA when input is E_TIMES_F or SPARE0_PLUS_SECONDARY_COLOR" );
444 return;
445 }
446
447 switch( variable )
448 {
449 case GL_VARIABLE_A_NV:
450 r->a = input;
451 r->aMapping = mapping;
452 r->aPortion = componentUsage;
453 break;
454 case GL_VARIABLE_B_NV:
455 r->b = input;
456 r->bMapping = mapping;
457 r->bPortion = componentUsage;
458 break;
459 case GL_VARIABLE_C_NV:
460 r->c = input;
461 r->cMapping = mapping;
462 r->cPortion = componentUsage;
463 break;
464 case GL_VARIABLE_D_NV:
465 r->d = input;
466 r->dMapping = mapping;
467 r->dPortion = componentUsage;
468 break;
469 case GL_VARIABLE_E_NV:
470 r->e = input;
471 r->eMapping = mapping;
472 r->ePortion = componentUsage;
473 break;
474 case GL_VARIABLE_F_NV:
475 r->f = input;
476 r->fMapping = mapping;
477 r->fPortion = componentUsage;
478 break;
479 case GL_VARIABLE_G_NV:
480 if( componentUsage != GL_ALPHA )
481 {
482 crStateError( __LINE__, __FILE__, GL_INVALID_OPERATION, "FinalCombinerInputNV can not have variable G when componentUsage is RGB or BLUE" );
483 return;
484 }
485 r->g = input;
486 r->gMapping = mapping;
487 r->gPortion = componentUsage;
488 break;
489 default:
490 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "CombinerOutputNV passed bogus variable: 0x%x", variable );
491 return;
492 }
493
494 DIRTY(rb->regCombinerFinalInput, g->neg_bitid);
495 DIRTY(rb->dirty, g->neg_bitid);
496}
497
498
499/* XXX Unfinished RegCombiner State functions */
500void STATE_APIENTRY crStateGetCombinerOutputParameterfvNV( GLenum stage, GLenum portion, GLenum pname, GLfloat *params )
501{
502 (void) stage;
503 (void) portion;
504 (void) pname;
505 (void) params;
506}
507
508void STATE_APIENTRY crStateGetCombinerOutputParameterivNV( GLenum stage, GLenum portion, GLenum pname, GLint *params )
509{
510 (void) stage;
511 (void) portion;
512 (void) pname;
513 (void) params;
514}
515
516void STATE_APIENTRY crStateGetFinalCombinerInputParameterfvNV( GLenum variable, GLenum pname, GLfloat *params )
517{
518 (void) variable;
519 (void) pname;
520 (void) params;
521}
522
523void STATE_APIENTRY crStateGetFinalCombinerInputParameterivNV( GLenum variable, GLenum pname, GLint *params )
524{
525 (void) variable;
526 (void) pname;
527 (void) params;
528}
529
530
531void STATE_APIENTRY crStateGetCombinerInputParameterivNV( GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLint *params )
532{
533 CRContext *g = GetCurrentContext();
534 CRRegCombinerState *r = &(g->regcombiner);
535 int i = stage - GL_COMBINER0_NV;
536 GLenum input = 0, mapping = 0, usage = 0;
537
538 if (g->current.inBeginEnd)
539 {
540 crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION,
541 "glGetCombinerParameterivNV called in begin/end");
542 return;
543 }
544
545 if (i < 0 || i > CR_MAX_GENERAL_COMBINERS) {
546 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM,
547 "GetCombinerInputParameterivNV(stage=0x%x)", stage);
548 return;
549 }
550
551 if (portion == GL_RGB) {
552 switch (variable) {
553 case GL_VARIABLE_A_NV:
554 input = r->rgb[i].a;
555 mapping = r->rgb[i].aMapping;
556 usage = r->rgb[i].aPortion;
557 break;
558 case GL_VARIABLE_B_NV:
559 input = r->rgb[i].b;
560 mapping = r->rgb[i].bMapping;
561 usage = r->rgb[i].bPortion;
562 break;
563 case GL_VARIABLE_C_NV:
564 input = r->rgb[i].c;
565 mapping = r->rgb[i].cMapping;
566 usage = r->rgb[i].cPortion;
567 break;
568 case GL_VARIABLE_D_NV:
569 input = r->rgb[i].d;
570 mapping = r->rgb[i].dMapping;
571 usage = r->rgb[i].dPortion;
572 break;
573 default:
574 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM,
575 "glGetCombinerInputParameterivNV(variable=0x%x)", variable);
576 return;
577 }
578 }
579 else if (portion == GL_ALPHA) {
580 switch (variable) {
581 case GL_VARIABLE_A_NV:
582 input = r->alpha[i].a;
583 mapping = r->alpha[i].aMapping;
584 usage = r->alpha[i].aPortion;
585 break;
586 case GL_VARIABLE_B_NV:
587 input = r->alpha[i].b;
588 mapping = r->alpha[i].bMapping;
589 usage = r->alpha[i].bPortion;
590 break;
591 case GL_VARIABLE_C_NV:
592 input = r->alpha[i].c;
593 mapping = r->alpha[i].cMapping;
594 usage = r->alpha[i].cPortion;
595 break;
596 case GL_VARIABLE_D_NV:
597 input = r->alpha[i].d;
598 mapping = r->alpha[i].dMapping;
599 usage = r->alpha[i].dPortion;
600 break;
601 default:
602 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM,
603 "glGetCombinerInputParameterivNV(variable=0x%x)", variable);
604 return;
605 }
606 }
607 else {
608 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM,
609 "glGetCombinerInputParameterivNV(portion=0x%x)", portion);
610 }
611 switch (pname) {
612 case GL_COMBINER_INPUT_NV:
613 *params = input;
614 return;
615 case GL_COMBINER_MAPPING_NV:
616 *params = mapping;
617 return;
618 case GL_COMBINER_COMPONENT_USAGE_NV:
619 *params = usage;
620 return;
621 default:
622 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM,
623 "glGetCombinerInputParameterivNV(pname=0x%x)", pname);
624 return;
625 }
626}
627
628
629void STATE_APIENTRY crStateGetCombinerInputParameterfvNV( GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLfloat *params )
630{
631 GLint iparams;
632 crStateGetCombinerInputParameterivNV(stage, portion, variable, pname, &iparams);
633 *params = (GLfloat) iparams;
634}
635
636
637void STATE_APIENTRY crStateCombinerStageParameterfvNV( GLenum stage, GLenum pname, const GLfloat *params )
638{
639 CRContext *g = GetCurrentContext();
640 CRRegCombinerState *r = &(g->regcombiner);
641 CRStateBits *sb = GetCurrentBits();
642 CRRegCombinerBits *rb = &(sb->regcombiner);
643
644 stage -= GL_COMBINER0_NV;
645 if( stage >= g->limits.maxGeneralCombiners )
646 {
647 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "CombinerStageParameterfvNV passed bogus stage: 0x%x", stage+GL_COMBINER0_NV );
648 return;
649 }
650
651 switch( pname )
652 {
653 case GL_CONSTANT_COLOR0_NV:
654 r->stageConstantColor0[stage].r = params[0];
655 r->stageConstantColor0[stage].g = params[1];
656 r->stageConstantColor0[stage].b = params[2];
657 r->stageConstantColor0[stage].a = params[3];
658 DIRTY(rb->regCombinerStageColor0[stage], g->neg_bitid);
659 break;
660 case GL_CONSTANT_COLOR1_NV:
661 r->stageConstantColor1[stage].r = params[0];
662 r->stageConstantColor1[stage].g = params[1];
663 r->stageConstantColor1[stage].b = params[2];
664 r->stageConstantColor1[stage].a = params[3];
665 DIRTY(rb->regCombinerStageColor1[stage], g->neg_bitid);
666 break;
667 default:
668 crStateError( __LINE__, __FILE__, GL_INVALID_ENUM, "CombinerStageParameter passed bogus pname: 0x%x", pname );
669 return;
670 }
671
672 DIRTY(rb->dirty, g->neg_bitid);
673}
674
675void STATE_APIENTRY crStateGetCombinerStageParameterfvNV( GLenum stage, GLenum pname, GLfloat *params )
676{
677 CRContext *g = GetCurrentContext();
678 CRRegCombinerState *r = &(g->regcombiner);
679
680 stage -= GL_COMBINER0_NV;
681 if( stage >= g->limits.maxGeneralCombiners )
682 {
683 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "GetCombinerStageParameterfvNV passed bogus stage: 0x%x", stage+GL_COMBINER0_NV );
684 return;
685 }
686 switch( pname )
687 {
688 case GL_CONSTANT_COLOR0_NV:
689 params[0] = r->stageConstantColor0[stage].r;
690 params[1] = r->stageConstantColor0[stage].g;
691 params[2] = r->stageConstantColor0[stage].b;
692 params[3] = r->stageConstantColor0[stage].a;
693 break;
694 case GL_CONSTANT_COLOR1_NV:
695 params[0] = r->stageConstantColor1[stage].r;
696 params[1] = r->stageConstantColor1[stage].g;
697 params[2] = r->stageConstantColor1[stage].b;
698 params[3] = r->stageConstantColor1[stage].a;
699 break;
700 default:
701 crStateError( __LINE__, __FILE__, GL_INVALID_ENUM, "GetCombinerStageParameter passed bogus pname: 0x%x", pname );
702 return;
703 }
704 return;
705}
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette