Panda3D
 All Classes Functions Variables Enumerations
colorWriteAttrib.h
1 // Filename: colorWriteAttrib.h
2 // Created by: drose (04Mar02)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef COLORWRITEATTRIB_H
16 #define COLORWRITEATTRIB_H
17 
18 #include "pandabase.h"
19 
20 #include "renderAttrib.h"
21 
22 class FactoryParams;
23 
24 ////////////////////////////////////////////////////////////////////
25 // Class : ColorWriteAttrib
26 // Description : Enables or disables writing to the color buffer.
27 // This is primarily useful for certain special effects
28 // in which it is important to write to the depth buffer
29 // without affecting the color buffer.
30 ////////////////////////////////////////////////////////////////////
31 class EXPCL_PANDA_PGRAPH ColorWriteAttrib : public RenderAttrib {
32 PUBLISHED:
33  enum Channels {
34  // By coincidence, these bits are the same as those for
35  // D3DCOLORWRITEENABLE_RED, _GREEN, _BLUE, and _ALPHA.
36  C_off = 0x000,
37  C_red = 0x001,
38  C_green = 0x002,
39  C_blue = 0x004,
40  C_rgb = 0x007, // == C_red | C_green | C_blue
41  C_alpha = 0x008,
42  C_all = 0x00f,
43  };
44 
45 private:
46  INLINE ColorWriteAttrib(unsigned int channels = C_all);
47 
48 PUBLISHED:
49  static CPT(RenderAttrib) make(unsigned int channels);
50  static CPT(RenderAttrib) make_default();
51 
52  INLINE unsigned int get_channels() const;
53 
54 public:
55  virtual void output(ostream &out) const;
56 
57 protected:
58  virtual int compare_to_impl(const RenderAttrib *other) const;
59  virtual size_t get_hash_impl() const;
60 
61 private:
62  int _channels;
63 
64 public:
65  static void register_with_read_factory();
66  virtual void write_datagram(BamWriter *manager, Datagram &dg);
67 
68 protected:
69  static TypedWritable *make_from_bam(const FactoryParams &params);
70  void fillin(DatagramIterator &scan, BamReader *manager);
71 
72 PUBLISHED:
73  static int get_class_slot() {
74  return _attrib_slot;
75  }
76  virtual int get_slot() const {
77  return get_class_slot();
78  }
79 
80 public:
81  static TypeHandle get_class_type() {
82  return _type_handle;
83  }
84  static void init_type() {
85  RenderAttrib::init_type();
86  register_type(_type_handle, "ColorWriteAttrib",
87  RenderAttrib::get_class_type());
88  _attrib_slot = register_slot(_type_handle, 100, make_default);
89  }
90  virtual TypeHandle get_type() const {
91  return get_class_type();
92  }
93  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
94 
95 private:
96  static TypeHandle _type_handle;
97  static int _attrib_slot;
98 };
99 
100 #include "colorWriteAttrib.I"
101 
102 #endif
103 
static int register_slot(TypeHandle type_handle, int sort, RenderAttribRegistry::MakeDefaultFunc *make_default_func)
Adds the indicated TypeHandle to the registry, if it is not there already, and returns a unique slot ...
Definition: renderAttrib.I:163
This is the base class for a number of render attributes (other than transform) that may be set on sc...
Definition: renderAttrib.h:60
Enables or disables writing to the color buffer.
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Definition: bamReader.h:122
Base class for objects that can be written to and read from Bam files.
Definition: typedWritable.h:37
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
Definition: bamWriter.h:73
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...
Definition: factoryParams.h:40
A class to retrieve the individual data elements previously stored in a Datagram. ...
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition: datagram.h:43