Panda3D
 All Classes Functions Variables Enumerations
shaderInput.I
1 // Filename: shaderInput.I
2 // Created by: jyelon (01Sep05)
3 // Updated by: fperazzi, PandaSE (06Apr10)
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 
16 ////////////////////////////////////////////////////////////////////
17 // Function: ShaderInput::Destructor
18 // Access: Public
19 // Description:
20 ////////////////////////////////////////////////////////////////////
21 INLINE ShaderInput::
22 ~ShaderInput() {
23 }
24 
25 ////////////////////////////////////////////////////////////////////
26 // Function: ShaderInput::Constructor
27 // Access: Published
28 // Description:
29 ////////////////////////////////////////////////////////////////////
30 INLINE ShaderInput::
31 ShaderInput(CPT_InternalName name, int priority) :
32  _name(MOVE(name)),
33  _type(M_invalid),
34  _priority(priority),
35  _bind_layer(0),
36  _bind_level(0),
37  _access(A_read)
38 {
39 }
40 
41 ////////////////////////////////////////////////////////////////////
42 // Function: ShaderInput::Constructor
43 // Access: Published
44 // Description:
45 ////////////////////////////////////////////////////////////////////
46 INLINE ShaderInput::
47 ShaderInput(CPT_InternalName name, Texture *tex, int priority) :
48  _name(MOVE(name)),
49  _type(M_texture),
50  _priority(priority),
51  _value(tex),
52  _bind_layer(0),
53  _bind_level(0),
54  _access(A_read | A_write | A_layered)
55 {
56 }
57 
58 ////////////////////////////////////////////////////////////////////
59 // Function: ShaderInput::Constructor
60 // Access: Published
61 // Description:
62 ////////////////////////////////////////////////////////////////////
63 INLINE ShaderInput::
64 ShaderInput(CPT_InternalName name, Texture *tex, const SamplerState &sampler, int priority) :
65  _name(MOVE(name)),
66  _type(M_texture_sampler),
67  _priority(priority),
68  _value(tex),
69  _sampler(sampler),
70  _bind_layer(0),
71  _bind_level(0),
72  _access(A_read | A_layered)
73 {
74 }
75 
76 ////////////////////////////////////////////////////////////////////
77 // Function: ShaderInput::Constructor
78 // Access: Published
79 // Description:
80 ////////////////////////////////////////////////////////////////////
81 INLINE ShaderInput::
82 ShaderInput(CPT_InternalName name, Texture *tex, bool read, bool write, int z, int n, int priority) :
83  _name(MOVE(name)),
84  _type(M_texture),
85  _priority(priority),
86  _value(tex),
87  _bind_layer(z),
88  _bind_level(n),
89  _access(0)
90 {
91  if (read) {
92  _access |= A_read;
93  }
94  if (write) {
95  _access |= A_write;
96  }
97  if (z >= 0) {
98  _bind_layer = z;
99  } else {
100  _bind_layer = 0;
101  _access |= A_layered;
102  }
103 }
104 
105 ////////////////////////////////////////////////////////////////////
106 // Function: ShaderInput::Constructor
107 // Access: Published
108 // Description:
109 ////////////////////////////////////////////////////////////////////
110 INLINE ShaderInput::
111 ShaderInput(CPT_InternalName name, ParamValueBase *param, int priority) :
112  _name(MOVE(name)),
113  _type(M_param),
114  _priority(priority),
115  _value(param),
116  _bind_layer(0),
117  _bind_level(0),
118  _access(A_read)
119 {
120 }
121 
122 ////////////////////////////////////////////////////////////////////
123 // Function: ShaderInput::Constructor
124 // Access: Published
125 // Description:
126 ////////////////////////////////////////////////////////////////////
127 INLINE ShaderInput::
128 ShaderInput(CPT_InternalName name, const PTA_float &ptr, int priority) :
129  _name(MOVE(name)),
130  _type(M_numeric),
131  _priority(priority),
132  _stored_ptr(ptr),
133  _bind_layer(0),
134  _bind_level(0),
135  _access(A_read)
136 {
137 }
138 
139 ////////////////////////////////////////////////////////////////////
140 // Function: ShaderInput::Constructor
141 // Access: Published
142 // Description:
143 ////////////////////////////////////////////////////////////////////
144 INLINE ShaderInput::
145 ShaderInput(CPT_InternalName name, const PTA_LVecBase4f &ptr, int priority) :
146  _name(MOVE(name)),
147  _type(M_numeric),
148  _priority(priority),
149  _stored_ptr(ptr),
150  _bind_layer(0),
151  _bind_level(0),
152  _access(A_read)
153 {
154 }
155 
156 ////////////////////////////////////////////////////////////////////
157 // Function: ShaderInput::Constructor
158 // Access: Published
159 // Description:
160 ////////////////////////////////////////////////////////////////////
161 INLINE ShaderInput::
162 ShaderInput(CPT_InternalName name, const PTA_LVecBase3f &ptr, int priority) :
163  _name(MOVE(name)),
164  _type(M_numeric),
165  _priority(priority),
166  _stored_ptr(ptr),
167  _bind_layer(0),
168  _bind_level(0),
169  _access(A_read)
170 {
171 }
172 
173 ////////////////////////////////////////////////////////////////////
174 // Function: ShaderInput::Constructor
175 // Access: Published
176 // Description:
177 ////////////////////////////////////////////////////////////////////
178 INLINE ShaderInput::
179 ShaderInput(CPT_InternalName name, const PTA_LVecBase2f &ptr, int priority) :
180  _name(MOVE(name)),
181  _type(M_numeric),
182  _priority(priority),
183  _stored_ptr(ptr),
184  _bind_layer(0),
185  _bind_level(0),
186  _access(A_read)
187 {
188 }
189 
190 ////////////////////////////////////////////////////////////////////
191 // Function: ShaderInput::Constructor
192 // Access: Published
193 // Description:
194 ////////////////////////////////////////////////////////////////////
195 INLINE ShaderInput::
196 ShaderInput(CPT_InternalName name, const LVecBase4f &vec, int priority) :
197  _name(MOVE(name)),
198  _type(M_vector),
199  _priority(priority),
200  _stored_ptr(vec),
201  _stored_vector(LCAST(PN_stdfloat, vec)),
202  _bind_layer(0),
203  _bind_level(0),
204  _access(A_read)
205 {
206 }
207 
208 ////////////////////////////////////////////////////////////////////
209 // Function: ShaderInput::Constructor
210 // Access: Published
211 // Description:
212 ////////////////////////////////////////////////////////////////////
213 INLINE ShaderInput::
214 ShaderInput(CPT_InternalName name, const LVecBase3f &vec, int priority) :
215  _name(MOVE(name)),
216  _type(M_vector),
217  _priority(priority),
218  _stored_ptr(vec),
219  _stored_vector(vec.get_x(), vec.get_y(), vec.get_z(), 0.0),
220  _bind_layer(0),
221  _bind_level(0),
222  _access(A_read)
223 {
224 }
225 
226 ////////////////////////////////////////////////////////////////////
227 // Function: ShaderInput::Constructor
228 // Access: Published
229 // Description:
230 ////////////////////////////////////////////////////////////////////
231 INLINE ShaderInput::
232 ShaderInput(CPT_InternalName name, const LVecBase2f &vec, int priority) :
233  _name(MOVE(name)),
234  _type(M_vector),
235  _priority(priority),
236  _stored_ptr(vec),
237  _stored_vector(vec.get_x(), vec.get_y(), 0.0, 0.0),
238  _bind_layer(0),
239  _bind_level(0),
240  _access(A_read)
241 {
242 }
243 
244 ////////////////////////////////////////////////////////////////////
245 // Function: ShaderInput::Constructor
246 // Access: Published
247 // Description:
248 ////////////////////////////////////////////////////////////////////
249 INLINE ShaderInput::
250 ShaderInput(CPT_InternalName name, const PTA_LMatrix4f &ptr, int priority) :
251  _name(MOVE(name)),
252  _type(M_numeric),
253  _priority(priority),
254  _stored_ptr(ptr),
255  _bind_layer(0),
256  _bind_level(0),
257  _access(A_read)
258 {
259 }
260 
261 ////////////////////////////////////////////////////////////////////
262 // Function: ShaderInput::Constructor
263 // Access: Published
264 // Description:
265 ////////////////////////////////////////////////////////////////////
266 INLINE ShaderInput::
267 ShaderInput(CPT_InternalName name, const PTA_LMatrix3f &ptr, int priority) :
268  _name(MOVE(name)),
269  _type(M_numeric),
270  _priority(priority),
271  _stored_ptr(ptr),
272  _bind_layer(0),
273  _bind_level(0),
274  _access(A_read)
275 {
276 }
277 
278 ////////////////////////////////////////////////////////////////////
279 // Function: ShaderInput::Constructor
280 // Access: Published
281 // Description:
282 ////////////////////////////////////////////////////////////////////
283 INLINE ShaderInput::
284 ShaderInput(CPT_InternalName name, const LMatrix4f &mat, int priority) :
285  _name(MOVE(name)),
286  _type(M_numeric),
287  _priority(priority),
288  _stored_ptr(mat),
289  _bind_layer(0),
290  _bind_level(0),
291  _access(A_read)
292 {
293 }
294 
295 ////////////////////////////////////////////////////////////////////
296 // Function: ShaderInput::Constructor
297 // Access: Published
298 // Description:
299 ////////////////////////////////////////////////////////////////////
300 INLINE ShaderInput::
301 ShaderInput(CPT_InternalName name, const LMatrix3f &mat, int priority) :
302  _name(MOVE(name)),
303  _type(M_numeric),
304  _priority(priority),
305  _stored_ptr(mat),
306  _bind_layer(0),
307  _bind_level(0),
308  _access(A_read)
309 {
310 }
311 
312 ////////////////////////////////////////////////////////////////////
313 // Function: ShaderInput::Constructor
314 // Access: Published
315 // Description:
316 ////////////////////////////////////////////////////////////////////
317 INLINE ShaderInput::
318 ShaderInput(CPT_InternalName name, const PTA_double &ptr, int priority) :
319  _name(MOVE(name)),
320  _type(M_numeric),
321  _priority(priority),
322  _stored_ptr(ptr),
323  _bind_layer(0),
324  _bind_level(0),
325  _access(A_read)
326 {
327 }
328 
329 ////////////////////////////////////////////////////////////////////
330 // Function: ShaderInput::Constructor
331 // Access: Published
332 // Description:
333 ////////////////////////////////////////////////////////////////////
334 INLINE ShaderInput::
335 ShaderInput(CPT_InternalName name, const PTA_LVecBase4d &ptr, int priority) :
336  _name(MOVE(name)),
337  _type(M_numeric),
338  _priority(priority),
339  _stored_ptr(ptr),
340  _bind_layer(0),
341  _bind_level(0),
342  _access(A_read)
343 {
344 }
345 
346 ////////////////////////////////////////////////////////////////////
347 // Function: ShaderInput::Constructor
348 // Access: Published
349 // Description:
350 ////////////////////////////////////////////////////////////////////
351 INLINE ShaderInput::
352 ShaderInput(CPT_InternalName name, const PTA_LVecBase3d &ptr, int priority) :
353  _name(MOVE(name)),
354  _type(M_numeric),
355  _priority(priority),
356  _stored_ptr(ptr),
357  _bind_layer(0),
358  _bind_level(0),
359  _access(A_read)
360 {
361 }
362 
363 ////////////////////////////////////////////////////////////////////
364 // Function: ShaderInput::Constructor
365 // Access: Published
366 // Description:
367 ////////////////////////////////////////////////////////////////////
368 INLINE ShaderInput::
369 ShaderInput(CPT_InternalName name, const PTA_LVecBase2d &ptr, int priority) :
370  _name(MOVE(name)),
371  _type(M_numeric),
372  _priority(priority),
373  _stored_ptr(ptr),
374  _bind_layer(0),
375  _bind_level(0),
376  _access(A_read)
377 {
378 }
379 
380 ////////////////////////////////////////////////////////////////////
381 // Function: ShaderInput::Constructor
382 // Access: Published
383 // Description:
384 ////////////////////////////////////////////////////////////////////
385 INLINE ShaderInput::
386 ShaderInput(CPT_InternalName name, const LVecBase4d &vec, int priority) :
387  _name(MOVE(name)),
388  _type(M_numeric),
389  _priority(priority),
390  _stored_ptr(vec),
391  _stored_vector(LCAST(PN_stdfloat, vec)),
392  _bind_layer(0),
393  _bind_level(0),
394  _access(A_read)
395 {
396 }
397 
398 ////////////////////////////////////////////////////////////////////
399 // Function: ShaderInput::Constructor
400 // Access: Published
401 // Description:
402 ////////////////////////////////////////////////////////////////////
403 INLINE ShaderInput::
404 ShaderInput(CPT_InternalName name, const LVecBase3d &vec, int priority) :
405  _name(MOVE(name)),
406  _type(M_numeric),
407  _priority(priority),
408  _stored_ptr(vec),
409  _stored_vector(vec.get_x(), vec.get_y(), vec.get_z(), 0.0),
410  _bind_layer(0),
411  _bind_level(0),
412  _access(A_read)
413 {
414 }
415 
416 ////////////////////////////////////////////////////////////////////
417 // Function: ShaderInput::Constructor
418 // Access: Published
419 // Description:
420 ////////////////////////////////////////////////////////////////////
421 INLINE ShaderInput::
422 ShaderInput(CPT_InternalName name, const LVecBase2d &vec, int priority) :
423  _name(MOVE(name)),
424  _type(M_numeric),
425  _priority(priority),
426  _stored_ptr(vec),
427  _stored_vector(vec.get_x(), vec.get_y(), 0.0, 0.0),
428  _bind_layer(0),
429  _bind_level(0),
430  _access(A_read)
431 {
432 }
433 
434 ////////////////////////////////////////////////////////////////////
435 // Function: ShaderInput::Constructor
436 // Access: Published
437 // Description:
438 ////////////////////////////////////////////////////////////////////
439 INLINE ShaderInput::
440 ShaderInput(CPT_InternalName name, const PTA_LMatrix4d &ptr, int priority) :
441  _name(MOVE(name)),
442  _type(M_numeric),
443  _priority(priority),
444  _stored_ptr(ptr),
445  _bind_layer(0),
446  _bind_level(0),
447  _access(A_read)
448 {
449 }
450 
451 ////////////////////////////////////////////////////////////////////
452 // Function: ShaderInput::Constructor
453 // Access: Published
454 // Description:
455 ////////////////////////////////////////////////////////////////////
456 INLINE ShaderInput::
457 ShaderInput(CPT_InternalName name, const PTA_LMatrix3d &ptr, int priority) :
458  _name(MOVE(name)),
459  _type(M_numeric),
460  _priority(priority),
461  _stored_ptr(ptr),
462  _bind_layer(0),
463  _bind_level(0),
464  _access(A_read)
465 {
466 }
467 
468 ////////////////////////////////////////////////////////////////////
469 // Function: ShaderInput::Constructor
470 // Access: Published
471 // Description:
472 ////////////////////////////////////////////////////////////////////
473 INLINE ShaderInput::
474 ShaderInput(CPT_InternalName name, const LMatrix4d &mat, int priority) :
475  _name(MOVE(name)),
476  _type(M_numeric),
477  _priority(priority),
478  _stored_ptr(mat),
479  _bind_layer(0),
480  _bind_level(0),
481  _access(A_read)
482 {
483 }
484 
485 ////////////////////////////////////////////////////////////////////
486 // Function: ShaderInput::Constructor
487 // Access: Published
488 // Description:
489 ////////////////////////////////////////////////////////////////////
490 INLINE ShaderInput::
491 ShaderInput(CPT_InternalName name, const LMatrix3d &mat, int priority) :
492  _name(MOVE(name)),
493  _type(M_numeric),
494  _priority(priority),
495  _stored_ptr(mat),
496  _bind_layer(0),
497  _bind_level(0),
498  _access(A_read)
499 {
500 }
501 
502 ////////////////////////////////////////////////////////////////////
503 // Function: ShaderInput::Constructor
504 // Access: Published
505 // Description:
506 ////////////////////////////////////////////////////////////////////
507 INLINE ShaderInput::
508 ShaderInput(CPT_InternalName name, const PTA_int &ptr, int priority) :
509  _name(MOVE(name)),
510  _type(M_numeric),
511  _priority(priority),
512  _stored_ptr(ptr),
513  _bind_layer(0),
514  _bind_level(0),
515  _access(A_read)
516 {
517 }
518 
519 ////////////////////////////////////////////////////////////////////
520 // Function: ShaderInput::Constructor
521 // Access: Published
522 // Description:
523 ////////////////////////////////////////////////////////////////////
524 INLINE ShaderInput::
525 ShaderInput(CPT_InternalName name, const PTA_LVecBase4i &ptr, int priority) :
526  _name(MOVE(name)),
527  _type(M_numeric),
528  _priority(priority),
529  _stored_ptr(ptr),
530  _bind_layer(0),
531  _bind_level(0),
532  _access(A_read)
533 {
534 }
535 
536 ////////////////////////////////////////////////////////////////////
537 // Function: ShaderInput::Constructor
538 // Access: Published
539 // Description:
540 ////////////////////////////////////////////////////////////////////
541 INLINE ShaderInput::
542 ShaderInput(CPT_InternalName name, const PTA_LVecBase3i &ptr, int priority) :
543  _name(MOVE(name)),
544  _type(M_numeric),
545  _priority(priority),
546  _stored_ptr(ptr),
547  _bind_layer(0),
548  _bind_level(0),
549  _access(A_read)
550 {
551 }
552 
553 ////////////////////////////////////////////////////////////////////
554 // Function: ShaderInput::Constructor
555 // Access: Published
556 // Description:
557 ////////////////////////////////////////////////////////////////////
558 INLINE ShaderInput::
559 ShaderInput(CPT_InternalName name, const PTA_LVecBase2i &ptr, int priority) :
560  _name(MOVE(name)),
561  _type(M_numeric),
562  _priority(priority),
563  _stored_ptr(ptr),
564  _bind_layer(0),
565  _bind_level(0),
566  _access(A_read)
567 {
568 }
569 
570 ////////////////////////////////////////////////////////////////////
571 // Function: ShaderInput::Constructor
572 // Access: Published
573 // Description:
574 ////////////////////////////////////////////////////////////////////
575 INLINE ShaderInput::
576 ShaderInput(CPT_InternalName name, const LVecBase4i &vec, int priority) :
577  _name(MOVE(name)),
578  _type(M_numeric),
579  _priority(priority),
580  _stored_ptr(vec),
581  _stored_vector((int)vec.get_x(), (int)vec.get_y(), (int)vec.get_z(), (int)vec.get_w()),
582  _bind_layer(0),
583  _bind_level(0),
584  _access(A_read)
585 {
586 }
587 
588 ////////////////////////////////////////////////////////////////////
589 // Function: ShaderInput::Constructor
590 // Access: Published
591 // Description:
592 ////////////////////////////////////////////////////////////////////
593 INLINE ShaderInput::
594 ShaderInput(CPT_InternalName name, const LVecBase3i &vec, int priority) :
595  _name(MOVE(name)),
596  _type(M_numeric),
597  _priority(priority),
598  _stored_ptr(vec),
599  _stored_vector((int)vec.get_x(), (int)vec.get_y(), (int)vec.get_z(), 0.0),
600  _bind_layer(0),
601  _bind_level(0),
602  _access(A_read)
603 {
604 }
605 
606 ////////////////////////////////////////////////////////////////////
607 // Function: ShaderInput::Constructor
608 // Access: Published
609 // Description:
610 ////////////////////////////////////////////////////////////////////
611 INLINE ShaderInput::
612 ShaderInput(CPT_InternalName name, const LVecBase2i &vec, int priority) :
613  _name(MOVE(name)),
614  _type(M_numeric),
615  _priority(priority),
616  _stored_ptr(vec),
617  _stored_vector((int)vec.get_x(), (int)vec.get_y(), 0.0, 0.0),
618  _bind_layer(0),
619  _bind_level(0),
620  _access(A_read)
621 {
622 }
623 
624 ////////////////////////////////////////////////////////////////////
625 // Function: ShaderInput::get_name
626 // Access: Published
627 // Description:
628 ////////////////////////////////////////////////////////////////////
629 INLINE const InternalName *ShaderInput::
630 get_name() const {
631  return _name;
632 }
633 
634 ////////////////////////////////////////////////////////////////////
635 // Function: ShaderInput::get_value_type
636 // Access: Published
637 // Description:
638 ////////////////////////////////////////////////////////////////////
639 INLINE int ShaderInput::
640 get_value_type() const {
641  return _type;
642 }
643 
644 ////////////////////////////////////////////////////////////////////
645 // Function: ShaderInput::get_priority
646 // Access: Published
647 // Description:
648 ////////////////////////////////////////////////////////////////////
649 INLINE int ShaderInput::
650 get_priority() const {
651  return _priority;
652 }
653 
654 ////////////////////////////////////////////////////////////////////
655 // Function: ShaderInput::get_texture
656 // Access: Published
657 // Description:
658 ////////////////////////////////////////////////////////////////////
659 INLINE Texture *ShaderInput::
660 get_texture() const {
661  return DCAST(Texture, _value);
662 }
663 
664 ////////////////////////////////////////////////////////////////////
665 // Function: ShaderInput::get_vector
666 // Access: Published
667 // Description:
668 ////////////////////////////////////////////////////////////////////
669 INLINE const LVecBase4 &ShaderInput::
670 get_vector() const {
671  return _stored_vector;
672 }
673 
674 ////////////////////////////////////////////////////////////////////
675 // Function: ShaderInput::get_ptr
676 // Access: Published
677 // Description:
678 ////////////////////////////////////////////////////////////////////
679 INLINE const Shader::ShaderPtrData &ShaderInput::
680 get_ptr() const {
681  return _stored_ptr;
682 }
683 
684 ////////////////////////////////////////////////////////////////////
685 // Function: ShaderInput::get_sampler
686 // Access: Published
687 // Description:
688 ////////////////////////////////////////////////////////////////////
689 INLINE const SamplerState &ShaderInput::
690 get_sampler() const {
691  return (_type == M_texture)
692  ? get_texture()->get_default_sampler()
693  : _sampler;
694 }
695 
696 ////////////////////////////////////////////////////////////////////
697 // Function: ShaderInput::get_param
698 // Access: Public
699 // Description:
700 ////////////////////////////////////////////////////////////////////
701 INLINE ParamValueBase *ShaderInput::
702 get_param() const {
703  return DCAST(ParamValueBase, _value);
704 }
This is the base class for all three-component vectors and points.
Definition: lvecBase3.h:105
This is a const pointer to an InternalName, and should be used in lieu of a CPT(InternalName) in func...
Definition: internalName.h:197
This is a 4-by-4 transform matrix.
Definition: lmatrix.h:4716
This is the base class for all two-component vectors and points.
Definition: lvecBase2.h:1241
Represents a texture object, which is typically a single 2-d image but may also represent a 1-d or 3-...
Definition: texture.h:75
This is the base class for all two-component vectors and points.
Definition: lvecBase2.h:2328
This is the base class for all three-component vectors and points.
Definition: lvecBase4.h:1661
This is the base class for all three-component vectors and points.
Definition: lvecBase4.h:3162
This is a 3-by-3 transform matrix.
Definition: lmatrix.h:4375
A non-template base class of ParamValue (below), which serves mainly to define the placeholder for th...
Definition: paramValue.h:34
This is a 4-by-4 transform matrix.
Definition: lmatrix.h:451
This is the base class for all two-component vectors and points.
Definition: lvecBase2.h:105
This is the base class for all three-component vectors and points.
Definition: lvecBase3.h:1455
Represents a set of settings that indicate how a texture is sampled.
Definition: samplerState.h:39
This is the base class for all three-component vectors and points.
Definition: lvecBase4.h:111
This is the base class for all three-component vectors and points.
Definition: lvecBase3.h:2756
This is a 3-by-3 transform matrix.
Definition: lmatrix.h:110
const SamplerState & get_default_sampler() const
This returns the default sampler state for this texture, containing the wrap and filter properties sp...
Definition: texture.I:1071