Panda3D
 All Classes Functions Variables Enumerations
renderModeAttrib.h
1 // Filename: renderModeAttrib.h
2 // Created by: drose (14Mar02)
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 RENDERMODEATTRIB_H
16 #define RENDERMODEATTRIB_H
17 
18 #include "pandabase.h"
19 
20 #include "renderAttrib.h"
21 #include "geom.h"
22 
23 class FactoryParams;
24 
25 ////////////////////////////////////////////////////////////////////
26 // Class : RenderModeAttrib
27 // Description : Specifies how polygons are to be drawn.
28 ////////////////////////////////////////////////////////////////////
29 class EXPCL_PANDA_PGRAPH RenderModeAttrib : public RenderAttrib {
30 PUBLISHED:
31  enum Mode {
32  M_unchanged,
33 
34  // Normal, filled polygons.
35  M_filled,
36 
37  // Wireframe polygons, possibly with thickness.
38  M_wireframe,
39 
40  // Points at vertices only, possibly with thickness and/or
41  // perspective sizing.
42  M_point,
43 
44  // Filled polygons, without any particular emphasis on perspective
45  // correctness (a particularly useful designation for software
46  // rendering sprites).
47  M_filled_flat,
48 
49  // Filled polygons with wireframe rendered in front.
50  // The wireframe is given a solid color.
51  M_filled_wireframe
52  };
53 
54 private:
55  INLINE RenderModeAttrib(Mode mode, PN_stdfloat thickness, bool perspective,
56  const LColor &wireframe_color = LColor::zero());
57 
58 PUBLISHED:
59  static CPT(RenderAttrib) make(Mode mode, PN_stdfloat thickness = 1.0f,
60  bool perspective = false,
61  const LColor &wireframe_color = LColor::zero());
62  static CPT(RenderAttrib) make_default();
63 
64  INLINE Mode get_mode() const;
65  INLINE PN_stdfloat get_thickness() const;
66  INLINE bool get_perspective() const;
67  INLINE const LColor &get_wireframe_color() const;
68 
69  INLINE int get_geom_rendering(int geom_rendering) const;
70 
71 public:
72  virtual void output(ostream &out) const;
73 
74 protected:
75  virtual int compare_to_impl(const RenderAttrib *other) const;
76  virtual size_t get_hash_impl() const;
77  virtual CPT(RenderAttrib) compose_impl(const RenderAttrib *other) const;
78 
79 private:
80  Mode _mode;
81  PN_stdfloat _thickness;
82  bool _perspective;
83  LColor _wireframe_color;
84 
85 PUBLISHED:
86  static int get_class_slot() {
87  return _attrib_slot;
88  }
89  virtual int get_slot() const {
90  return get_class_slot();
91  }
92 
93 public:
94  static void register_with_read_factory();
95  virtual void write_datagram(BamWriter *manager, Datagram &dg);
96 
97 protected:
98  static TypedWritable *make_from_bam(const FactoryParams &params);
99  void fillin(DatagramIterator &scan, BamReader *manager);
100 
101 public:
102  static TypeHandle get_class_type() {
103  return _type_handle;
104  }
105  static void init_type() {
106  RenderAttrib::init_type();
107  register_type(_type_handle, "RenderModeAttrib",
108  RenderAttrib::get_class_type());
109  _attrib_slot = register_slot(_type_handle, 100, make_default);
110  }
111  virtual TypeHandle get_type() const {
112  return get_class_type();
113  }
114  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
115 
116 private:
117  static TypeHandle _type_handle;
118  static int _attrib_slot;
119 };
120 
121 #include "renderModeAttrib.I"
122 
123 #endif
124 
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
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 is the base class for all three-component vectors and points.
Definition: lvecBase4.h:111
Specifies how polygons are to be drawn.
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
static const LVecBase4f & zero()
Returns a zero-length vector.
Definition: lvecBase4.h:492