Panda3D
Loading...
Searching...
No Matches
eggRenderMode.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 eggRenderMode.h
10 * @author drose
11 * @date 1999-01-20
12 */
13
14#ifndef EGGRENDERMODE_H
15#define EGGRENDERMODE_H
16
17#include "pandabase.h"
18#include "typedObject.h"
19
20
21/**
22 * This class stores miscellaneous rendering properties that is associated
23 * with geometry, and which may be set on the geometry primitive level, on the
24 * group above it, or indirectly via a texture. It's intended to be a base
25 * class for egg objects that can have these properties set.
26 *
27 * This class cannot inherit from EggObject, because it causes problems at the
28 * EggPolygon level with multiple appearances of the EggObject base class.
29 * And making EggObject a virtual base class is just no fun.
30 */
31class EXPCL_PANDA_EGG EggRenderMode {
32PUBLISHED:
33 EggRenderMode();
34 INLINE EggRenderMode(const EggRenderMode &copy);
35 EggRenderMode &operator = (const EggRenderMode &copy);
36
37 void write(std::ostream &out, int indent_level) const;
38
39 enum AlphaMode { // Specifies implementation of transparency.
40 AM_unspecified,
41 AM_off, // No transparency.
42 AM_on, // Use whatever the default model is.
43 AM_blend, // Normal alpha blending, e.g. TransparencyAttrib::M_alpha.
44 AM_blend_no_occlude, // Alpha blending w/o depth write.
45 AM_ms, // TransparencyAttrib::M_multisample
46 AM_ms_mask, // TransparencyAttrib::M_multisample_mask
47 AM_binary, // TransparencyAttrib::M_binary
48 AM_dual, // TransparencyAttrib::M_dual
49 AM_premultiplied // TransparencyAttrib::M_premultiplied_alpha
50 };
51
52 enum DepthWriteMode {
53 DWM_unspecified, DWM_off, DWM_on
54 };
55
56 enum DepthTestMode {
57 DTM_unspecified, DTM_off, DTM_on
58 };
59
60 enum VisibilityMode {
61 VM_unspecified, VM_hidden, VM_normal
62 };
63
64 INLINE void set_alpha_mode(AlphaMode mode);
65 INLINE AlphaMode get_alpha_mode() const;
66
67 INLINE void set_depth_write_mode(DepthWriteMode mode);
68 INLINE DepthWriteMode get_depth_write_mode() const;
69
70 INLINE void set_depth_test_mode(DepthTestMode mode);
71 INLINE DepthTestMode get_depth_test_mode() const;
72
73 INLINE void set_visibility_mode(VisibilityMode mode);
74 INLINE VisibilityMode get_visibility_mode() const;
75
76 INLINE void set_depth_offset(int bias);
77 INLINE int get_depth_offset() const;
78 INLINE bool has_depth_offset() const;
79 INLINE void clear_depth_offset();
80
81 INLINE void set_draw_order(int order);
82 INLINE int get_draw_order() const;
83 INLINE bool has_draw_order() const;
84 INLINE void clear_draw_order();
85
86 INLINE void set_bin(const std::string &bin);
87 INLINE std::string get_bin() const;
88 INLINE bool has_bin() const;
89 INLINE void clear_bin();
90
91 // Comparison operators are handy.
92 bool operator == (const EggRenderMode &other) const;
93 INLINE bool operator != (const EggRenderMode &other) const;
94 bool operator < (const EggRenderMode &other) const;
95
96 static AlphaMode string_alpha_mode(const std::string &string);
97 static DepthWriteMode string_depth_write_mode(const std::string &string);
98 static DepthTestMode string_depth_test_mode(const std::string &string);
99 static VisibilityMode string_visibility_mode(const std::string &string);
100
101private:
102 AlphaMode _alpha_mode;
103 DepthWriteMode _depth_write_mode;
104 DepthTestMode _depth_test_mode;
105 VisibilityMode _visibility_mode;
106 int _depth_offset;
107 bool _has_depth_offset;
108 int _draw_order;
109 bool _has_draw_order;
110 std::string _bin;
111
112
113public:
114 static TypeHandle get_class_type() {
115 return _type_handle;
116 }
117 static void init_type() {
118 register_type(_type_handle, "EggRenderMode");
119 }
120
121private:
122 static TypeHandle _type_handle;
123};
124
125EXPCL_PANDA_EGG std::ostream &operator << (std::ostream &out, EggRenderMode::AlphaMode mode);
126EXPCL_PANDA_EGG std::istream &operator >> (std::istream &in, EggRenderMode::AlphaMode &mode);
127
128EXPCL_PANDA_EGG std::ostream &operator << (std::ostream &out, EggRenderMode::DepthWriteMode mode);
129EXPCL_PANDA_EGG std::ostream &operator << (std::ostream &out, EggRenderMode::DepthTestMode mode);
130EXPCL_PANDA_EGG std::ostream &operator << (std::ostream &out, EggRenderMode::VisibilityMode mode);
131
132#include "eggRenderMode.I"
133
134#endif
void clear_depth_offset()
Removes the depth-offset flag from this particular object.
bool has_bin() const
Returns true if a bin name has been set for this particular object.
void set_draw_order(int order)
Sets the "draw-order" flag associated with this object.
static DepthWriteMode string_depth_write_mode(const std::string &string)
Returns the DepthWriteMode value associated with the given string representation, or DWM_unspecified ...
int get_draw_order() const
Returns the "draw-order" flag as set for this particular object.
static AlphaMode string_alpha_mode(const std::string &string)
Returns the AlphaMode value associated with the given string representation, or AM_unspecified if the...
void write(std::ostream &out, int indent_level) const
Writes the attributes to the indicated output stream in Egg format.
void set_depth_write_mode(DepthWriteMode mode)
Specifies whether writes should be made to the depth buffer (assuming the rendering backend provides ...
DepthTestMode get_depth_test_mode() const
Returns the depth_test mode that was set, or DTM_unspecified if nothing was set.
DepthWriteMode get_depth_write_mode() const
Returns the depth_write mode that was set, or DWM_unspecified if nothing was set.
void set_alpha_mode(AlphaMode mode)
Specifies precisely how the transparency for this geometry should be achieved, or if it should be use...
VisibilityMode get_visibility_mode() const
Returns the visibility mode that was set, or VM_unspecified if nothing was set.
void set_depth_test_mode(DepthTestMode mode)
Specifies whether this geometry should be tested against the depth buffer when it is drawn (assuming ...
int get_depth_offset() const
Returns the "depth-offset" flag as set for this particular object.
bool has_draw_order() const
Returns true if the draw-order flag has been set for this particular object.
void clear_draw_order()
Removes the draw-order flag from this particular object.
void set_visibility_mode(VisibilityMode mode)
Specifies whether this geometry is to be considered normally visible, or hidden.
bool has_depth_offset() const
Returns true if the depth-offset flag has been set for this particular object.
static DepthTestMode string_depth_test_mode(const std::string &string)
Returns the DepthTestMode value associated with the given string representation, or DTM_unspecified i...
void set_bin(const std::string &bin)
Sets the "bin" string for this particular object.
static VisibilityMode string_visibility_mode(const std::string &string)
Returns the HiddenMode value associated with the given string representation, or VM_unspecified if th...
std::string get_bin() const
Returns the bin name that has been set for this particular object, if any.
void clear_bin()
Removes the bin name that was set for this particular object.
AlphaMode get_alpha_mode() const
Returns the alpha mode that was set, or AM_unspecified if nothing was set.
void set_depth_offset(int bias)
Sets the "depth-offset" flag associated with this object.
TypeHandle is the identifier used to differentiate C++ class types.
Definition typeHandle.h:81
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.