Panda3D
renderModeAttrib.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 renderModeAttrib.h
10  * @author drose
11  * @date 2002-03-14
12  */
13 
14 #ifndef RENDERMODEATTRIB_H
15 #define RENDERMODEATTRIB_H
16 
17 #include "pandabase.h"
18 
19 #include "renderAttrib.h"
20 #include "geom.h"
21 
22 class FactoryParams;
23 
24 /**
25  * Specifies how polygons are to be drawn.
26  */
27 class EXPCL_PANDA_PGRAPH RenderModeAttrib : public RenderAttrib {
28 PUBLISHED:
29  enum Mode {
30  M_unchanged,
31 
32  // Normal, filled polygons.
33  M_filled,
34 
35  // Wireframe polygons, possibly with thickness.
36  M_wireframe,
37 
38  // Points at vertices only, possibly with thickness andor perspective
39  // sizing.
40  M_point,
41 
42  // Filled polygons, without any particular emphasis on perspective
43  // correctness (a particularly useful designation for software rendering
44  // sprites).
45  M_filled_flat,
46 
47  // Filled polygons with wireframe rendered in front. The wireframe is
48  // given a solid color.
49  M_filled_wireframe
50  };
51 
52 private:
53  INLINE RenderModeAttrib(Mode mode, PN_stdfloat thickness, bool perspective,
54  const LColor &wireframe_color = LColor::zero());
55 
56 PUBLISHED:
57  static CPT(RenderAttrib) make(Mode mode, PN_stdfloat thickness = 1.0f,
58  bool perspective = false,
59  const LColor &wireframe_color = LColor::zero());
60  static CPT(RenderAttrib) make_default();
61 
62  INLINE Mode get_mode() const;
63  INLINE PN_stdfloat get_thickness() const;
64  INLINE bool get_perspective() const;
65  INLINE const LColor &get_wireframe_color() const;
66  INLINE int get_geom_rendering(int geom_rendering) const;
67 
68 PUBLISHED:
69  MAKE_PROPERTY(mode, get_mode);
70  MAKE_PROPERTY(thickness, get_thickness);
71  MAKE_PROPERTY(perspective, get_perspective);
72  MAKE_PROPERTY(wireframe_color, get_wireframe_color);
73 
74 public:
75  virtual void output(std::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) compose_impl(const RenderAttrib *other) const;
81 
82 private:
83  Mode _mode;
84  PN_stdfloat _thickness;
85  bool _perspective;
86  LColor _wireframe_color;
87 
88 PUBLISHED:
89  static int get_class_slot() {
90  return _attrib_slot;
91  }
92  virtual int get_slot() const {
93  return get_class_slot();
94  }
95  MAKE_PROPERTY(class_slot, get_class_slot);
96 
97 public:
98  static void register_with_read_factory();
99  virtual void write_datagram(BamWriter *manager, Datagram &dg);
100 
101 protected:
102  static TypedWritable *make_from_bam(const FactoryParams &params);
103  void fillin(DatagramIterator &scan, BamReader *manager);
104 
105 public:
106  static TypeHandle get_class_type() {
107  return _type_handle;
108  }
109  static void init_type() {
110  RenderAttrib::init_type();
111  register_type(_type_handle, "RenderModeAttrib",
112  RenderAttrib::get_class_type());
113  _attrib_slot = register_slot(_type_handle, 100,
114  new RenderModeAttrib(M_filled, 1, false));
115  }
116  virtual TypeHandle get_type() const {
117  return get_class_type();
118  }
119  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
120 
121 private:
122  static TypeHandle _type_handle;
123  static int _attrib_slot;
124 };
125 
126 #include "renderModeAttrib.I"
127 
128 #endif
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is the base class for a number of render attributes (other than transform) that may be set on sc...
Definition: renderAttrib.h:51
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
An instance of this class is passed to the Factory when requesting it to do its business and construc...
Definition: factoryParams.h:36
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:81
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition: datagram.h:38
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.