76 void setBool(
const std::string& name,
bool value);
77 void setInt(
const std::string& name,
int value);
78 void setFloat(
const std::string& name,
float value);
79 void setVec2(
const std::string& name,
const glm::vec2& value);
80 void setVec2(
const std::string& name,
float x,
float y);
81 void setVec3(
const std::string& name,
const glm::vec3& value);
82 void setVec3(
const std::string& name,
float x,
float y,
float z);
83 void setVec4(
const std::string& name,
const glm::vec4& value);
84 void setVec4(
const std::string& name,
float x,
float y,
float z,
float w);
85 void setMat2(
const std::string& name,
const glm::mat2& mat);
86 void setMat3(
const std::string& name,
const glm::mat3& mat);
87 void setMat4(
const std::string& name,
const glm::mat4& mat);
88 void bindTexture(
int texture,
unsigned int texture_id);
92 void Set(
const std::string& name,
bool value);
93 void Set(
const std::string& name,
int value);
94 void Set(
const std::string& name,
float value);
95 void Set(
const std::string& name,
const glm::vec2& value);
96 void Set(
const std::string& name,
float x,
float y);
97 void Set(
const std::string& name,
const glm::vec3& value);
98 void Set(
const std::string& name,
float x,
float y,
float z);
99 void Set(
const std::string& name,
const glm::vec4& value);
100 void Set(
const std::string& name,
float x,
float y,
float z,
float w);
101 void Set(
const std::string& name,
const glm::mat2& mat);
102 void Set(
const std::string& name,
const glm::mat3& mat);
103 void Set(
const std::string& name,
const glm::mat4& mat);
108 void SetMVP(
const glm::mat4& model,
const glm::mat4& view,
const glm::mat4& projection);
110 operator unsigned int()
const {
return program; }
118 return std::make_shared<ShaderProgram>(vert, frag);
123 return std::make_shared<ShaderProgram>(vert, frag, geom);
The base class for assets.
Definition: asset.h:159
std::string vert
Code for vertex shader.
Definition: shader.h:150
std::string geometry
Code for geometry file.
Definition: shader.h:156
Hjson::Value uniforms
Definition: shader.h:159
std::string frag
Code for fragment shader.
Definition: shader.h:153
void SetShaderUniform(cqsp::asset::ShaderProgram_t &shader, std::pair< const std::string, Hjson::Value > &value)
Definition: shader.cpp:437
ShaderProgram_t MakeShader()
Definition: shader.cpp:504
AssetType GetAssetType() override
Definition: shader.h:163
unsigned int id
Id of the shader.
Definition: shader.h:56
ShaderType shader_type
Definition: shader.h:53
~Shader()
Definition: shader.cpp:266
AssetType GetAssetType() override
Definition: shader.h:57
Shader(const Shader &)=default
void operator()(const std::string &code, ShaderType type)
Constructs a shader from the code provided.
Definition: shader.cpp:232
A shader program.
Definition: shader.h:69
~ShaderProgram()
Definition: shader.cpp:197
void setMat2(const std::string &name, const glm::mat2 &mat)
Definition: shader.cpp:113
void setFloat(const std::string &name, float value)
Definition: shader.cpp:85
void bindTexture(int texture, unsigned int texture_id)
Definition: shader.cpp:527
void setVec3(const std::string &name, const glm::vec3 &value)
Definition: shader.cpp:97
void setVec4(const std::string &name, const glm::vec4 &value)
Definition: shader.cpp:105
void setBool(const std::string &name, bool value)
Definition: shader.cpp:77
void setMat4(const std::string &name, const glm::mat4 &mat)
Definition: shader.cpp:121
unsigned int program
Definition: shader.h:106
void setVec2(const std::string &name, const glm::vec2 &value)
Definition: shader.cpp:89
void SetMVP(const glm::mat4 &model, const glm::mat4 &view, const glm::mat4 &projection)
Definition: shader.cpp:175
void setInt(const std::string &name, int value)
Definition: shader.cpp:81
void UseProgram()
Definition: shader.cpp:173
void Set(const std::string &name, bool value)
Definition: shader.cpp:125
void setMat3(const std::string &name, const glm::mat3 &mat)
Definition: shader.cpp:117
ShaderProgram()
Definition: shader.cpp:182
std::string GetErrorLog(unsigned int shader)
Get the issues of the shader, up to 1024 characters of it.
Definition: shader.cpp:63
AssetType
Definition: asset.h:33
@ SHADER_DEFINITION
shader_def as the type parameter in resource.hjson
std::shared_ptr< ShaderProgram > ShaderProgram_t
The preferred way of using a shader program.
Definition: shader.h:114
@ SHADER
shader prototype
Definition: assetprototype.h:27
ShaderType
Definition: shader.h:32
ShaderProgram_t MakeShaderProgram(Shader &vert, Shader &frag)
Helper function to create a shader program.
Definition: shader.h:117
unsigned int LoadShaderData(const std::string &code, int type)
Definition: shader.cpp:29
When adding assets, it is extremely crucial that you read cqsp::asset::AssetLoader::LoadResources to ...
Definition: clientctx.h:21