3 #include <Engine/RaEngine.hpp>
7 #include <Core/CoreMacros.hpp>
8 #include <Engine/Data/ShaderConfiguration.hpp>
10 #include <globjects/Program.h>
15 #include <type_traits>
20 class StaticStringSource;
47 void validate()
const;
52 void setUniform(
const char* name,
const T& value )
const;
53 void setUniform(
const char* name,
Texture* tex,
int texUnit )
const;
59 void setUniformTexture(
const char* name,
Texture* tex )
const;
61 globjects::Program* getProgramObject()
const;
64 void addShaderFromSource( Data::ShaderType type,
65 std::unique_ptr<globjects::StaticStringSource>&& source,
66 const std::string& name =
"",
67 bool fromFile =
true );
72 struct TextureBinding {
74 int m_location { -1 };
75 TextureBinding(
int unit,
int location ) : m_texUnit { unit }, m_location { location } {}
76 TextureBinding() =
default;
78 using TextureUnits = std::map<std::string, TextureBinding>;
79 TextureUnits textureUnits;
81 void loadShader( Data::ShaderType type,
82 const std::string& name,
83 const std::set<std::string>& props,
84 const std::vector<std::pair<std::string, Data::ShaderType>>& includes,
86 const std::string& version =
"#version " +
89 std::string preprocessIncludes(
const std::string& name,
90 const std::string& shader,
97 std::array<std::pair<bool, std::unique_ptr<globjects::Shader>>, Data::ShaderType_COUNT>
99 std::array<std::unique_ptr<globjects::StaticStringSource>, Data::ShaderType_COUNT>
102 std::unique_ptr<globjects::Program> m_program;
129 const std::vector<Scalar>& value )
const;
132 template <
typename T>
134 m_program->setUniform<T>( name, value );
static std::string getGLSLVersion()
get the OpenGL version used in the generated header for shaders.
void setUniform(const char *name, const T &value) const
Uniform setters.