Panda3D
Loading...
Searching...
No Matches
shaderAttrib.I
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 shaderAttrib.I
10 * @author sshodhan
11 * @date 2004-07-10
12 * @author weifengh, PandaSE
13 * @date 2010-04-15
14 */
15
16/**
17 *
18 */
19INLINE ShaderAttrib::
20ShaderAttrib() :
21 _shader(nullptr),
22 _shader_priority(0),
23 _auto_shader(false),
24 _has_shader(false),
25 _flags(0),
26 _has_flags(0),
27 _instance_count(0),
28 _auto_normal_on(false),
29 _auto_glow_on(false),
30 _auto_gloss_on(false),
31 _auto_ramp_on(false),
32 _auto_shadow_on(false)
33{
34}
35
36/**
37 *
38 */
39INLINE ShaderAttrib::
40ShaderAttrib(const ShaderAttrib &copy) :
41 _shader(copy._shader),
42 _shader_priority(copy._shader_priority),
43 _auto_shader(copy._auto_shader),
44 _has_shader(copy._has_shader),
45 _flags(copy._flags),
46 _has_flags(copy._has_flags),
47 _instance_count(copy._instance_count),
48 _auto_normal_on(copy._auto_normal_on),
49 _auto_glow_on(copy._auto_glow_on),
50 _auto_gloss_on(copy._auto_gloss_on),
51 _auto_ramp_on(copy._auto_ramp_on),
52 _auto_shadow_on(copy._auto_shadow_on),
53 _inputs(copy._inputs)
54{
55}
56
57/**
58 * If true, the shader field of this attribute overrides the shader field of
59 * the parent attribute.
60 */
61INLINE bool ShaderAttrib::
62has_shader() const {
63 return _has_shader;
64}
65
66/**
67 * If true, then this ShaderAttrib does not contain an explicit shader -
68 * instead, it requests the automatic generation of a shader.
69 */
70INLINE bool ShaderAttrib::
71auto_shader() const {
72 return _auto_shader;
73}
74
75/**
76 *
77 */
78INLINE int ShaderAttrib::
79get_shader_priority() const {
80 return _shader_priority;
81}
82
83/**
84 * Returns the number of geometry instances. A value of 0 means not to use
85 * instancing at all.
86 */
87INLINE int ShaderAttrib::
88get_instance_count() const {
89 return _instance_count;
90}
91
92/**
93 *
94 */
95INLINE bool ShaderAttrib::
96get_flag(int index) const {
97 return (_flags & (1<<index)) ? true:false;
98}
99
100/**
101 * Returns true if there is a ShaderInput of the given name.
102 */
105 return (_inputs.find(id) != _inputs.end());
106}
107
108/**
109 *
110 */
111INLINE CPT(RenderAttrib) ShaderAttrib::
112set_shader_input(CPT_InternalName id, const PTA_float &v, int priority) const {
113 return set_shader_input(ShaderInput(std::move(id), v, priority));
114}
115
116/**
117 *
118 */
119INLINE CPT(RenderAttrib) ShaderAttrib::
120set_shader_input(CPT_InternalName id, const PTA_double &v, int priority) const {
121 return set_shader_input(ShaderInput(std::move(id), v, priority));
122}
123
124/**
125 *
126 */
127INLINE CPT(RenderAttrib) ShaderAttrib::
128set_shader_input(CPT_InternalName id, const PTA_LVecBase4 &v, int priority) const {
129 return set_shader_input(ShaderInput(std::move(id), v, priority));
130}
131
132/**
133 *
134 */
135INLINE CPT(RenderAttrib) ShaderAttrib::
136set_shader_input(CPT_InternalName id, const PTA_LVecBase3 &v, int priority) const {
137 return set_shader_input(ShaderInput(std::move(id), v, priority));
138}
139
140
141/**
142 *
143 */
144INLINE CPT(RenderAttrib) ShaderAttrib::
145set_shader_input(CPT_InternalName id, const PTA_LVecBase2 &v, int priority) const {
146 return set_shader_input(ShaderInput(std::move(id), v, priority));
147}
148
149/**
150 *
151 */
152INLINE CPT(RenderAttrib) ShaderAttrib::
153set_shader_input(CPT_InternalName id, const LVecBase4 &v, int priority) const {
154 return set_shader_input(ShaderInput(std::move(id), v, priority));
155}
156
157/**
158 *
159 */
160INLINE CPT(RenderAttrib) ShaderAttrib::
161set_shader_input(CPT_InternalName id, const LVecBase3 &v, int priority) const {
162 return set_shader_input(ShaderInput(std::move(id), v, priority));
163}
164
165/**
166 *
167 */
168INLINE CPT(RenderAttrib) ShaderAttrib::
169set_shader_input(CPT_InternalName id, const LVecBase2 &v, int priority) const {
170 return set_shader_input(ShaderInput(std::move(id), v, priority));
171}
172
173/**
174 *
175 */
176INLINE CPT(RenderAttrib) ShaderAttrib::
177set_shader_input(CPT_InternalName id, const PTA_LMatrix4 &v, int priority) const {
178 return set_shader_input(ShaderInput(std::move(id), v, priority));
179}
180
181/**
182 *
183 */
184INLINE CPT(RenderAttrib) ShaderAttrib::
185set_shader_input(CPT_InternalName id, const PTA_LMatrix3 &v, int priority) const {
186 return set_shader_input(ShaderInput(std::move(id), v, priority));
187}
188
189/**
190 *
191 */
192INLINE CPT(RenderAttrib) ShaderAttrib::
193set_shader_input(CPT_InternalName id, const LMatrix4 &v, int priority) const {
194 return set_shader_input(ShaderInput(std::move(id), v, priority));
195}
196
197/**
198 *
199 */
200INLINE CPT(RenderAttrib) ShaderAttrib::
201set_shader_input(CPT_InternalName id, const LMatrix3 &v, int priority) const {
202 return set_shader_input(ShaderInput(std::move(id), v, priority));
203}
204
205/**
206 *
207 */
208INLINE CPT(RenderAttrib) ShaderAttrib::
209set_shader_input(CPT_InternalName id, Texture *tex, int priority) const {
210 return set_shader_input(ShaderInput(std::move(id), tex, priority));
211}
212
213/**
214 *
215 */
216INLINE CPT(RenderAttrib) ShaderAttrib::
217set_shader_input(CPT_InternalName id, const NodePath &np, int priority) const {
218 return set_shader_input(ShaderInput(std::move(id), np, priority));
219}
220
221/**
222 *
223 */
224INLINE CPT(RenderAttrib) ShaderAttrib::
225set_shader_input(CPT_InternalName id, double n1, double n2, double n3, double n4, int priority) const {
226 return set_shader_input(ShaderInput(std::move(id), LVecBase4((PN_stdfloat)n1, (PN_stdfloat)n2, (PN_stdfloat)n3, (PN_stdfloat)n4), priority));
227}
228
229INLINE bool ShaderAttrib::
230auto_normal_on() const {
231 return _auto_normal_on;
232}
233
234/**
235 *
236 */
237INLINE bool ShaderAttrib::
238auto_glow_on() const {
239 return _auto_glow_on;
240}
241
242/**
243 *
244 */
245INLINE bool ShaderAttrib::
246auto_gloss_on() const {
247 return _auto_gloss_on;
248}
249
250/**
251 *
252 */
253INLINE bool ShaderAttrib::
254auto_ramp_on() const {
255 return _auto_ramp_on;
256}
257
258/**
259 *
260 */
261INLINE bool ShaderAttrib::
262auto_shadow_on() const {
263 return _auto_shadow_on;
264}
This is a const pointer to an InternalName, and should be used in lieu of a CPT(InternalName) in func...
NodePath is the fundamental system for disambiguating instances, and also provides a higher-level int...
Definition nodePath.h:159
This is the base class for a number of render attributes (other than transform) that may be set on sc...
bool auto_shader() const
If true, then this ShaderAttrib does not contain an explicit shader - instead, it requests the automa...
bool has_shader_input(CPT_InternalName id) const
Returns true if there is a ShaderInput of the given name.
get_instance_count
Returns the number of geometry instances.
bool has_shader() const
If true, the shader field of this attribute overrides the shader field of the parent attribute.
This is a small container class that can hold any one of the value types that can be passed as input ...
Definition shaderInput.h:40
Represents a texture object, which is typically a single 2-d image but may also represent a 1-d or 3-...
Definition texture.h:72