HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
bindingMap.h
Go to the documentation of this file.
1 //
2 // Copyright 2016 Pixar
3 //
4 // Licensed under the Apache License, Version 2.0 (the "Apache License")
5 // with the following modification; you may not use this file except in
6 // compliance with the Apache License and the following modification to it:
7 // Section 6. Trademarks. is deleted and replaced with:
8 //
9 // 6. Trademarks. This License does not grant permission to use the trade
10 // names, trademarks, service marks, or product names of the Licensor
11 // and its affiliates, except as required to comply with Section 4(c) of
12 // the License and to reproduce the content of the NOTICE file.
13 //
14 // You may obtain a copy of the Apache License at
15 //
16 // http://www.apache.org/licenses/LICENSE-2.0
17 //
18 // Unless required by applicable law or agreed to in writing, software
19 // distributed under the Apache License with the above modification is
20 // distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21 // KIND, either express or implied. See the Apache License for the specific
22 // language governing permissions and limitations under the Apache License.
23 //
24 #ifndef PXR_IMAGING_GLF_BINDING_MAP_H
25 #define PXR_IMAGING_GLF_BINDING_MAP_H
26 
27 /// \file glf/bindingMap.h
28 
29 #include "pxr/pxr.h"
30 #include "pxr/imaging/glf/api.h"
31 #include "pxr/imaging/garch/gl.h"
32 #include "pxr/base/tf/refBase.h"
34 #include "pxr/base/tf/token.h"
35 #include "pxr/base/tf/weakBase.h"
36 
37 #include "pxr/base/tf/hashmap.h"
38 
40 
41 
42 class GlfBindingMap : public TfRefBase, public TfWeakBase {
43 public:
45 
46  GLF_API
47  int GetSamplerUnit(std::string const &name);
48  GLF_API
49  int GetSamplerUnit(TfToken const & name);
50 
51  // If GetAttributeIndex is called with an unknown
52  // attribute token they return -1
53  GLF_API
54  int GetAttributeIndex(std::string const & name);
55  GLF_API
56  int GetAttributeIndex(TfToken const & name);
57 
58  GLF_API
59  int GetUniformBinding(std::string const & name);
60  GLF_API
61  int GetUniformBinding(TfToken const & name);
62 
63  GLF_API
64  bool HasUniformBinding(std::string const & name) const;
65  GLF_API
66  bool HasUniformBinding(TfToken const & name) const;
67 
68  int GetNumSamplerBindings() const {
69  return (int)_samplerBindings.size();
70  }
71 
73  _attribBindings.clear();
74  }
75 
76  void AddAttribBinding(TfToken const &name, int location) {
77  _attribBindings[name] = location;
78  }
79 
81  return _attribBindings;
82  }
83 
84  GLF_API
86 
87  GLF_API
89 
90  GLF_API
92 
93  GLF_API
94  void Debug() const;
95 
96 private:
97  void _AddActiveAttributeBindings(GLuint program);
98  void _AddActiveUniformBindings(GLuint program);
99  void _AddActiveUniformBlockBindings(GLuint program);
100 
101  BindingMap _attribBindings;
102  BindingMap _samplerBindings;
103  BindingMap _uniformBindings;
104 };
105 
106 
108 
109 #endif // PXR_IMAGING_GLF_BINDING_MAP_H
GLF_API void AssignUniformBindingsToProgram(GLuint program)
GLF_API int GetAttributeIndex(std::string const &name)
#define GLF_API
Definition: api.h:40
GLuint const GLchar * name
Definition: glew.h:1814
void AddAttribBinding(TfToken const &name, int location)
Definition: bindingMap.h:76
unsigned int GLuint
Definition: cl.hpp:167
GLF_API bool HasUniformBinding(std::string const &name) const
TfHashMap< TfToken, int, TfToken::HashFunctor > BindingMap
Definition: bindingMap.h:44
Definition: token.h:87
GLF_API void AddCustomBindings(GLuint program)
GLF_API int GetUniformBinding(std::string const &name)
GLF_API int GetSamplerUnit(std::string const &name)
BindingMap const & GetAttributeBindings() const
Definition: bindingMap.h:80
GLF_API void AssignSamplerUnitsToProgram(GLuint program)
GLsizei const GLchar *const * string
Definition: glew.h:1844
GLF_API void Debug() const
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1346
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91
int GetNumSamplerBindings() const
Definition: bindingMap.h:68
GLuint program
Definition: glew.h:5881
GLint location
Definition: glew.h:1835
void ClearAttribBindings()
Definition: bindingMap.h:72