23 int StencilAttrib::_attrib_slot;
25 const char *StencilAttrib::
26 stencil_render_state_name_array[StencilAttrib::SRS_total] =
28 "SRS_front_comparison_function",
29 "SRS_front_stencil_fail_operation",
30 "SRS_front_stencil_pass_z_fail_operation",
31 "SRS_front_stencil_pass_z_pass_operation",
37 "SRS_back_comparison_function",
38 "SRS_back_stencil_fail_operation",
39 "SRS_back_stencil_pass_z_fail_operation",
40 "SRS_back_stencil_pass_z_pass_operation",
51 _stencil_render_states [SRS_front_comparison_function] = M_none;
52 _stencil_render_states [SRS_front_stencil_fail_operation] = SO_keep;
53 _stencil_render_states [SRS_front_stencil_pass_z_fail_operation] = SO_keep;
54 _stencil_render_states [SRS_front_stencil_pass_z_pass_operation] = SO_keep;
56 _stencil_render_states [SRS_reference] = 0;
57 _stencil_render_states [SRS_read_mask] = ~0;
58 _stencil_render_states [SRS_write_mask] = ~0;
60 _stencil_render_states [SRS_back_comparison_function] = M_none;
61 _stencil_render_states [SRS_back_stencil_fail_operation] = SO_keep;
62 _stencil_render_states [SRS_back_stencil_pass_z_fail_operation] = SO_keep;
63 _stencil_render_states [SRS_back_stencil_pass_z_pass_operation] = SO_keep;
65 _stencil_render_states [SRS_clear] = 0;
66 _stencil_render_states [SRS_clear_value] = 0;
75 return return_new(attrib);
93 PandaCompareFunc front_comparison_function,
94 StencilOperation stencil_fail_operation,
95 StencilOperation stencil_pass_z_fail_operation,
96 StencilOperation front_stencil_pass_z_pass_operation,
97 unsigned int reference,
98 unsigned int read_mask,
99 unsigned int write_mask)
104 front_comparison_function = M_none;
107 attrib->_stencil_render_states [SRS_front_comparison_function] = front_comparison_function;
108 attrib->_stencil_render_states [SRS_front_stencil_fail_operation] = stencil_fail_operation;
109 attrib->_stencil_render_states [SRS_front_stencil_pass_z_fail_operation] = stencil_pass_z_fail_operation;
110 attrib->_stencil_render_states [SRS_front_stencil_pass_z_pass_operation] = front_stencil_pass_z_pass_operation;
112 attrib->_stencil_render_states [SRS_reference] = reference;
113 attrib->_stencil_render_states [SRS_read_mask] = read_mask;
114 attrib->_stencil_render_states [SRS_write_mask] = write_mask;
116 attrib->_stencil_render_states [SRS_back_comparison_function] = M_none;
117 attrib->_stencil_render_states [SRS_back_stencil_fail_operation] = SO_keep;
118 attrib->_stencil_render_states [SRS_back_stencil_pass_z_fail_operation] = SO_keep;
119 attrib->_stencil_render_states [SRS_back_stencil_pass_z_pass_operation] = SO_keep;
121 return return_new(attrib);
131 PandaCompareFunc front_comparison_function,
132 StencilOperation stencil_fail_operation,
133 StencilOperation stencil_pass_z_fail_operation,
134 StencilOperation front_stencil_pass_z_pass_operation,
135 unsigned int reference,
136 unsigned int read_mask,
137 unsigned int write_mask,
138 PandaCompareFunc back_comparison_function,
139 StencilOperation back_stencil_fail_operation,
140 StencilOperation back_stencil_pass_z_fail_operation,
141 StencilOperation back_stencil_pass_z_pass_operation)
146 front_comparison_function = M_none;
150 back_comparison_function = M_none;
153 attrib->_stencil_render_states [SRS_front_comparison_function] = front_comparison_function;
154 attrib->_stencil_render_states [SRS_front_stencil_fail_operation] = stencil_fail_operation;
155 attrib->_stencil_render_states [SRS_front_stencil_pass_z_fail_operation] = stencil_pass_z_fail_operation;
156 attrib->_stencil_render_states [SRS_front_stencil_pass_z_pass_operation] = front_stencil_pass_z_pass_operation;
158 attrib->_stencil_render_states [SRS_reference] = reference;
159 attrib->_stencil_render_states [SRS_read_mask] = read_mask;
160 attrib->_stencil_render_states [SRS_write_mask] = write_mask;
162 attrib->_stencil_render_states [SRS_back_comparison_function] = back_comparison_function;
163 attrib->_stencil_render_states [SRS_back_stencil_fail_operation] = back_stencil_fail_operation;
164 attrib->_stencil_render_states [SRS_back_stencil_pass_z_fail_operation] = back_stencil_pass_z_fail_operation;
165 attrib->_stencil_render_states [SRS_back_stencil_pass_z_pass_operation] = back_stencil_pass_z_pass_operation;
167 return return_new(attrib);
176 PandaCompareFunc front_comparison_function,
177 StencilOperation stencil_fail_operation,
178 StencilOperation stencil_pass_z_fail_operation,
179 StencilOperation front_stencil_pass_z_pass_operation,
180 unsigned int reference,
181 unsigned int read_mask,
182 unsigned int write_mask,
184 unsigned int clear_value)
189 front_comparison_function = M_none;
192 attrib->_stencil_render_states [SRS_front_comparison_function] = front_comparison_function;
193 attrib->_stencil_render_states [SRS_front_stencil_fail_operation] = stencil_fail_operation;
194 attrib->_stencil_render_states [SRS_front_stencil_pass_z_fail_operation] = stencil_pass_z_fail_operation;
195 attrib->_stencil_render_states [SRS_front_stencil_pass_z_pass_operation] = front_stencil_pass_z_pass_operation;
197 attrib->_stencil_render_states [SRS_reference] = reference;
198 attrib->_stencil_render_states [SRS_read_mask] = read_mask;
199 attrib->_stencil_render_states [SRS_write_mask] = write_mask;
201 attrib->_stencil_render_states [SRS_back_comparison_function] = M_none;
202 attrib->_stencil_render_states [SRS_back_stencil_fail_operation] = SO_keep;
203 attrib->_stencil_render_states [SRS_back_stencil_pass_z_fail_operation] = SO_keep;
204 attrib->_stencil_render_states [SRS_back_stencil_pass_z_pass_operation] = SO_keep;
206 attrib->_stencil_render_states [SRS_clear] = clear;
207 attrib->_stencil_render_states [SRS_clear_value] = clear_value;
209 return return_new(attrib);
216 make_2_sided_with_clear(
219 PandaCompareFunc front_comparison_function,
220 StencilOperation stencil_fail_operation,
221 StencilOperation stencil_pass_z_fail_operation,
222 StencilOperation front_stencil_pass_z_pass_operation,
223 unsigned int reference,
224 unsigned int read_mask,
225 unsigned int write_mask,
226 PandaCompareFunc back_comparison_function,
227 StencilOperation back_stencil_fail_operation,
228 StencilOperation back_stencil_pass_z_fail_operation,
229 StencilOperation back_stencil_pass_z_pass_operation,
231 unsigned int clear_value)
236 front_comparison_function = M_none;
240 back_comparison_function = M_none;
243 attrib->_stencil_render_states [SRS_front_comparison_function] = front_comparison_function;
244 attrib->_stencil_render_states [SRS_front_stencil_fail_operation] = stencil_fail_operation;
245 attrib->_stencil_render_states [SRS_front_stencil_pass_z_fail_operation] = stencil_pass_z_fail_operation;
246 attrib->_stencil_render_states [SRS_front_stencil_pass_z_pass_operation] = front_stencil_pass_z_pass_operation;
248 attrib->_stencil_render_states [SRS_reference] = reference;
249 attrib->_stencil_render_states [SRS_read_mask] = read_mask;
250 attrib->_stencil_render_states [SRS_write_mask] = write_mask;
252 attrib->_stencil_render_states [SRS_back_comparison_function] = back_comparison_function;
253 attrib->_stencil_render_states [SRS_back_stencil_fail_operation] = back_stencil_fail_operation;
254 attrib->_stencil_render_states [SRS_back_stencil_pass_z_fail_operation] = back_stencil_pass_z_fail_operation;
255 attrib->_stencil_render_states [SRS_back_stencil_pass_z_pass_operation] = back_stencil_pass_z_pass_operation;
257 attrib->_stencil_render_states [SRS_clear] = clear;
258 attrib->_stencil_render_states [SRS_clear_value] = clear_value;
260 return return_new(attrib);
267 output(std::ostream &out)
const {
270 for (index = 0; index < SRS_total; index++) {
272 <<
"(" << stencil_render_state_name_array [index]
273 <<
", " << _stencil_render_states [index] <<
")";
296 int compare_result = 0;
298 for (index = 0; index < SRS_total; ++index) {
299 a = (int) sa -> _stencil_render_states[index];
300 b = (int) _stencil_render_states[index];
301 compare_result = (a - b);
302 if (compare_result) {
307 return compare_result;
316 size_t StencilAttrib::
317 get_hash_impl()
const {
319 for (
int index = 0; index < SRS_total; index++) {
342 dg.
add_int32(_stencil_render_states[SRS_front_comparison_function] != M_none);
343 dg.
add_int32(_stencil_render_states[SRS_back_comparison_function] != M_none);
345 for (
int index = 0; index < SRS_total; ++index) {
346 if (index == SRS_front_comparison_function ||
347 index == SRS_back_comparison_function) {
348 if (_stencil_render_states[index] == M_none) {
351 dg.
add_uint32(_stencil_render_states[index] - 1);
358 for (
int index = 0; index < SRS_total; ++index) {
376 attrib->fillin(scan, manager);
387 RenderAttrib::fillin(scan, manager);
390 unsigned int front_enable, back_enable;
394 for (
int index = 0; index < SRS_total; ++index) {
395 _stencil_render_states[index] = scan.
get_int32();
399 _stencil_render_states[SRS_front_comparison_function]++;
401 _stencil_render_states[SRS_front_comparison_function] = M_none;
405 _stencil_render_states[SRS_back_comparison_function]++;
407 _stencil_render_states[SRS_back_comparison_function] = M_none;
410 for (
int index = 0; index < SRS_total; ++index) {
411 _stencil_render_states[index] = scan.
get_uint32();