Panda3D

colorWriteAttrib.h

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   virtual size_t get_hash_impl() const;
00060 
00061 private:
00062   int _channels;
00063 
00064 public:
00065   static void register_with_read_factory();
00066   virtual void write_datagram(BamWriter *manager, Datagram &dg);
00067 
00068 protected:
00069   static TypedWritable *make_from_bam(const FactoryParams &params);
00070   void fillin(DatagramIterator &scan, BamReader *manager);
00071 
00072 PUBLISHED:
00073   static int get_class_slot() {
00074     return _attrib_slot;
00075   }
00076   virtual int get_slot() const {
00077     return get_class_slot();
00078   }
00079   
00080 public:
00081   static TypeHandle get_class_type() {
00082     return _type_handle;
00083   }
00084   static void init_type() {
00085     RenderAttrib::init_type();
00086     register_type(_type_handle, "ColorWriteAttrib",
00087                   RenderAttrib::get_class_type());
00088     _attrib_slot = register_slot(_type_handle, 100, make_default);
00089   }
00090   virtual TypeHandle get_type() const {
00091     return get_class_type();
00092   }
00093   virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00094 
00095 private:
00096   static TypeHandle _type_handle;
00097   static int _attrib_slot;
00098 };
00099 
00100 #include "colorWriteAttrib.I"
00101 
00102 #endif
00103 
 All Classes Functions Variables Enumerations