21 #ifndef HX3D_GRAPHICS_SHADER 22 #define HX3D_GRAPHICS_SHADER 24 #include "hx3d/graphics/gl.hpp" 26 #include "hx3d/utils/ptr.hpp" 27 #include "hx3d/utils/resource.hpp" 29 #include <glm/glm.hpp> 54 explicit Shader(std::string pathToShader);
62 Shader(std::string vert, std::string frag);
85 void setUniform2f(std::string uniform, glm::vec2 vector);
92 void setUniform3f(std::string uniform, glm::vec3 vector);
99 void setUniform4f(std::string uniform, glm::vec4 vector);
165 bool compile(
const std::string& vert,
const std::string& frag);
176 bool compile(GLuint &shaderId, GLenum type,
const std::string& content);
GLuint _vertexID
Vertex shader ID.
void setUniform4f(std::string uniform, glm::vec4 vector)
Send a vec4 to the shader.
GLuint _programID
Shader program ID.
void setUniform2f(std::string uniform, glm::vec2 vector)
Send a vec2 to the shader.
static void use(Ptr< Shader > shader)
Use the shader as the current shader.
void setUniformMatrix3f(std::string uniform, glm::mat3 matrix)
Send a mat3 to the shader.
static bool _programsAnalyzed
Are the programs analyzed ?
std::string getParameterType(GLenum type)
Get the parameter type (debug mode).
bool compile(const std::string &vert, const std::string &frag)
Compile the vertex and fragment shaders.
GLint getUniform(std::string name)
Get the wanted uniform id.
void setUniform1f(std::string uniform, float value)
Send a single float to the shader.
GLuint _fragmentID
Fragment shader ID.
GLuint getProgramID() const
Get the program ID.
void analyzeAttributes()
Analyze the shader attributes (debug mode).
std::map< std::string, GLint > _activeAttributes
Active attributes map.
void analyzeUniforms()
Analyze the shader uniforms (debug mode).
Resource type: to use in an asset manager.
void setUniform3f(std::string uniform, glm::vec3 vector)
Send a vec3 to the shader.
std::map< std::string, GLint > _activeUniforms
Active uniforms map.
bool createProgram()
Create the shader program.
static void disable()
Clear the current shader.
static void setProgramAnalyzing(bool value)
Analyse the shaders (debug mode).
Shader(std::string pathToShader)
Create a shader from a path. The path must be without extension, e.g. shaders/test.
GLint getAttribute(std::string name)
Get the wanted attribute id.
void setUniformMatrix4f(std::string uniform, glm::mat4 matrix)
Send a mat4 to the shader.
std::shared_ptr< T > Ptr
Quick-typing shared ptr.