NAP
uniformcontainer.h
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2  * License, v. 2.0. If a copy of the MPL was not distributed with this
3  * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4 
5 #pragma once
6 
7 // Local Includes
8 #include "samplerinstance.h"
9 #include "uniforminstance.h"
10 #include "bufferbindinginstance.h"
11 
12 namespace nap
13 {
19  class NAPAPI UniformContainer
20  {
21  RTTI_ENABLE()
22  public:
23  using UniformStructInstanceList = std::vector<std::unique_ptr<UniformStructInstance>>;
24  using BufferBindingInstanceList = std::vector<std::unique_ptr<BufferBindingInstance>>;
25  using SamplerInstanceList = std::vector<std::unique_ptr<SamplerInstance>>;
26 
27  UniformContainer() = default;
28  virtual ~UniformContainer() = default;
29 
30  UniformContainer(const UniformContainer&) = delete;
31  UniformContainer& operator=(const UniformContainer&) = delete;
32 
38  UniformStructInstance* findUniform(const std::string& name);
39 
45  BufferBindingInstance* findBinding(const std::string& name);
46 
52  UniformStructInstance& getUniform(const std::string& name);
53 
59  BufferBindingInstance& getBinding(const std::string& name);
60 
64  const SamplerInstanceList& getSamplers() const { return mSamplerInstances; }
65 
69  const BufferBindingInstanceList& getBufferBindings() const { return mBindingInstances; }
70 
74  const UniformStructInstanceList& getUniformStructs() const { return mUniformRootStructs; }
75 
81  SamplerInstance* findSampler(const std::string& name) const;
82 
83  protected:
84  UniformStructInstance& createUniformRootStruct(const ShaderVariableStructDeclaration& declaration, const UniformCreatedCallback& uniformCreatedCallback);
85  BufferBindingInstance& addBindingInstance(std::unique_ptr<BufferBindingInstance> instance);
86  SamplerInstance& addSamplerInstance(std::unique_ptr<SamplerInstance> instance);
87 
88  private:
89  std::vector<std::unique_ptr<UniformStructInstance>> mUniformRootStructs;
90  std::vector<std::unique_ptr<BufferBindingInstance>> mBindingInstances;
91  std::vector<std::unique_ptr<SamplerInstance>> mSamplerInstances;
92  };
93 }
nap::UniformContainer::BufferBindingInstanceList
std::vector< std::unique_ptr< BufferBindingInstance > > BufferBindingInstanceList
Definition: uniformcontainer.h:24
nap::UniformContainer::UniformStructInstanceList
std::vector< std::unique_ptr< UniformStructInstance > > UniformStructInstanceList
Definition: uniformcontainer.h:23
nap::UniformCreatedCallback
std::function< void()> UniformCreatedCallback
Definition: uniform.h:18
nap::UniformContainer::SamplerInstanceList
std::vector< std::unique_ptr< SamplerInstance > > SamplerInstanceList
Definition: uniformcontainer.h:25
nap::BufferBindingInstance
Definition: bufferbindinginstance.h:73
nap::SamplerInstance
Definition: samplerinstance.h:18
nap::UniformContainer::getSamplers
const SamplerInstanceList & getSamplers() const
Definition: uniformcontainer.h:64
nap::ShaderVariableStructDeclaration
Definition: shadervariabledeclarations.h:87
nap
Definition: assert.h:10
nap::UniformStructInstance
Definition: uniforminstance.h:53
nap::UniformContainer
Definition: uniformcontainer.h:19
nap::UniformContainer::getBufferBindings
const BufferBindingInstanceList & getBufferBindings() const
Definition: uniformcontainer.h:69
nap::UniformContainer::getUniformStructs
const UniformStructInstanceList & getUniformStructs() const
Definition: uniformcontainer.h:74