lmgl 1.0.0
A lightweight OpenGL graphics engine library written in C++
Loading...
Searching...
No Matches
lmgl::renderer::ShaderLibrary Class Reference

Manages a collection of shader programs. More...

#include <shader.hpp>

Static Public Member Functions

static void add (const std::string &name, const std::shared_ptr< Shader > shader)
 Adds a shader program to the library.
 
static std::shared_ptr< Shaderload_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< Shaderload_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< Shaderget (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.
 

Detailed Description

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.

Member Function Documentation

◆ 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
nameThe name to associate with the shader program.
shaderA 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
nameThe 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
nameThe 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
nameThe name to associate with the shader program.
srcThe 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
nameThe name to associate with the shader program.
vertThe file path to the vertex shader source code.
fragThe 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: