Vesper 0.5.1
Vesper is short form for the Latin word for "Bat", as Vesper is designed to be small, lightweight, and easily handle things like particles and flocking behaviors in accordance with the nature of bats. \n It is meant to be a particle simulation, VFX editor, and CAN be used secondarily as a small game engine.
GitHub | Vesper Updates | Creator
Loading...
Searching...
No Matches
Vesper::ShaderLibrary Class Reference

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

#include <Shader.h>

Public Member Functions

void Add (const std::string &name, const Ref< Shader > &shader)
 Adds a shader to the library with the specified name.
void Add (const Ref< Shader > &shader)
 Adds a shader to the library using its own name.
Ref< ShaderLoad (const std::string &filepath)
 Loads a shader from the specified filepath and adds it to the library.
Ref< ShaderLoad (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.
Ref< ShaderGet (const std::string &name)
 Retrieves a shader from the library by name.
bool Exists (const std::string &name) const
 Checks if a shader with the specified name exists in the library.

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 Vesper::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 VZ_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

◆ Add() [2/2]

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

Adds a shader to the library with the specified name.

32 {
34 VZ_CORE_ASSERT(!Exists(name), "Shader already exists!");
35 m_Shaders[name] = shader;
36 }
#define VZ_CORE_ASSERT(x,...)
Definition Asserts.h:20
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:62

◆ Exists()

bool Vesper::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()

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

Retrieves a shader from the library by name.

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

◆ Load() [1/2]

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

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

46 {
48 auto shader = Shader::Create(filepath);
49 Add(Ref<Shader>(shader));
50 return shader;
51 }
static Ref< Shader > Create(const std::string &name, const std::string &vertexSrc, const std::string &fragmentSrc)
Definition Shader.cpp:20
std::shared_ptr< T > Ref
A smart pointer type representing shared ownership of an object.
Definition Defines_Macros.h:63

◆ Load() [2/2]

Vesper::Ref< Vesper::Shader > Vesper::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 {
56 auto shader = Shader::Create(filepath);
57 Add(Ref<Vesper::Shader>(shader));
58 return shader;
59 }

Member Data Documentation

◆ m_Shaders

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

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