Gazebo Rendering

API Reference

7.4.2
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/utils/SuppressWarning.hh>
27 
28 #include "gz/rendering/config.hh"
29 #include "gz/rendering/Export.hh"
30 
31 namespace gz
32 {
33  namespace rendering
34  {
35  inline namespace GZ_RENDERING_VERSION_NAMESPACE {
36  //
38  class ShaderParamPrivate;
39 
41  class GZ_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 
140  GZ_UTILS_WARN_IGNORE__DLL_INTERFACE_MISSING
141  private: std::unique_ptr<ShaderParamPrivate> dataPtr;
142  GZ_UTILS_WARN_RESUME__DLL_INTERFACE_MISSING
143  };
144  }
145  }
146 }
147 
148 #endif