Raven Engine v0.1
Loading...
Searching...
No Matches
Raven::ShaderLibrary Class Reference

Manages a collection of shaders for efficient reuse and lookup. More...

#include <Shader.h>

Public Member Functions

void Add (const std::string &name, const Ref< Shader > &shader)
 Add a shader to the library with a custom name.
void Add (const Ref< Shader > &shader)
 Add a shader to the library using its internal name.
Ref< ShaderLoad (const std::string &filepath)
 Load and add a shader by file path, using its internal name.
Ref< ShaderLoad (const std::string &name, const std::string &filepath)
 Load and add a shader by file path with a custom name.
Ref< ShaderGet (const std::string &name)
 Retrieve a shader by name.
bool Exists (const std::string &name) const
 Checks if a shader exists in the library.
std::unordered_map< std::string, Ref< Shader > > & GetShaders ()

Static Public Member Functions

static Ref< ShaderLibraryCreate ()
 Factory method to create a new ShaderLibrary instance.

Detailed Description

Manages a collection of shaders for efficient reuse and lookup.

Allows adding, loading, and retrieving shaders by name, preventing duplicate loads. Acts as a cache and centralized management point.

Member Function Documentation

◆ Add() [1/2]

void Raven::ShaderLibrary::Add ( const Ref< Shader > & shader)

Add a shader to the library using its internal name.

Parameters
shaderShader reference to add.

◆ Add() [2/2]

void Raven::ShaderLibrary::Add ( const std::string & name,
const Ref< Shader > & shader )

Add a shader to the library with a custom name.

Parameters
nameName to associate with the shader.
shaderShader reference to add.

◆ Create()

Ref< ShaderLibrary > Raven::ShaderLibrary::Create ( )
static

Factory method to create a new ShaderLibrary instance.

Returns
Reference to a new ShaderLibrary.

◆ Exists()

bool Raven::ShaderLibrary::Exists ( const std::string & name) const

Checks if a shader exists in the library.

Parameters
nameShader name to check.
Returns
True if exists, false otherwise.

◆ Get()

Ref< Shader > Raven::ShaderLibrary::Get ( const std::string & name)

Retrieve a shader by name.

Parameters
nameName of the shader.
Returns
Reference to the Shader.

◆ GetShaders()

std::unordered_map< std::string, Ref< Shader > > & Raven::ShaderLibrary::GetShaders ( )
inline

◆ Load() [1/2]

Ref< Shader > Raven::ShaderLibrary::Load ( const std::string & filepath)

Load and add a shader by file path, using its internal name.

Parameters
filepathPath to the shader file.
Returns
Reference to the loaded Shader.

◆ Load() [2/2]

Ref< Shader > Raven::ShaderLibrary::Load ( const std::string & name,
const std::string & filepath )

Load and add a shader by file path with a custom name.

Parameters
nameName to associate with the shader.
filepathPath to the shader file.
Returns
Reference to the loaded Shader.

The documentation for this class was generated from the following files: