Panda3D
 All Classes Functions Variables Enumerations
paramTexture.I
1 // Filename: paramTexture.I
2 // Created by: rdb (11Dec14)
3 //
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: ParamTextureSampler::Constructor
18 // Access: Published
19 // Description: Creates a new ParamTextureSampler storing the given
20 // texture and sampler objects.
21 ////////////////////////////////////////////////////////////////////
22 INLINE ParamTextureSampler::
23 ParamTextureSampler(Texture *tex, const SamplerState &sampler) :
24  _texture(tex),
25  _sampler(sampler)
26 {
27 }
28 
29 ////////////////////////////////////////////////////////////////////
30 // Function: ParamTextureSampler::get_value_type
31 // Access: Published, Virtual
32 // Description: Returns Texture::get_class_type(), even though it
33 // technically stores more than just a Texture.
34 ////////////////////////////////////////////////////////////////////
36 get_value_type() const {
37  return Texture::get_class_type();
38 }
39 
40 ////////////////////////////////////////////////////////////////////
41 // Function: ParamTextureSampler::get_texture
42 // Access: Published
43 // Description: Retrieves the texture stored in the parameter.
44 ////////////////////////////////////////////////////////////////////
46 get_texture() const {
47  return _texture;
48 }
49 
50 ////////////////////////////////////////////////////////////////////
51 // Function: ParamTextureSampler::get_sampler
52 // Access: Published
53 // Description: Retrieves the sampler state stored in the parameter.
54 ////////////////////////////////////////////////////////////////////
56 get_sampler() const {
57  return _sampler;
58 }
59 
60 ////////////////////////////////////////////////////////////////////
61 // Function: ParamTextureImage::Constructor
62 // Access: Published
63 // Description: Creates a new ParamTextureImage storing the given
64 // texture and image binding parameters.
65 ////////////////////////////////////////////////////////////////////
66 INLINE ParamTextureImage::
67 ParamTextureImage(Texture *tex, bool read, bool write, int z, int n) :
68  _texture(tex),
69  _access(0),
70  _bind_level(min(n, 127)),
71  _bind_layer(z)
72 {
73  if (read) {
74  _access |= A_read;
75  }
76  if (write) {
77  _access |= A_write;
78  }
79  if (z < 0) {
80  _bind_layer = 0;
81  _access |= A_layered;
82  }
83 }
84 
85 ////////////////////////////////////////////////////////////////////
86 // Function: ParamTextureImage::get_value_type
87 // Access: Published, Virtual
88 // Description: Returns Texture::get_class_type(), even though it
89 // technically stores more than just a Texture.
90 ////////////////////////////////////////////////////////////////////
92 get_value_type() const {
93  return Texture::get_class_type();
94 }
95 
96 ////////////////////////////////////////////////////////////////////
97 // Function: ParamTextureImage::get_texture
98 // Access: Published
99 // Description: Retrieves the texture stored in the parameter.
100 ////////////////////////////////////////////////////////////////////
102 get_texture() const {
103  return _texture;
104 }
105 
106 ////////////////////////////////////////////////////////////////////
107 // Function: ParamTextureImage::has_read_access
108 // Access: Published
109 // Description: Returns true if this image should be bound with
110 // read access enabled.
111 ////////////////////////////////////////////////////////////////////
112 INLINE bool ParamTextureImage::
114  return (_access & A_read) != 0;
115 }
116 
117 ////////////////////////////////////////////////////////////////////
118 // Function: ParamTextureImage::has_write_access
119 // Access: Published
120 // Description: Returns true if this image should be bound with
121 // write access enabled.
122 ////////////////////////////////////////////////////////////////////
123 INLINE bool ParamTextureImage::
125  return (_access & A_write) != 0;
126 }
127 
128 ////////////////////////////////////////////////////////////////////
129 // Function: ParamTextureImage::get_bind_layered
130 // Access: Published
131 // Description: Returns true if all layers of this image should be
132 // bound simultaneously.
133 ////////////////////////////////////////////////////////////////////
134 INLINE bool ParamTextureImage::
136  return (_access & A_layered) != 0;
137 }
138 
139 ////////////////////////////////////////////////////////////////////
140 // Function: ParamTextureImage::get_bind_level
141 // Access: Published
142 // Description: Returns the image level that should be bound.
143 ////////////////////////////////////////////////////////////////////
144 INLINE int ParamTextureImage::
145 get_bind_level() const {
146  return _bind_level;
147 }
148 
149 ////////////////////////////////////////////////////////////////////
150 // Function: ParamTextureImage::get_bind_layer
151 // Access: Published
152 // Description: Returns the image layer that should be bound. This
153 // is undefined if get_bind_layered() returns false.
154 ////////////////////////////////////////////////////////////////////
155 INLINE int ParamTextureImage::
156 get_bind_layer() const {
157  return _bind_layer;
158 }
virtual TypeHandle get_value_type() const
Returns Texture::get_class_type(), even though it technically stores more than just a Texture...
Definition: paramTexture.I:92
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
const SamplerState & get_sampler() const
Retrieves the sampler state stored in the parameter.
Definition: paramTexture.I:56
bool get_bind_layered() const
Returns true if all layers of this image should be bound simultaneously.
Definition: paramTexture.I:135
Texture * get_texture() const
Retrieves the texture stored in the parameter.
Definition: paramTexture.I:46
bool has_read_access() const
Returns true if this image should be bound with read access enabled.
Definition: paramTexture.I:113
virtual TypeHandle get_value_type() const
Returns Texture::get_class_type(), even though it technically stores more than just a Texture...
Definition: paramTexture.I:36
int get_bind_layer() const
Returns the image layer that should be bound.
Definition: paramTexture.I:156
int get_bind_level() const
Returns the image level that should be bound.
Definition: paramTexture.I:145
Represents a set of settings that indicate how a texture is sampled.
Definition: samplerState.h:39
bool has_write_access() const
Returns true if this image should be bound with write access enabled.
Definition: paramTexture.I:124
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85
Texture * get_texture() const
Retrieves the texture stored in the parameter.
Definition: paramTexture.I:102