1 | #include "rc1.0_final.h"
|
---|
2 | #include "nvparse_errors.h"
|
---|
3 | #include "nvparse_externs.h"
|
---|
4 |
|
---|
5 | #include <OgreGLPrerequisites.h>
|
---|
6 |
|
---|
7 | void FinalRgbFunctionStruct::ZeroOut()
|
---|
8 | {
|
---|
9 | RegisterEnum zero;
|
---|
10 | zero.word = RCP_ZERO;
|
---|
11 | a.Init(zero, GL_UNSIGNED_IDENTITY_NV);
|
---|
12 | b.Init(zero, GL_UNSIGNED_IDENTITY_NV);
|
---|
13 | c.Init(zero, GL_UNSIGNED_IDENTITY_NV);
|
---|
14 | d.Init(zero, GL_UNSIGNED_IDENTITY_NV);
|
---|
15 | }
|
---|
16 |
|
---|
17 | void FinalAlphaFunctionStruct::ZeroOut()
|
---|
18 | {
|
---|
19 | RegisterEnum zero;
|
---|
20 | zero.word = RCP_ZERO;
|
---|
21 | g.Init(zero, GL_UNSIGNED_IDENTITY_NV);
|
---|
22 | }
|
---|
23 |
|
---|
24 | void FinalProductStruct::ZeroOut()
|
---|
25 | {
|
---|
26 | RegisterEnum zero;
|
---|
27 | zero.word = RCP_ZERO;
|
---|
28 | e.Init(zero, GL_UNSIGNED_IDENTITY_NV);
|
---|
29 | f.Init(zero, GL_UNSIGNED_IDENTITY_NV);
|
---|
30 | }
|
---|
31 | void FinalCombinerStruct::Validate()
|
---|
32 | {
|
---|
33 | if (hasProduct &&
|
---|
34 | (GL_E_TIMES_F_NV == product.e.reg.bits.name ||
|
---|
35 | GL_SPARE0_PLUS_SECONDARY_COLOR_NV == product.e.reg.bits.name ||
|
---|
36 | GL_DISCARD_NV == product.e.reg.bits.name ||
|
---|
37 | GL_E_TIMES_F_NV == product.f.reg.bits.name ||
|
---|
38 | GL_SPARE0_PLUS_SECONDARY_COLOR_NV == product.f.reg.bits.name ||
|
---|
39 | GL_DISCARD_NV == product.f.reg.bits.name))
|
---|
40 | errors.set("invalid input register for final_product");
|
---|
41 |
|
---|
42 | if (hasProduct &&
|
---|
43 | (RCP_BLUE == product.e.reg.bits.channel ||
|
---|
44 | RCP_BLUE == product.f.reg.bits.channel))
|
---|
45 | errors.set("blue register used in final_product");
|
---|
46 |
|
---|
47 | if (GL_E_TIMES_F_NV == alpha.g.reg.bits.name ||
|
---|
48 | GL_SPARE0_PLUS_SECONDARY_COLOR_NV == alpha.g.reg.bits.name ||
|
---|
49 | GL_DISCARD_NV == alpha.g.reg.bits.name)
|
---|
50 | errors.set("invalid input register for final alpha");
|
---|
51 |
|
---|
52 | if (RCP_RGB == alpha.g.reg.bits.channel)
|
---|
53 | errors.set("rgb register used in final alpha");
|
---|
54 |
|
---|
55 | if (GL_SPARE0_PLUS_SECONDARY_COLOR_NV == rgb.a.reg.bits.name &&
|
---|
56 | GL_SPARE0_PLUS_SECONDARY_COLOR_NV != rgb.b.reg.bits.name &&
|
---|
57 | GL_ZERO == rgb.c.reg.bits.name && GL_UNSIGNED_IDENTITY_NV == rgb.c.map)
|
---|
58 | {
|
---|
59 | MappedRegisterStruct temp;
|
---|
60 | temp = rgb.a;
|
---|
61 | rgb.a = rgb.b;
|
---|
62 | rgb.b = temp;
|
---|
63 | }
|
---|
64 |
|
---|
65 | if (GL_SPARE0_PLUS_SECONDARY_COLOR_NV == rgb.a.reg.bits.name &&
|
---|
66 | GL_ZERO == rgb.b.reg.bits.name && GL_UNSIGNED_INVERT_NV == rgb.b.map &&
|
---|
67 | GL_ZERO == rgb.c.reg.bits.name && GL_UNSIGNED_IDENTITY_NV == rgb.c.map &&
|
---|
68 | GL_SPARE0_PLUS_SECONDARY_COLOR_NV != rgb.d.reg.bits.name)
|
---|
69 | {
|
---|
70 | MappedRegisterStruct temp;
|
---|
71 | temp = rgb.a;
|
---|
72 | rgb.a = rgb.d;
|
---|
73 | rgb.d = temp;
|
---|
74 | }
|
---|
75 |
|
---|
76 | if (GL_SPARE0_PLUS_SECONDARY_COLOR_NV == rgb.a.reg.bits.name ||
|
---|
77 | GL_DISCARD_NV == rgb.a.reg.bits.name ||
|
---|
78 | GL_DISCARD_NV == rgb.b.reg.bits.name ||
|
---|
79 | GL_DISCARD_NV == rgb.c.reg.bits.name ||
|
---|
80 | GL_DISCARD_NV == rgb.d.reg.bits.name)
|
---|
81 | errors.set("invalid input register for final rgb");
|
---|
82 |
|
---|
83 | if (RCP_BLUE == rgb.a.reg.bits.channel ||
|
---|
84 | RCP_BLUE == rgb.b.reg.bits.channel ||
|
---|
85 | RCP_BLUE == rgb.c.reg.bits.channel ||
|
---|
86 | RCP_BLUE == rgb.d.reg.bits.channel)
|
---|
87 | errors.set("blue register used in final rgb");
|
---|
88 |
|
---|
89 | if ((GL_E_TIMES_F_NV == rgb.a.reg.bits.name ||
|
---|
90 | GL_E_TIMES_F_NV == rgb.b.reg.bits.name ||
|
---|
91 | GL_E_TIMES_F_NV == rgb.c.reg.bits.name ||
|
---|
92 | GL_E_TIMES_F_NV == rgb.d.reg.bits.name) && !hasProduct)
|
---|
93 | errors.set("final_product used but not set");
|
---|
94 |
|
---|
95 | if (RCP_NONE == rgb.a.reg.bits.channel)
|
---|
96 | rgb.a.reg.bits.channel = RCP_RGB;
|
---|
97 | if (RCP_NONE == rgb.b.reg.bits.channel)
|
---|
98 | rgb.b.reg.bits.channel = RCP_RGB;
|
---|
99 | if (RCP_NONE == rgb.c.reg.bits.channel)
|
---|
100 | rgb.c.reg.bits.channel = RCP_RGB;
|
---|
101 | if (RCP_NONE == rgb.d.reg.bits.channel)
|
---|
102 | rgb.d.reg.bits.channel = RCP_RGB;
|
---|
103 | if (RCP_NONE == product.e.reg.bits.channel)
|
---|
104 | product.e.reg.bits.channel = RCP_RGB;
|
---|
105 | if (RCP_NONE == product.f.reg.bits.channel)
|
---|
106 | product.f.reg.bits.channel = RCP_RGB;
|
---|
107 | if (RCP_NONE == alpha.g.reg.bits.channel)
|
---|
108 | alpha.g.reg.bits.channel = RCP_ALPHA;
|
---|
109 | }
|
---|
110 |
|
---|
111 | void FinalCombinerStruct::Invoke()
|
---|
112 | {
|
---|
113 | if(clamp)
|
---|
114 | glCombinerParameteriNV(GL_COLOR_SUM_CLAMP_NV, GL_TRUE);
|
---|
115 | else
|
---|
116 | glCombinerParameteriNV(GL_COLOR_SUM_CLAMP_NV, GL_FALSE);
|
---|
117 |
|
---|
118 | glFinalCombinerInputNV(
|
---|
119 | GL_VARIABLE_A_NV,
|
---|
120 | rgb.a.reg.bits.name,
|
---|
121 | rgb.a.map,
|
---|
122 | MAP_CHANNEL(rgb.a.reg.bits.channel));
|
---|
123 |
|
---|
124 | glFinalCombinerInputNV(
|
---|
125 | GL_VARIABLE_B_NV,
|
---|
126 | rgb.b.reg.bits.name,
|
---|
127 | rgb.b.map,
|
---|
128 | MAP_CHANNEL(rgb.b.reg.bits.channel));
|
---|
129 |
|
---|
130 | glFinalCombinerInputNV(
|
---|
131 | GL_VARIABLE_C_NV,
|
---|
132 | rgb.c.reg.bits.name,
|
---|
133 | rgb.c.map,
|
---|
134 | MAP_CHANNEL(rgb.c.reg.bits.channel));
|
---|
135 |
|
---|
136 | glFinalCombinerInputNV(
|
---|
137 | GL_VARIABLE_D_NV,
|
---|
138 | rgb.d.reg.bits.name,
|
---|
139 | rgb.d.map,
|
---|
140 | MAP_CHANNEL(rgb.d.reg.bits.channel));
|
---|
141 |
|
---|
142 | glFinalCombinerInputNV(
|
---|
143 | GL_VARIABLE_E_NV,
|
---|
144 | product.e.reg.bits.name,
|
---|
145 | product.e.map,
|
---|
146 | MAP_CHANNEL(product.e.reg.bits.channel));
|
---|
147 |
|
---|
148 | glFinalCombinerInputNV(
|
---|
149 | GL_VARIABLE_F_NV,
|
---|
150 | product.f.reg.bits.name,
|
---|
151 | product.f.map,
|
---|
152 | MAP_CHANNEL(product.f.reg.bits.channel));
|
---|
153 |
|
---|
154 | glFinalCombinerInputNV(
|
---|
155 | GL_VARIABLE_G_NV,
|
---|
156 | alpha.g.reg.bits.name,
|
---|
157 | alpha.g.map,
|
---|
158 | MAP_CHANNEL(alpha.g.reg.bits.channel));
|
---|
159 | }
|
---|