Manages a collection of shader programs.
More...
#include <shader.hpp>
|
| static void | add (const std::string &name, const std::shared_ptr< Shader > shader) |
| | Adds a shader program to the library.
|
| |
| static std::shared_ptr< Shader > | load_vf (const std::string &name, const std::string &vert, const std::string &frag) |
| | Loads a shader program from vertex and fragment shader files and adds it to the library.
|
| |
| static std::shared_ptr< Shader > | load_glsl (const std::string &name, const std::string &src) |
| | Loads a shader program from a GLSL source string and adds it to the library.
|
| |
| static std::shared_ptr< Shader > | get (const std::string &name) |
| | Retrieve a shader program from the library by name.
|
| |
| static bool | exists (const std::string &name) |
| | Checks if a shader program exists in the library by name.
|
| |
| static void | clear () |
| | Clears all shader programs from the library.
|
| |
Manages a collection of shader programs.
The ShaderLibrary class provides functionality to load, store, and retrieve shader programs used in rendering operations. It serves as a centralized repository for shaders, allowing easy access and management of multiple shader programs.
◆ add()
| void lmgl::renderer::ShaderLibrary::add |
( |
const std::string & | name, |
|
|
const std::shared_ptr< Shader > | shader ) |
|
static |
Adds a shader program to the library.
Stores the provided shader program in the library under the specified name.
- Parameters
-
| name | The name to associate with the shader program. |
| shader | A shared pointer to the Shader instance to add. |
◆ clear()
| void lmgl::renderer::ShaderLibrary::clear |
( |
| ) |
|
|
static |
Clears all shader programs from the library.
Removes all stored shader programs, freeing associated resources.
◆ exists()
| bool lmgl::renderer::ShaderLibrary::exists |
( |
const std::string & | name | ) |
|
|
static |
Checks if a shader program exists in the library by name.
- Parameters
-
| name | The name of the shader program to check. |
- Returns
- True if the shader program exists, false otherwise.
◆ get()
| std::shared_ptr< Shader > lmgl::renderer::ShaderLibrary::get |
( |
const std::string & | name | ) |
|
|
static |
Retrieve a shader program from the library by name.
Returns the shader program associated with the specified name.
- Parameters
-
| name | The name of the shader program to retrieve. |
- Returns
- A shared pointer to the Shader instance.
◆ load_glsl()
| std::shared_ptr< Shader > lmgl::renderer::ShaderLibrary::load_glsl |
( |
const std::string & | name, |
|
|
const std::string & | src ) |
|
static |
Loads a shader program from a GLSL source string and adds it to the library.
Parses the provided GLSL source code into vertex and fragment shader components, compiles them, links them into a shader program, and stores it in the library under the given name.
- Parameters
-
| name | The name to associate with the shader program. |
| src | The GLSL shader source code containing both vertex and fragment shaders. |
- Returns
- A shared pointer to the created Shader instance.
◆ load_vf()
| std::shared_ptr< Shader > lmgl::renderer::ShaderLibrary::load_vf |
( |
const std::string & | name, |
|
|
const std::string & | vert, |
|
|
const std::string & | frag ) |
|
static |
Loads a shader program from vertex and fragment shader files and adds it to the library.
Reads the shader source code from the specified files, compiles them, links them into a shader program, and stores it in the library under the given name.
- Parameters
-
| name | The name to associate with the shader program. |
| vert | The file path to the vertex shader source code. |
| frag | The file path to the fragment shader source code. |
- Returns
- A shared pointer to the created Shader instance.
The documentation for this class was generated from the following files:
- include/lmgl/renderer/shader.hpp
- src/renderer/shader.cpp