Gazebo Rendering

API Reference

6.6.3
gz/rendering/ShaderParam.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2017 Open Source Robotics Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17 
18 #ifndef GZ_RENDERING_SHADERPARAM_HH_
19 #define GZ_RENDERING_SHADERPARAM_HH_
20 
21 #include <cstdint>
22 #include <cstring>
23 #include <memory>
24 #include <string>
25 
26 #include <gz/common/SuppressWarning.hh>
27 
28 #include "gz/rendering/config.hh"
29 #include "gz/rendering/Export.hh"
30 
31 namespace ignition
32 {
33  namespace rendering
34  {
35  inline namespace IGNITION_RENDERING_VERSION_NAMESPACE {
36  //
38  class ShaderParamPrivate;
39 
41  class IGNITION_RENDERING_VISIBLE ShaderParam
42  {
43  public: enum ParamType : uint16_t
44  {
46  PARAM_NONE = 0,
47 
49  PARAM_FLOAT = 1,
50 
52  PARAM_INT = 2,
53 
55  PARAM_FLOAT_BUFFER = 3,
56 
58  PARAM_INT_BUFFER = 4,
59 
61  PARAM_TEXTURE = 5,
62 
64  PARAM_TEXTURE_CUBE = 6,
65  };
66 
68  public: ShaderParam();
69 
72  public: ShaderParam(const ShaderParam &_other);
73 
75  public: ~ShaderParam();
76 
79  public: ParamType Type() const;
80 
83  public: uint32_t Count() const;
84 
88  public: ShaderParam &operator=(const ShaderParam &_other);
89 
92  public: void operator=(const float _value);
93 
96  public: void operator=(const int _value);
97 
102  public: void SetTexture(const std::string &_value,
103  ShaderParam::ParamType _type = ShaderParam::ParamType::PARAM_TEXTURE,
104  uint32_t _uvSetIndex = 0u);
105 
108  public: void InitializeBuffer(uint32_t _count);
109 
112  public: void UpdateBuffer(float *_floatBuffer);
113 
116  public: void UpdateBuffer(int *_intBuffer);
117 
121  public: bool Value(float *_value) const;
122 
126  public: bool Value(int *_value) const;
127 
132  public: bool Value(std::string &_value, uint32_t &_uvSetIndex) const;
133 
137  public: bool Buffer(std::shared_ptr<void> &_buffer) const;
138 
141  private: std::unique_ptr<ShaderParamPrivate> dataPtr;
143  };
144  }
145  }
146 }
147 
148 #endif
@ PARAM_FLOAT_BUFFER
Float Buffer type parameter.
Definition: gz/rendering/ShaderParam.hh:55
STL class.
STL class.
#define IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING
@ PARAM_INT_BUFFER
Int Buffer type parameter.
Definition: gz/rendering/ShaderParam.hh:58
bool Value(float *_value) const
Get the value of this parameter if it is a float.
ParamType Type() const
Get the type of this parameter.
ParamType
Definition: gz/rendering/ShaderParam.hh:43
@ PARAM_NONE
Type none.
Definition: gz/rendering/ShaderParam.hh:46
a variant type that holds params that can be passed to a shader
Definition: gz/rendering/ShaderParam.hh:41
void UpdateBuffer(float *_floatBuffer)
Copy a buffer to this parameter.
void SetTexture(const std::string &_value, ShaderParam::ParamType _type=ShaderParam::ParamType::PARAM_TEXTURE, uint32_t _uvSetIndex=0u)
Set this to be a texture parameter.
ShaderParam & operator=(const ShaderParam &_other)
Set from another ShaderParam.
uint32_t Count() const
Get the element count of this parameter's buffer.
bool Buffer(std::shared_ptr< void > &_buffer) const
Get the value of this parameter if it is a buffer.
@ PARAM_TEXTURE_CUBE
cube map type parameter
Definition: gz/rendering/ShaderParam.hh:64
@ PARAM_INT
Integer type parameter.
Definition: gz/rendering/ShaderParam.hh:52
@ PARAM_TEXTURE
texture type parameter
Definition: gz/rendering/ShaderParam.hh:61
void InitializeBuffer(uint32_t _count)
Set this to be a buffer parameter.
#define IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING
@ PARAM_FLOAT
Float type parameter.
Definition: gz/rendering/ShaderParam.hh:49