Panda3D
auxBitplaneAttrib.h
1 // Filename: auxBitplaneAttrib.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 AUXBITPLANEATTRIB_H
16 #define AUXBITPLANEATTRIB_H
17 
18 #include "pandabase.h"
19 #include "renderAttrib.h"
20 
21 class FactoryParams;
22 
23 ////////////////////////////////////////////////////////////////////
24 // Class : AuxBitplaneAttrib
25 // Description : Modern frame buffers can have 'aux' bitplanes, which
26 // are additional bitplanes above and beyond the
27 // standard depth and color. This attrib controls what
28 // gets rendered into those additional bitplanes. It
29 // can also affect what goes into the alpha channel
30 // of the primary color buffer.
31 //
32 // ABO_glow: copy the glow map into the alpha channel
33 // of the primary frame buffer. If there is no glow
34 // map, set it to zero. Caveat: it is not
35 // possible to write glow or depth values to the
36 // framebuffer alpha channel at the same time as using
37 // alpha blending or alpha testing. Any attempt to use
38 // transparency, blending, or alpha testing will cause
39 // this flag to be overridden.
40 //
41 // ABO_aux_normal: put the camera-space normal into
42 // the into the R,G components of the first auxiliary
43 // bitplane.
44 //
45 // ABO_aux_modelz: put the clip-space Z coordinate of
46 // the center of the model (after perspective divide)
47 // into the B channel of the first auxiliary bitplane.
48 //
49 // ABO_aux_glow: put a copy of the glow map into the
50 // alpha channel of the first auxiliary bitplane.
51 // If there is no glow map, set it to zero.
52 //
53 // AuxBitplaneAttrib is relevant only when shader
54 // generation is enabled. Otherwise, it has no effect.
55 //
56 ////////////////////////////////////////////////////////////////////
57 class EXPCL_PANDA_PGRAPH AuxBitplaneAttrib : public RenderAttrib {
58 private:
59  INLINE AuxBitplaneAttrib(int outputs);
60 
61 PUBLISHED:
62  enum AuxBitplaneOutput {
63  ABO_glow = 1,
64 
65  ABO_aux_normal = 2,
66  ABO_aux_glow = 4,
67  };
68  static CPT(RenderAttrib) make();
69  static CPT(RenderAttrib) make(int outputs);
70  static CPT(RenderAttrib) make_default();
71 
72  INLINE int get_outputs() const;
73 
74 public:
75  virtual void output(ostream &out) const;
76 
77 protected:
78  virtual int compare_to_impl(const RenderAttrib *other) const;
79  virtual size_t get_hash_impl() const;
80  virtual CPT(RenderAttrib) get_auto_shader_attrib_impl(const RenderState *state) const;
81 
82 private:
83  int _outputs;
84 
85  static CPT(RenderAttrib) _default;
86 
87 PUBLISHED:
88  static int get_class_slot() {
89  return _attrib_slot;
90  }
91  virtual int get_slot() const {
92  return get_class_slot();
93  }
94 
95 public:
96  static void register_with_read_factory();
97  virtual void write_datagram(BamWriter *manager, Datagram &dg);
98 
99 protected:
100  static TypedWritable *make_from_bam(const FactoryParams &params);
101  void fillin(DatagramIterator &scan, BamReader *manager);
102 
103 public:
104  static TypeHandle get_class_type() {
105  return _type_handle;
106  }
107  static void init_type() {
108  RenderAttrib::init_type();
109  register_type(_type_handle, "AuxBitplaneAttrib",
110  RenderAttrib::get_class_type());
111  _attrib_slot = register_slot(_type_handle, 100, make_default);
112  }
113  virtual TypeHandle get_type() const {
114  return get_class_type();
115  }
116  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
117 
118 private:
119  static TypeHandle _type_handle;
120  static int _attrib_slot;
121 };
122 
123 #include "auxBitplaneAttrib.I"
124 
125 #endif
126 
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
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
Modern frame buffers can have 'aux' bitplanes, which are additional bitplanes above and beyond the st...
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
This represents a unique collection of RenderAttrib objects that correspond to a particular renderabl...
Definition: renderState.h:53
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