Muto 0.0.1
Cross-Platform Application Template
GitHub Repo | Muto Updates | Muto's Author
Loading...
Searching...
No Matches
Muto::ShaderLibrary Class Reference

A library for managing and storing shaders. More...

#include <Shader.h>

Public Member Functions

void Add (const Ref< Shader > &shader)
 Adds a shader to the library using its own name.
 
void Add (const std::string &name, const Ref< Shader > &shader)
 Adds a shader to the library with the specified name.
 
bool Exists (const std::string &name) const
 Checks if a shader with the specified name exists in the library.
 
Ref< Shader > Get (const std::string &name)
 Retrieves a shader from the library by name.
 
Ref< Shader > Load (const std::string &filepath)
 Loads a shader from the specified filepath and adds it to the library.
 
Ref< Shader > Load (const std::string &name, const std::string &filepath)
 Loads a shader from the specified filepath and adds it to the library with the given name.
 

Private Attributes

std::unordered_map< std::string, Ref< Shader > > m_Shaders
 

Detailed Description

A library for managing and storing shaders.

Member Function Documentation

◆ Add() [1/2]

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

Adds a shader to the library using its own name.

39 {
41 auto& name = shader->GetName();
42 Add(name, shader);
43 }
#define MU_PROFILE_FUNCTION()
Definition Instrumentor.h:240
void Add(const std::string &name, const Ref< Shader > &shader)
Adds a shader to the library with the specified name.
Definition Shader.cpp:31
constexpr Scope< T > CreateScope(Args &&... args)
Creates a Scope (unique_ptr) for the given type and constructor arguments.
Definition Defines_Macros.h:51

◆ Add() [2/2]

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

Adds a shader to the library with the specified name.

32 {
34 MU_CORE_ASSERT(!Exists(name), "Shader already exists!");
36 }
#define MU_CORE_ASSERT(x,...)
Definition Asserts.h:32
bool Exists(const std::string &name) const
Checks if a shader with the specified name exists in the library.
Definition Shader.cpp:67
std::unordered_map< std::string, Ref< Shader > > m_Shaders
Definition Shader.h:83

◆ Exists()

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

Checks if a shader with the specified name exists in the library.

68 {
70 return m_Shaders.find(name) != m_Shaders.end();
71 }

◆ Get()

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

Retrieves a shader from the library by name.

62 {
63 MU_CORE_ASSERT(Exists(name), "Shader not found!");
64 return m_Shaders[name];
65 }

◆ Load() [1/2]

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

Loads a shader from the specified filepath and adds it to the library.

46 {
50 return shader;
51 }
static Ref< Shader > Create(const std::string &name, const std::string &vertexSrc, const std::string &fragmentSrc)
Creates a new shader from vertex and fragment shader source code.
Definition Shader.cpp:20

◆ Load() [2/2]

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

Loads a shader from the specified filepath and adds it to the library with the given name.

54 {
58 return shader;
59 }

Member Data Documentation

◆ m_Shaders

std::unordered_map<std::string, Ref<Shader> > Muto::ShaderLibrary::m_Shaders
private

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