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();
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...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
Base class for objects that can be written to and read from Bam files.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
int get_file_minor_ver() const
Returns the minor version number of the Bam file currently being written.
CPT(RenderAttrib) StencilAttrib
Constructs a StencilAttrib that has stenciling turned off.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
int32_t get_int32()
Extracts a signed 32-bit integer.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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.
void add_uint32(uint32_t value)
Adds an unsigned 32-bit integer to the datagram.
static size_t add_hash(size_t start, const Key &key)
Adds the indicated key into a running hash.
void parse_params(const FactoryParams ¶ms, DatagramIterator &scan, BamReader *&manager)
Takes in a FactoryParams, passed from a WritableFactory into any TypedWritable's make function,...
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...
uint32_t get_uint32()
Extracts an unsigned 32-bit integer.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void register_factory(TypeHandle handle, CreateFunc *func, void *user_data=nullptr)
Registers a new kind of thing the Factory will be able to create.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void add_int32(int32_t value)
Adds a signed 32-bit integer to the datagram.
static WritableFactory * get_factory()
Returns the global WritableFactory for generating TypedWritable objects.
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.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.