18#ifndef HEADER_SP_SHADER_MANAGER_HPP
19#define HEADER_SP_SHADER_MANAGER_HPP
27#include <unordered_map>
30#include "utils/no_copy.hpp"
36class SPUniformAssigner;
38enum SamplerType:
unsigned int;
39enum RenderPass:
unsigned int;
46 std::function<void()> m_use_function;
48 std::function<void()> m_unuse_function;
50 std::string m_vertex_shader;
52 std::string m_fragment_shader;
54 std::string m_skinned_mesh_shader;
56 std::vector<std::tuple<std::string, std::string, bool, SamplerType> >
61 typedef std::vector<std::pair< std::string, std::function<void
65 std::string m_shader_name, m_fallback_name;
67 int m_drawing_priority = 0;
69 bool m_transparent_shader =
false;
71 bool m_use_alpha_channel =
false;
73 bool m_use_tangents =
false;
75 std::array<bool, 6> m_srgb =
77 true,
true,
false,
false,
false,
false
83 std::unordered_map<std::string, std::shared_ptr<SPShader> > m_shaders;
85 std::vector<std::shared_ptr<SPShader> > m_official_shaders;
87 std::unordered_map<std::string, SamplerType> m_official_sampler_types;
90 m_official_uniform_assigner_functions;
92 std::unordered_map<std::string, std::function<void()> >
93 m_official_use_functions;
95 std::unordered_map<std::string, std::function<void()> >
96 m_official_unuse_functions;
98 std::string m_shader_directory;
101 std::string getShaderFullPath(
const std::string& name);
105 void loadEachShader(
const std::string& file_name);
107 std::shared_ptr<SPShader> buildSPShader(
const ShaderInfo& si,
108 const std::array<PassInfo, 2>& pi,
109 const UniformAssigners& ua,
123 static void destroy()
129 static void addPrefilledTexturesToShader(SPShader* s,
130 const std::vector<std::tuple<std::string, std::string,
bool,
131 SamplerType> >& t, RenderPass rp);
137 std::shared_ptr<SPShader> getSPShader(
const std::string& name)
139 auto ret = m_shaders.find(name);
140 if (ret != m_shaders.end())
147 void loadSPShaders(
const std::string& directory_name);
149 void addSPShader(
const std::string& name,
150 std::shared_ptr<SPShader> shader)
152 m_shaders[name] = shader;
159 void removeUnusedShaders();
161 void setOfficialShaders()
163 for (
auto& p : m_shaders)
165 m_official_shaders.push_back(p.second);
Utility class, you can inherit from this class to disallow the assignment operator and copy construct...
Definition: no_copy.hpp:26
Definition: sp_shader_manager.hpp:42
utility class used to parse XML files
Definition: xml_node.hpp:48
Definition: sp_shader_manager.hpp:45
Definition: sp_shader_manager.hpp:64