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