Panda3D
colorWriteAttrib.h
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file colorWriteAttrib.h
10  * @author drose
11  * @date 2002-03-04
12  */
13 
14 #ifndef COLORWRITEATTRIB_H
15 #define COLORWRITEATTRIB_H
16 
17 #include "pandabase.h"
18 
19 #include "renderAttrib.h"
20 
21 class FactoryParams;
22 
23 /**
24  * Enables or disables writing to the color buffer. This is primarily useful
25  * for certain special effects in which it is important to write to the depth
26  * buffer without affecting the color buffer.
27  */
28 class EXPCL_PANDA_PGRAPH ColorWriteAttrib : public RenderAttrib {
29 PUBLISHED:
30  enum Channels {
31  // By coincidence, these bits are the same as those for
32  // D3DCOLORWRITEENABLE_RED, _GREEN, _BLUE, and _ALPHA.
33  C_off = 0x000,
34  C_red = 0x001,
35  C_green = 0x002,
36  C_blue = 0x004,
37  C_rgb = 0x007, // == C_red | C_green | C_blue
38  C_alpha = 0x008,
39  C_all = 0x00f,
40  };
41 
42 private:
43  INLINE ColorWriteAttrib(unsigned int channels = C_all);
44 
45 PUBLISHED:
46  static CPT(RenderAttrib) make(unsigned int channels);
47  static CPT(RenderAttrib) make_default();
48 
49  INLINE unsigned int get_channels() const;
50 
51 PUBLISHED:
52  MAKE_PROPERTY(channels, get_channels);
53 
54 public:
55  virtual void output(std::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  MAKE_PROPERTY(class_slot, get_class_slot);
80 
81 public:
82  static TypeHandle get_class_type() {
83  return _type_handle;
84  }
85  static void init_type() {
86  RenderAttrib::init_type();
87  register_type(_type_handle, "ColorWriteAttrib",
88  RenderAttrib::get_class_type());
89  _attrib_slot = register_slot(_type_handle, 100, new ColorWriteAttrib);
90  }
91  virtual TypeHandle get_type() const {
92  return get_class_type();
93  }
94  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
95 
96 private:
97  static TypeHandle _type_handle;
98  static int _attrib_slot;
99 };
100 
101 #include "colorWriteAttrib.I"
102 
103 #endif
This is the base class for a number of render attributes (other than transform) that may be set on sc...
Definition: renderAttrib.h:51
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:110
Base class for objects that can be written to and read from Bam files.
Definition: typedWritable.h:35
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...
Definition: register_type.I:22
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
Definition: bamWriter.h:63
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
static int register_slot(TypeHandle type_handle, int sort, RenderAttrib *default_attrib)
Adds the indicated TypeHandle to the registry, if it is not there already, and returns a unique slot ...
Definition: renderAttrib.I:101
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
An instance of this class is passed to the Factory when requesting it to do its business and construc...
Definition: factoryParams.h:36
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:81
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition: datagram.h:38