Radium Engine  1.5.0
ShaderProgramManager.hpp
1 #pragma once
2 
3 #include <Engine/RaEngine.hpp>
4 
5 #include <map>
6 #include <memory>
7 #include <string>
8 #include <vector>
9 
10 #include <Core/Utils/Singleton.hpp>
11 #include <Core/Utils/StdOptional.hpp>
12 
13 namespace globjects {
14 class File;
15 class NamedString;
16 } // namespace globjects
17 
18 namespace Ra {
19 namespace Engine {
20 namespace Data {
21 
22 class ShaderProgram;
23 class ShaderConfiguration;
24 
36 class RA_ENGINE_API ShaderProgramManager final
37 {
38 
39  public:
43  ShaderProgramManager( const ShaderProgramManager& ) = delete;
44  ShaderProgramManager& operator=( const ShaderProgramManager& ) = delete;
45 
57  Core::Utils::optional<const Data::ShaderProgram*>
58  addShaderProgram( const Data::ShaderConfiguration& config );
59 
65  const Data::ShaderProgram* getShaderProgram( const std::string& id );
66 
73  const Data::ShaderProgram* getShaderProgram( const Data::ShaderConfiguration& config );
74 
79  void reloadAllShaderPrograms();
85  void reloadNotCompiledShaderPrograms();
86 
95  bool addNamedString( const std::string& includepath, const std::string& realfile );
96 
101  void reloadNamedString();
102 
103  private:
104  void insertShader( const Data::ShaderConfiguration& config,
105  const std::shared_ptr<Data::ShaderProgram>& shader );
106 
107  private:
108  std::map<std::string, Data::ShaderConfiguration> m_shaderProgramIds;
109  std::map<Data::ShaderConfiguration, std::shared_ptr<Data::ShaderProgram>> m_shaderPrograms;
110  std::vector<Data::ShaderConfiguration> m_shaderFailedConfs;
111 
112  std::map<std::string,
113  std::pair<std::unique_ptr<globjects::File>, std::unique_ptr<globjects::NamedString>>>
114  m_namedStrings;
115 };
116 
117 } // namespace Data
118 } // namespace Engine
119 } // namespace Ra
Definition: Cage.cpp:3