Panda3D
paramTexture.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 paramTexture.I
10  * @author rdb
11  * @date 2014-12-11
12  */
13 
14 /**
15  * Creates a new ParamTextureSampler storing the given texture and sampler
16  * objects.
17  */
18 INLINE ParamTextureSampler::
19 ParamTextureSampler(Texture *tex, const SamplerState &sampler) :
20  _texture(tex),
21  _sampler(sampler)
22 {
23 }
24 
25 /**
26  * Returns Texture::get_class_type(), even though it technically stores more
27  * than just a Texture.
28  */
30 get_value_type() const {
31  return Texture::get_class_type();
32 }
33 
34 /**
35  * Retrieves the texture stored in the parameter.
36  */
37 INLINE Texture *ParamTextureSampler::
38 get_texture() const {
39  return _texture;
40 }
41 
42 /**
43  * Retrieves the sampler state stored in the parameter.
44  */
45 INLINE const SamplerState &ParamTextureSampler::
46 get_sampler() const {
47  return _sampler;
48 }
49 
50 /**
51  * Creates a new ParamTextureImage storing the given texture and image binding
52  * parameters.
53  */
54 INLINE ParamTextureImage::
55 ParamTextureImage(Texture *tex, bool read, bool write, int z, int n) :
56  _texture(tex),
57  _access(0),
58  _bind_level(std::min(n, 127)),
59  _bind_layer(z)
60 {
61  if (read) {
62  _access |= A_read;
63  }
64  if (write) {
65  _access |= A_write;
66  }
67  if (z < 0) {
68  _bind_layer = 0;
69  _access |= A_layered;
70  }
71 }
72 
73 /**
74  * Returns Texture::get_class_type(), even though it technically stores more
75  * than just a Texture.
76  */
78 get_value_type() const {
79  return Texture::get_class_type();
80 }
81 
82 /**
83  * Retrieves the texture stored in the parameter.
84  */
85 INLINE Texture *ParamTextureImage::
86 get_texture() const {
87  return _texture;
88 }
89 
90 /**
91  * Returns true if this image should be bound with read access enabled.
92  */
93 INLINE bool ParamTextureImage::
94 has_read_access() const {
95  return (_access & A_read) != 0;
96 }
97 
98 /**
99  * Returns true if this image should be bound with write access enabled.
100  */
101 INLINE bool ParamTextureImage::
102 has_write_access() const {
103  return (_access & A_write) != 0;
104 }
105 
106 /**
107  * Returns true if all layers of this image should be bound simultaneously.
108  */
109 INLINE bool ParamTextureImage::
110 get_bind_layered() const {
111  return (_access & A_layered) != 0;
112 }
113 
114 /**
115  * Returns the image level that should be bound.
116  */
117 INLINE int ParamTextureImage::
118 get_bind_level() const {
119  return _bind_level;
120 }
121 
122 /**
123  * Returns the image layer that should be bound. This is undefined if
124  * get_bind_layered() returns false.
125  */
126 INLINE int ParamTextureImage::
127 get_bind_layer() const {
128  return _bind_layer;
129 }
Represents a texture object, which is typically a single 2-d image but may also represent a 1-d or 3-...
Definition: texture.h:71
Represents a set of settings that indicate how a texture is sampled.
Definition: samplerState.h:36
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81
virtual TypeHandle get_value_type() const
Returns Texture::get_class_type(), even though it technically stores more than just a Texture.
Definition: paramTexture.I:30
virtual TypeHandle get_value_type() const
Returns Texture::get_class_type(), even though it technically stores more than just a Texture.
Definition: paramTexture.I:78