Panda3D
Loading...
Searching...
No Matches
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
22class FactoryParams;
23
24/**
25 * Specifies how polygons are to be drawn.
26 */
27class EXPCL_PANDA_PGRAPH RenderModeAttrib : public RenderAttrib {
28PUBLISHED:
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
52private:
53 INLINE RenderModeAttrib(Mode mode, PN_stdfloat thickness, bool perspective,
54 const LColor &wireframe_color = LColor::zero());
55
56PUBLISHED:
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
68PUBLISHED:
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
74public:
75 virtual void output(std::ostream &out) const;
76
77protected:
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
82private:
83 Mode _mode;
84 PN_stdfloat _thickness;
85 bool _perspective;
86 LColor _wireframe_color;
87
88PUBLISHED:
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
97public:
98 static void register_with_read_factory();
99 virtual void write_datagram(BamWriter *manager, Datagram &dg);
100
101protected:
102 static TypedWritable *make_from_bam(const FactoryParams &params);
103 void fillin(DatagramIterator &scan, BamReader *manager);
104
105public:
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
121private:
122 static TypeHandle _type_handle;
123 static int _attrib_slot;
124};
125
126#include "renderModeAttrib.I"
127
128#endif
An instance of this class is passed to the Factory when requesting it to do its business and construc...
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 ...
static ConstPointerTo< RenderAttrib > make(Mode mode, PN_stdfloat thickness=1.0f, bool perspective=false, const LColor &wireframe_color=LColor::zero())
Constructs a new RenderModeAttrib object that specifies whether to draw polygons in the normal,...
get_perspective
Returns the perspective flag.
static ConstPointerTo< RenderAttrib > make_default()
Returns a RenderAttrib that corresponds to whatever the standard default properties for render attrib...
get_thickness
Returns the line width or point thickness.
int get_geom_rendering(int geom_rendering) const
Returns the union of the Geom::GeomRendering bits that will be required once this RenderModeAttrib is...
get_wireframe_color
Returns the color that is used in M_filled_wireframe mode to distinguish the wireframe from the rest ...
get_mode
Returns the render mode.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.