Panda3D
|
00001 // Filename: colorWriteAttrib.h 00002 // Created by: drose (04Mar02) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 #ifndef COLORWRITEATTRIB_H 00016 #define COLORWRITEATTRIB_H 00017 00018 #include "pandabase.h" 00019 00020 #include "renderAttrib.h" 00021 00022 class FactoryParams; 00023 00024 //////////////////////////////////////////////////////////////////// 00025 // Class : ColorWriteAttrib 00026 // Description : Enables or disables writing to the color buffer. 00027 // This is primarily useful for certain special effects 00028 // in which it is important to write to the depth buffer 00029 // without affecting the color buffer. 00030 //////////////////////////////////////////////////////////////////// 00031 class EXPCL_PANDA_PGRAPH ColorWriteAttrib : public RenderAttrib { 00032 PUBLISHED: 00033 enum Channels { 00034 // By coincidence, these bits are the same as those for 00035 // D3DCOLORWRITEENABLE_RED, _GREEN, _BLUE, and _ALPHA. 00036 C_off = 0x000, 00037 C_red = 0x001, 00038 C_green = 0x002, 00039 C_blue = 0x004, 00040 C_rgb = 0x007, // == C_red | C_green | C_blue 00041 C_alpha = 0x008, 00042 C_all = 0x00f, 00043 }; 00044 00045 private: 00046 INLINE ColorWriteAttrib(unsigned int channels = C_all); 00047 00048 PUBLISHED: 00049 static CPT(RenderAttrib) make(unsigned int channels); 00050 static CPT(RenderAttrib) make_default(); 00051 00052 INLINE unsigned int get_channels() const; 00053 00054 public: 00055 virtual void output(ostream &out) const; 00056 00057 protected: 00058 virtual int compare_to_impl(const RenderAttrib *other) const; 00059 00060 private: 00061 int _channels; 00062 00063 public: 00064 static void register_with_read_factory(); 00065 virtual void write_datagram(BamWriter *manager, Datagram &dg); 00066 00067 protected: 00068 static TypedWritable *make_from_bam(const FactoryParams ¶ms); 00069 void fillin(DatagramIterator &scan, BamReader *manager); 00070 00071 PUBLISHED: 00072 static int get_class_slot() { 00073 return _attrib_slot; 00074 } 00075 virtual int get_slot() const { 00076 return get_class_slot(); 00077 } 00078 00079 public: 00080 static TypeHandle get_class_type() { 00081 return _type_handle; 00082 } 00083 static void init_type() { 00084 RenderAttrib::init_type(); 00085 register_type(_type_handle, "ColorWriteAttrib", 00086 RenderAttrib::get_class_type()); 00087 _attrib_slot = register_slot(_type_handle, 100, make_default); 00088 } 00089 virtual TypeHandle get_type() const { 00090 return get_class_type(); 00091 } 00092 virtual TypeHandle force_init_type() {init_type(); return get_class_type();} 00093 00094 private: 00095 static TypeHandle _type_handle; 00096 static int _attrib_slot; 00097 }; 00098 00099 #include "colorWriteAttrib.I" 00100 00101 #endif 00102