15 #include "stencilAttrib.h" 16 #include "graphicsStateGuardianBase.h" 18 #include "bamReader.h" 19 #include "bamWriter.h" 21 #include "datagramIterator.h" 24 int StencilAttrib::_attrib_slot;
26 const char *StencilAttrib::
27 stencil_render_state_name_array[StencilAttrib::SRS_total] =
29 "SRS_front_comparison_function",
30 "SRS_front_stencil_fail_operation",
31 "SRS_front_stencil_pass_z_fail_operation",
32 "SRS_front_stencil_pass_z_pass_operation",
38 "SRS_back_comparison_function",
39 "SRS_back_stencil_fail_operation",
40 "SRS_back_stencil_pass_z_fail_operation",
41 "SRS_back_stencil_pass_z_pass_operation",
55 _stencil_render_states [SRS_front_comparison_function] = M_none;
56 _stencil_render_states [SRS_front_stencil_fail_operation] = SO_keep;
57 _stencil_render_states [SRS_front_stencil_pass_z_fail_operation] = SO_keep;
58 _stencil_render_states [SRS_front_stencil_pass_z_pass_operation] = SO_keep;
60 _stencil_render_states [SRS_reference] = 0;
61 _stencil_render_states [SRS_read_mask] = ~0;
62 _stencil_render_states [SRS_write_mask] = ~0;
64 _stencil_render_states [SRS_back_comparison_function] = M_none;
65 _stencil_render_states [SRS_back_stencil_fail_operation] = SO_keep;
66 _stencil_render_states [SRS_back_stencil_pass_z_fail_operation] = SO_keep;
67 _stencil_render_states [SRS_back_stencil_pass_z_pass_operation] = SO_keep;
69 _stencil_render_states [SRS_clear] = 0;
70 _stencil_render_states [SRS_clear_value] = 0;
82 return return_new(attrib);
105 PandaCompareFunc front_comparison_function,
106 StencilOperation stencil_fail_operation,
107 StencilOperation stencil_pass_z_fail_operation,
108 StencilOperation front_stencil_pass_z_pass_operation,
109 unsigned int reference,
110 unsigned int read_mask,
111 unsigned int write_mask)
116 front_comparison_function = M_none;
119 attrib->_stencil_render_states [SRS_front_comparison_function] = front_comparison_function;
120 attrib->_stencil_render_states [SRS_front_stencil_fail_operation] = stencil_fail_operation;
121 attrib->_stencil_render_states [SRS_front_stencil_pass_z_fail_operation] = stencil_pass_z_fail_operation;
122 attrib->_stencil_render_states [SRS_front_stencil_pass_z_pass_operation] = front_stencil_pass_z_pass_operation;
124 attrib->_stencil_render_states [SRS_reference] = reference;
125 attrib->_stencil_render_states [SRS_read_mask] = read_mask;
126 attrib->_stencil_render_states [SRS_write_mask] = write_mask;
128 attrib->_stencil_render_states [SRS_back_comparison_function] = M_none;
129 attrib->_stencil_render_states [SRS_back_stencil_fail_operation] = SO_keep;
130 attrib->_stencil_render_states [SRS_back_stencil_pass_z_fail_operation] = SO_keep;
131 attrib->_stencil_render_states [SRS_back_stencil_pass_z_pass_operation] = SO_keep;
133 return return_new(attrib);
145 PandaCompareFunc front_comparison_function,
146 StencilOperation stencil_fail_operation,
147 StencilOperation stencil_pass_z_fail_operation,
148 StencilOperation front_stencil_pass_z_pass_operation,
149 unsigned int reference,
150 unsigned int read_mask,
151 unsigned int write_mask,
152 PandaCompareFunc back_comparison_function,
153 StencilOperation back_stencil_fail_operation,
154 StencilOperation back_stencil_pass_z_fail_operation,
155 StencilOperation back_stencil_pass_z_pass_operation)
160 front_comparison_function = M_none;
164 back_comparison_function = M_none;
167 attrib->_stencil_render_states [SRS_front_comparison_function] = front_comparison_function;
168 attrib->_stencil_render_states [SRS_front_stencil_fail_operation] = stencil_fail_operation;
169 attrib->_stencil_render_states [SRS_front_stencil_pass_z_fail_operation] = stencil_pass_z_fail_operation;
170 attrib->_stencil_render_states [SRS_front_stencil_pass_z_pass_operation] = front_stencil_pass_z_pass_operation;
172 attrib->_stencil_render_states [SRS_reference] = reference;
173 attrib->_stencil_render_states [SRS_read_mask] = read_mask;
174 attrib->_stencil_render_states [SRS_write_mask] = write_mask;
176 attrib->_stencil_render_states [SRS_back_comparison_function] = back_comparison_function;
177 attrib->_stencil_render_states [SRS_back_stencil_fail_operation] = back_stencil_fail_operation;
178 attrib->_stencil_render_states [SRS_back_stencil_pass_z_fail_operation] = back_stencil_pass_z_fail_operation;
179 attrib->_stencil_render_states [SRS_back_stencil_pass_z_pass_operation] = back_stencil_pass_z_pass_operation;
181 return return_new(attrib);
192 PandaCompareFunc front_comparison_function,
193 StencilOperation stencil_fail_operation,
194 StencilOperation stencil_pass_z_fail_operation,
195 StencilOperation front_stencil_pass_z_pass_operation,
196 unsigned int reference,
197 unsigned int read_mask,
198 unsigned int write_mask,
200 unsigned int clear_value)
205 front_comparison_function = M_none;
208 attrib->_stencil_render_states [SRS_front_comparison_function] = front_comparison_function;
209 attrib->_stencil_render_states [SRS_front_stencil_fail_operation] = stencil_fail_operation;
210 attrib->_stencil_render_states [SRS_front_stencil_pass_z_fail_operation] = stencil_pass_z_fail_operation;
211 attrib->_stencil_render_states [SRS_front_stencil_pass_z_pass_operation] = front_stencil_pass_z_pass_operation;
213 attrib->_stencil_render_states [SRS_reference] = reference;
214 attrib->_stencil_render_states [SRS_read_mask] = read_mask;
215 attrib->_stencil_render_states [SRS_write_mask] = write_mask;
217 attrib->_stencil_render_states [SRS_back_comparison_function] = M_none;
218 attrib->_stencil_render_states [SRS_back_stencil_fail_operation] = SO_keep;
219 attrib->_stencil_render_states [SRS_back_stencil_pass_z_fail_operation] = SO_keep;
220 attrib->_stencil_render_states [SRS_back_stencil_pass_z_pass_operation] = SO_keep;
222 attrib->_stencil_render_states [SRS_clear] = clear;
223 attrib->_stencil_render_states [SRS_clear_value] = clear_value;
225 return return_new(attrib);
234 make_2_sided_with_clear(
237 PandaCompareFunc front_comparison_function,
238 StencilOperation stencil_fail_operation,
239 StencilOperation stencil_pass_z_fail_operation,
240 StencilOperation front_stencil_pass_z_pass_operation,
241 unsigned int reference,
242 unsigned int read_mask,
243 unsigned int write_mask,
244 PandaCompareFunc back_comparison_function,
245 StencilOperation back_stencil_fail_operation,
246 StencilOperation back_stencil_pass_z_fail_operation,
247 StencilOperation back_stencil_pass_z_pass_operation,
249 unsigned int clear_value)
254 front_comparison_function = M_none;
258 back_comparison_function = M_none;
261 attrib->_stencil_render_states [SRS_front_comparison_function] = front_comparison_function;
262 attrib->_stencil_render_states [SRS_front_stencil_fail_operation] = stencil_fail_operation;
263 attrib->_stencil_render_states [SRS_front_stencil_pass_z_fail_operation] = stencil_pass_z_fail_operation;
264 attrib->_stencil_render_states [SRS_front_stencil_pass_z_pass_operation] = front_stencil_pass_z_pass_operation;
266 attrib->_stencil_render_states [SRS_reference] = reference;
267 attrib->_stencil_render_states [SRS_read_mask] = read_mask;
268 attrib->_stencil_render_states [SRS_write_mask] = write_mask;
270 attrib->_stencil_render_states [SRS_back_comparison_function] = back_comparison_function;
271 attrib->_stencil_render_states [SRS_back_stencil_fail_operation] = back_stencil_fail_operation;
272 attrib->_stencil_render_states [SRS_back_stencil_pass_z_fail_operation] = back_stencil_pass_z_fail_operation;
273 attrib->_stencil_render_states [SRS_back_stencil_pass_z_pass_operation] = back_stencil_pass_z_pass_operation;
275 attrib->_stencil_render_states [SRS_clear] = clear;
276 attrib->_stencil_render_states [SRS_clear_value] = clear_value;
278 return return_new(attrib);
287 output(ostream &out)
const {
290 for (index = 0; index < SRS_total; index++) {
292 <<
"(" << stencil_render_state_name_array [index]
293 <<
", " << _stencil_render_states [index] <<
")";
315 DCAST_INTO_R(sa, other, 0);
320 int compare_result = 0;
322 for (index = 0; index < SRS_total; ++index) {
323 a = (int) sa -> _stencil_render_states[index];
324 b = (int) _stencil_render_states[index];
325 compare_result = (a - b);
326 if (compare_result) {
331 return compare_result;
344 size_t StencilAttrib::
345 get_hash_impl()
const {
347 for (
int index = 0; index < SRS_total; index++) {
374 for (
int index = 0; index < SRS_total; ++index) {
393 parse_params(params, scan, manager);
394 attrib->fillin(scan, manager);
408 RenderAttrib::fillin(scan, manager);
411 unsigned int front_enable, back_enable;
415 for (
int index = 0; index < SRS_total; ++index) {
416 _stencil_render_states[index] = scan.
get_int32();
420 _stencil_render_states[SRS_front_comparison_function]++;
422 _stencil_render_states[SRS_front_comparison_function] = M_none;
426 _stencil_render_states[SRS_back_comparison_function]++;
428 _stencil_render_states[SRS_back_comparison_function] = M_none;
431 for (
int index = 0; index < SRS_total; ++index) {
432 _stencil_render_states[index] = scan.
get_uint32();
This is the base class for a number of render attributes (other than transform) that may be set on sc...
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Base class for objects that can be written to and read from Bam files.
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
PN_int32 get_int32()
Extracts a signed 32-bit integer.
PN_uint32 get_uint32()
Extracts an unsigned 32-bit integer.
static void register_with_read_factory()
Tells the BamReader how to create objects of type StencilAttrib.
int get_file_minor_ver() const
Returns the minor version number of the Bam file currently being read.
static size_t add_hash(size_t start, const Key &key)
Adds the indicated key into a running hash.
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
A StencilAttrib is a collection of all stencil render states.
An instance of this class is passed to the Factory when requesting it to do its business and construc...
void register_factory(TypeHandle handle, CreateFunc *func)
Registers a new kind of thing the Factory will be able to create.
static WritableFactory * get_factory()
Returns the global WritableFactory for generating TypedWritable objects.
void add_uint32(PN_uint32 value)
Adds an unsigned 32-bit integer to the datagram.
A class to retrieve the individual data elements previously stored in a Datagram. ...
TypeHandle is the identifier used to differentiate C++ class types.
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.