HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
HwLightShaders.h
Go to the documentation of this file.
1 //
2 // Copyright Contributors to the MaterialX Project
3 // SPDX-License-Identifier: Apache-2.0
4 //
5 
6 #ifndef MATERIALX_HWLIGHTSHADERS_H
7 #define MATERIALX_HWLIGHTSHADERS_H
8 
9 /// @file
10 /// Hardware shader generator lights
11 
12 #include <MaterialXGenHw/Export.h>
13 
16 
18 
19 class HwLightShaders;
20 /// Shared pointer to a HwLightShaders
21 using HwLightShadersPtr = shared_ptr<class HwLightShaders>;
22 
23 /// @class HwLightShaders
24 /// Hardware light shader user data
26 {
27  public:
28  /// Create and return a new instance.
30  {
31  return std::make_shared<HwLightShaders>();
32  }
33 
34  /// Bind a light shader to a light type id.
35  void bind(unsigned int type, ShaderNodePtr shader)
36  {
37  _shaders[type] = shader;
38  }
39 
40  /// Unbind a light shader previously bound to a light type id.
41  void unbind(unsigned int type)
42  {
43  _shaders.erase(type);
44  }
45 
46  /// Clear all light shaders previously bound.
47  void clear()
48  {
49  _shaders.clear();
50  }
51 
52  /// Return the light shader bound to the given light type,
53  /// or nullptr if not light shader is bound to this type.
54  const ShaderNode* get(unsigned int type) const
55  {
56  auto it = _shaders.find(type);
57  return it != _shaders.end() ? it->second.get() : nullptr;
58  }
59 
60  /// Return the map of bound light shaders.
61  const std::unordered_map<unsigned int, ShaderNodePtr>& get() const
62  {
63  return _shaders;
64  }
65 
66  protected:
67  std::unordered_map<unsigned int, ShaderNodePtr> _shaders;
68 };
69 
71 
72 #endif
type
Definition: core.h:556
shared_ptr< class HwLightShaders > HwLightShadersPtr
Shared pointer to a HwLightShaders.
void clear()
Clear all light shaders previously bound.
#define MATERIALX_NAMESPACE_BEGIN
Definition: Generated.h:25
GLint GLint GLsizei GLint GLenum GLenum type
Definition: glcorearb.h:108
void unbind(unsigned int type)
Unbind a light shader previously bound to a light type id.
shared_ptr< class ShaderNode > ShaderNodePtr
Shared pointer to a ShaderNode.
Definition: ShaderNode.h:35
std::unordered_map< unsigned int, ShaderNodePtr > _shaders
GLuint shader
Definition: glcorearb.h:785
void bind(unsigned int type, ShaderNodePtr shader)
Bind a light shader to a light type id.
#define MATERIALX_NAMESPACE_END
Definition: Generated.h:26
#define MX_GENHW_API
Definition: Export.h:18
static HwLightShadersPtr create()
Create and return a new instance.