00001 // Filename: colorBlendAttrib.h 00002 // Created by: drose (29Mar02) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved 00008 // 00009 // All use of this software is subject to the terms of the Panda 3d 00010 // Software license. You should have received a copy of this license 00011 // along with this source code; you will also find a current copy of 00012 // the license at http://www.panda3d.org/license.txt . 00013 // 00014 // To contact the maintainers of this program write to 00015 // panda3d@yahoogroups.com . 00016 // 00017 //////////////////////////////////////////////////////////////////// 00018 00019 #ifndef COLORBLENDATTRIB_H 00020 #define COLORBLENDATTRIB_H 00021 00022 #include "pandabase.h" 00023 00024 #include "renderAttrib.h" 00025 00026 //////////////////////////////////////////////////////////////////// 00027 // Class : ColorBlendAttrib 00028 // Description : This specifies how colors are blended into the frame 00029 // buffer, for special effects. This overrides 00030 // transparency if transparency is also specified. 00031 //////////////////////////////////////////////////////////////////// 00032 class EXPCL_PANDA ColorBlendAttrib : public RenderAttrib { 00033 PUBLISHED: 00034 enum Mode { 00035 M_none, // Blending is disabled 00036 M_multiply, // color already in fbuffer * incoming color 00037 M_add, // color already in fbuffer + incoming color 00038 M_multiply_add, // color already in fbuffer * incoming color + 00039 // color already in fbuffer 00040 }; 00041 00042 private: 00043 INLINE ColorBlendAttrib(Mode mode = M_none); 00044 00045 PUBLISHED: 00046 static CPT(RenderAttrib) make(Mode mode); 00047 00048 INLINE Mode get_mode() const; 00049 00050 public: 00051 virtual void issue(GraphicsStateGuardianBase *gsg) const; 00052 virtual void output(ostream &out) const; 00053 00054 protected: 00055 virtual int compare_to_impl(const RenderAttrib *other) const; 00056 virtual RenderAttrib *make_default_impl() const; 00057 00058 private: 00059 Mode _mode; 00060 00061 public: 00062 static void register_with_read_factory(); 00063 virtual void write_datagram(BamWriter *manager, Datagram &dg); 00064 00065 protected: 00066 static TypedWritable *make_from_bam(const FactoryParams ¶ms); 00067 void fillin(DatagramIterator &scan, BamReader *manager); 00068 00069 public: 00070 static TypeHandle get_class_type() { 00071 return _type_handle; 00072 } 00073 static void init_type() { 00074 RenderAttrib::init_type(); 00075 register_type(_type_handle, "ColorBlendAttrib", 00076 RenderAttrib::get_class_type()); 00077 } 00078 virtual TypeHandle get_type() const { 00079 return get_class_type(); 00080 } 00081 virtual TypeHandle force_init_type() {init_type(); return get_class_type();} 00082 00083 private: 00084 static TypeHandle _type_handle; 00085 }; 00086 00087 #include "colorBlendAttrib.I" 00088 00089 #endif 00090