|
lmgl 1.0.0
A lightweight OpenGL graphics engine library written in C++
|
Represents a shader program used in rendering. More...
#include <shader.hpp>
Public Member Functions | |
| Shader (const std::string &vert, const std::string &frag) | |
| Creates a shader program from vertex and fragment shader source code. | |
| Shader (const std::string &vert, const std::string &geom, const std::string &frag) | |
| Creates a shader program with vertex, geometry, and fragment shaders. | |
| ~Shader () | |
| Destructor for the Shader class. | |
| void | bind () const |
| Binds the shader program for use in rendering. | |
| void | unbind () const |
| Unbinds the shader program. | |
| unsigned int | get_id () const |
| Retrieves the unique identifier of the shader program. | |
| void | set_int (const std::string &name, int val) |
| Sets an integer uniform variable in the shader program. | |
| void | set_int_array (const std::string &name, int *vals, unsigned int count) |
| Sets an array of integer uniform variables in the shader program. | |
| void | set_float (const std::string &name, float val) |
| Sets a float uniform variable in the shader program. | |
| void | set_vec2 (const std::string &name, const glm::vec2 &val) |
| Sets a vec2 uniform variable in the shader program. | |
| void | set_vec3 (const std::string &name, const glm::vec3 &val) |
| Sets a vec3 uniform variable in the shader program. | |
| void | set_vec4 (const std::string &name, const glm::vec4 &val) |
| Sets a vec4 uniform variable in the shader program. | |
| void | set_mat3 (const std::string &name, const glm::mat3 &val) |
| Sets a mat3 uniform variable in the shader program. | |
| void | set_mat4 (const std::string &name, const glm::mat4 &val) |
| Sets a mat4 uniform variable in the shader program. | |
Static Public Member Functions | |
| static std::shared_ptr< Shader > | from_vf_files (const std::string &vert, const std::string &frag) |
| Creates a Shader instance from vertex and fragment shader files. | |
| static std::shared_ptr< Shader > | from_vgf_files (const std::string &vert, const std::string &geom, const std::string &frag) |
| Creates a Shader instance from vertex, geometry, and fragment shader files. | |
| static std::shared_ptr< Shader > | from_glsl_file (const std::string &glsl) |
| Creates a Shader instance from a single GLSL file. | |
Represents a shader program used in rendering.
The Shader class encapsulates the functionality to create, compile, and manage shader programs consisting of vertex and fragment shaders. It provides an interface for loading shader source code, compiling it, and linking it into a usable program for rendering graphics.
| lmgl::renderer::Shader::Shader | ( | const std::string & | vert, |
| const std::string & | frag ) |
Creates a shader program from vertex and fragment shader source code.
Compiles the provided vertex and fragment shader source code, links them into a shader program, and prepares it for use in rendering.
| vertex_src | The source code for the vertex shader. |
| fragment_src | The source code for the fragment shader. |
| lmgl::renderer::Shader::Shader | ( | const std::string & | vert, |
| const std::string & | geom, | ||
| const std::string & | frag ) |
Creates a shader program with vertex, geometry, and fragment shaders.
| vertex_src | The source code for the vertex shader. |
| geometry_src | The source code for the geometry shader. |
| fragment_src | The source code for the fragment shader. |
| lmgl::renderer::Shader::~Shader | ( | ) |
Destructor for the Shader class.
Cleans up the shader program and releases any associated resources.
| void lmgl::renderer::Shader::bind | ( | ) | const |
Binds the shader program for use in rendering.
Activates the shader program so that it is used for subsequent rendering operations.
|
static |
Creates a Shader instance from a single GLSL file.
Reads the shader source code from the specified GLSL file, which contains both vertex and fragment shader code, compiles them, and links them into a shader program. Also supports optional geometry shader with #shader geometry directive.
| glsl | The file path to the GLSL shader source code. |
|
static |
Creates a Shader instance from vertex and fragment shader files.
Reads the shader source code from the specified files, compiles them, and links them into a shader program.
| vert | The file path to the vertex shader source code. |
| frag | The file path to the fragment shader source code. |
|
static |
Creates a Shader instance from vertex, geometry, and fragment shader files.
| vert | The file path to the vertex shader source code. |
| geom | The file path to the geometry shader source code. |
| frag | The file path to the fragment shader source code. |
| unsigned int lmgl::renderer::Shader::get_id | ( | ) | const |
Retrieves the unique identifier of the shader program.
| void lmgl::renderer::Shader::set_float | ( | const std::string & | name, |
| float | val ) |
Sets a float uniform variable in the shader program.
| name | The name of the uniform variable. |
| val | The float value to set. |
| void lmgl::renderer::Shader::set_int | ( | const std::string & | name, |
| int | val ) |
Sets an integer uniform variable in the shader program.
| name | The name of the uniform variable. |
| val | The integer value to set. |
| void lmgl::renderer::Shader::set_int_array | ( | const std::string & | name, |
| int * | vals, | ||
| unsigned int | count ) |
Sets an array of integer uniform variables in the shader program.
| name | The name of the uniform variable. |
| vals | Pointer to the array of integer values to set. |
| count | The number of integers in the array. |
| void lmgl::renderer::Shader::set_mat3 | ( | const std::string & | name, |
| const glm::mat3 & | val ) |
Sets a mat3 uniform variable in the shader program.
| name | The name of the uniform variable. |
| val | The glm::mat3 value to set. |
| void lmgl::renderer::Shader::set_mat4 | ( | const std::string & | name, |
| const glm::mat4 & | val ) |
Sets a mat4 uniform variable in the shader program.
| name | The name of the uniform variable. |
| val | The glm::mat4 value to set. |
| void lmgl::renderer::Shader::set_vec2 | ( | const std::string & | name, |
| const glm::vec2 & | val ) |
Sets a vec2 uniform variable in the shader program.
| name | The name of the uniform variable. |
| val | The glm::vec2 value to set. |
| void lmgl::renderer::Shader::set_vec3 | ( | const std::string & | name, |
| const glm::vec3 & | val ) |
Sets a vec3 uniform variable in the shader program.
| name | The name of the uniform variable. |
| val | The glm::vec3 value to set. |
| void lmgl::renderer::Shader::set_vec4 | ( | const std::string & | name, |
| const glm::vec4 & | val ) |
Sets a vec4 uniform variable in the shader program.
| name | The name of the uniform variable. |
| val | The glm::vec4 value to set. |
| void lmgl::renderer::Shader::unbind | ( | ) | const |
Unbinds the shader program.
Deactivates the shader program, preventing it from being used in subsequent rendering operations.