25 int ColorBlendAttrib::_attrib_slot;
34 return return_new(attrib);
42 make(ColorBlendAttrib::Mode mode) {
46 return return_new(attrib);
55 make(ColorBlendAttrib::Mode mode,
56 ColorBlendAttrib::Operand a, ColorBlendAttrib::Operand b,
57 const LColor &color) {
59 return return_new(attrib);
68 make(ColorBlendAttrib::Mode mode,
69 ColorBlendAttrib::Operand a, ColorBlendAttrib::Operand b,
70 ColorBlendAttrib::Mode alpha_mode,
71 ColorBlendAttrib::Operand alpha_a, ColorBlendAttrib::Operand alpha_b,
72 const LColor &color) {
74 alpha_mode, alpha_a, alpha_b,
76 return return_new(attrib);
91 void ColorBlendAttrib::
92 output(ostream &out)
const {
93 out << get_type() <<
":" <<
get_mode();
117 int ColorBlendAttrib::
121 if (_mode != ta->_mode) {
122 return (
int)_mode - (int)ta->_mode;
126 return (
int)_a - (int)ta->_a;
130 return (
int)_b - (int)ta->_b;
133 return _color.compare_to(ta->_color);
142 size_t ColorBlendAttrib::
143 get_hash_impl()
const {
148 hash = _color.add_hash(hash);
179 _color.write_datagram(dg);
194 attrib->fillin(scan, manager);
203 void ColorBlendAttrib::
205 RenderAttrib::fillin(scan, manager);
217 if (_a >= O_incoming1_color) {
218 _a = (Operand)(_a + 4);
220 if (_b >= O_incoming1_color) {
221 _b = (Operand)(_b + 4);
230 _color.read_datagram(scan);
232 _involves_constant_color =
235 _involves_color_scale =
244 operator << (ostream &out, ColorBlendAttrib::Mode mode) {
246 case ColorBlendAttrib::M_none:
247 return out <<
"none";
249 case ColorBlendAttrib::M_add:
252 case ColorBlendAttrib::M_subtract:
253 return out <<
"subtract";
255 case ColorBlendAttrib::M_inv_subtract:
256 return out <<
"inv_subtract";
258 case ColorBlendAttrib::M_min:
261 case ColorBlendAttrib::M_max:
265 return out <<
"**invalid ColorBlendAttrib::Mode(" << (int)mode <<
")**";
272 operator << (ostream &out, ColorBlendAttrib::Operand operand) {
274 case ColorBlendAttrib::O_zero:
275 return out <<
"zero";
277 case ColorBlendAttrib::O_one:
280 case ColorBlendAttrib::O_incoming_color:
281 return out <<
"incoming_color";
283 case ColorBlendAttrib::O_one_minus_incoming_color:
284 return out <<
"one_minus_incoming_color";
286 case ColorBlendAttrib::O_fbuffer_color:
287 return out <<
"fbuffer_color";
289 case ColorBlendAttrib::O_one_minus_fbuffer_color:
290 return out <<
"one_minus_fbuffer_color";
292 case ColorBlendAttrib::O_incoming_alpha:
293 return out <<
"incoming_alpha";
295 case ColorBlendAttrib::O_one_minus_incoming_alpha:
296 return out <<
"one_minus_incoming_alpha";
298 case ColorBlendAttrib::O_fbuffer_alpha:
299 return out <<
"fbuffer_alpha";
301 case ColorBlendAttrib::O_one_minus_fbuffer_alpha:
302 return out <<
"one_minus_fbuffer_alpha";
304 case ColorBlendAttrib::O_constant_color:
305 return out <<
"constant_color";
307 case ColorBlendAttrib::O_one_minus_constant_color:
308 return out <<
"one_minus_constant_color";
310 case ColorBlendAttrib::O_constant_alpha:
311 return out <<
"constant_alpha";
313 case ColorBlendAttrib::O_one_minus_constant_alpha:
314 return out <<
"one_minus_constant_alpha";
316 case ColorBlendAttrib::O_incoming_color_saturate:
317 return out <<
"incoming_color_saturate";
319 case ColorBlendAttrib::O_color_scale:
320 return out <<
"color_scale";
322 case ColorBlendAttrib::O_one_minus_color_scale:
323 return out <<
"one_minus_color_scale";
325 case ColorBlendAttrib::O_alpha_scale:
326 return out <<
"alpha_scale";
328 case ColorBlendAttrib::O_one_minus_alpha_scale:
329 return out <<
"one_minus_alpha_scale";
331 case ColorBlendAttrib::O_incoming1_color:
332 return out <<
"incoming1_color";
334 case ColorBlendAttrib::O_one_minus_incoming1_color:
335 return out <<
"one_minus_incoming1_color";
337 case ColorBlendAttrib::O_incoming1_alpha:
338 return out <<
"incoming1_alpha";
340 case ColorBlendAttrib::O_one_minus_incoming1_alpha:
341 return out <<
"one_minus_incoming1_alpha";
344 return out <<
"**invalid ColorBlendAttrib::Operand(" << (int)operand <<
")**";
static void register_with_read_factory()
Tells the BamReader how to create objects of type ColorBlendAttrib.
This is the base class for a number of render attributes (other than transform) that may be set on sc...
uint8_t get_uint8()
Extracts an unsigned 8-bit integer.
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
get_color
Returns the constant color associated with the attrib.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
Base class for objects that can be written to and read from Bam files.
bool involves_color_scale() const
Returns true if the this attrib uses the color scale attrib, false otherwise.
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.
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
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 read.
get_operand_b
Returns the RGB multiplier for the second component.
static size_t add_hash(size_t start, const Key &key)
Adds the indicated key into a running hash.
get_mode
Returns the blending mode for the RGB channels.
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.
An instance of this class is passed to the Factory when requesting it to do its business and construc...
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.
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
This specifies how colors are blended into the frame buffer, for special effects.
static WritableFactory * get_factory()
Returns the global WritableFactory for generating TypedWritable objects.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void add_uint8(uint8_t value)
Adds an unsigned 8-bit integer to the datagram.
A class to retrieve the individual data elements previously stored in a Datagram.
get_operand_a
Returns the RGB multiplier for the first component.
TypeHandle is the identifier used to differentiate C++ class types.
CPT(RenderAttrib) ColorBlendAttrib
Constructs a new ColorBlendAttrib object that disables special-effect blending, allowing normal trans...
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
bool involves_constant_color() const
Returns true if the this attrib uses the constant color, false otherwise.