00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef COLORBLENDATTRIB_H
00016 #define COLORBLENDATTRIB_H
00017
00018 #include "pandabase.h"
00019 #include "luse.h"
00020 #include "renderAttrib.h"
00021
00022 class FactoryParams;
00023
00024
00025
00026
00027
00028
00029
00030 class EXPCL_PANDA_PGRAPH ColorBlendAttrib : public RenderAttrib {
00031 PUBLISHED:
00032 enum Mode {
00033 M_none,
00034 M_add,
00035 M_subtract,
00036 M_inv_subtract,
00037 M_min,
00038 M_max
00039 };
00040
00041 enum Operand {
00042 O_zero,
00043 O_one,
00044 O_incoming_color,
00045 O_one_minus_incoming_color,
00046 O_fbuffer_color,
00047 O_one_minus_fbuffer_color,
00048 O_incoming_alpha,
00049 O_one_minus_incoming_alpha,
00050 O_fbuffer_alpha,
00051 O_one_minus_fbuffer_alpha,
00052 O_constant_color,
00053 O_one_minus_constant_color,
00054 O_constant_alpha,
00055 O_one_minus_constant_alpha,
00056 O_incoming_color_saturate,
00057
00058
00059
00060
00061
00062
00063
00064 O_color_scale,
00065 O_one_minus_color_scale,
00066 O_alpha_scale,
00067 O_one_minus_alpha_scale,
00068 };
00069
00070 private:
00071 INLINE ColorBlendAttrib();
00072 INLINE ColorBlendAttrib(Mode mode, Operand a, Operand b,
00073 const LColor &color);
00074
00075 PUBLISHED:
00076 static CPT(RenderAttrib) make_off();
00077 static CPT(RenderAttrib) make(Mode mode);
00078 static CPT(RenderAttrib) make(Mode mode, Operand a, Operand b,
00079 const LColor &color = LColor::zero());
00080 static CPT(RenderAttrib) make_default();
00081
00082 INLINE Mode get_mode() const;
00083 INLINE Operand get_operand_a() const;
00084 INLINE Operand get_operand_b() const;
00085 INLINE LColor get_color() const;
00086
00087 INLINE bool involves_constant_color() const;
00088 INLINE bool involves_color_scale() const;
00089
00090 INLINE static bool involves_constant_color(Operand operand);
00091 INLINE static bool involves_color_scale(Operand operand);
00092
00093 public:
00094 virtual void output(ostream &out) const;
00095
00096 protected:
00097 virtual int compare_to_impl(const RenderAttrib *other) const;
00098 virtual size_t get_hash_impl() const;
00099 virtual CPT(RenderAttrib) get_auto_shader_attrib_impl(const RenderState *state) const;
00100
00101 private:
00102 Mode _mode;
00103 Operand _a, _b;
00104 LColor _color;
00105 bool _involves_constant_color;
00106 bool _involves_color_scale;
00107
00108 PUBLISHED:
00109 static int get_class_slot() {
00110 return _attrib_slot;
00111 }
00112 virtual int get_slot() const {
00113 return get_class_slot();
00114 }
00115
00116 public:
00117 static void register_with_read_factory();
00118 virtual void write_datagram(BamWriter *manager, Datagram &dg);
00119
00120 protected:
00121 static TypedWritable *make_from_bam(const FactoryParams ¶ms);
00122 void fillin(DatagramIterator &scan, BamReader *manager);
00123
00124 public:
00125 static TypeHandle get_class_type() {
00126 return _type_handle;
00127 }
00128 static void init_type() {
00129 RenderAttrib::init_type();
00130 register_type(_type_handle, "ColorBlendAttrib",
00131 RenderAttrib::get_class_type());
00132 _attrib_slot = register_slot(_type_handle, 100, make_default);
00133 }
00134 virtual TypeHandle get_type() const {
00135 return get_class_type();
00136 }
00137 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00138
00139 private:
00140 static TypeHandle _type_handle;
00141 static int _attrib_slot;
00142 };
00143
00144 ostream &operator << (ostream &out, ColorBlendAttrib::Mode mode);
00145 ostream &operator << (ostream &out, ColorBlendAttrib::Operand operand);
00146
00147 #include "colorBlendAttrib.I"
00148
00149 #endif
00150