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::TextureLibrary Class Reference

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

#include <Texture.h>

Public Member Functions

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

Private Attributes

std::unordered_map< std::string, Ref< Texture2D > > m_Textures

Detailed Description

A library for managing and storing textures.

No current serialization implemented.

Member Function Documentation

◆ Add() [1/2]

void Vesper::TextureLibrary::Add ( const Ref< Texture2D > & texture)

Adds a texture to the library using its own name.

40 {
42 auto& name = texture->GetName();
43 Add(name, texture);
44 }
#define VZ_PROFILE_FUNCTION()
Definition Instrumentor.h:240
void Add(const std::string &name, const Ref< Texture2D > &texture)
Adds a texture to the library with the specified name.
Definition Texture.cpp:32

◆ Add() [2/2]

void Vesper::TextureLibrary::Add ( const std::string & name,
const Ref< Texture2D > & texture )

Adds a texture to the library with the specified name.

33 {
35 VZ_CORE_ASSERT(!Exists(name), "Texture already exists!");
36 m_Textures[name] = texture;
37 }
#define VZ_CORE_ASSERT(x,...)
Definition Asserts.h:20
bool Exists(const std::string &name) const
Checks if a texture with the specified name exists in the library.
Definition Texture.cpp:69
std::unordered_map< std::string, Ref< Texture2D > > m_Textures
Definition Texture.h:64

◆ Exists()

bool Vesper::TextureLibrary::Exists ( const std::string & name) const

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

70 {
72 return m_Textures.find(name) != m_Textures.end();
73 }

◆ Get()

Ref< Texture2D > Vesper::TextureLibrary::Get ( const std::string & name) const

Retrieves a texture from the library by name.

63 {
65 VZ_CORE_ASSERT(Exists(name), "Texture not found!");
66 return m_Textures.at(name);
67 }

◆ Load() [1/2]

Ref< Texture2D > Vesper::TextureLibrary::Load ( const std::string & filepath)

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

47 {
49 auto texture = Texture2D::Create(filepath);
50 Add(texture);
51 return texture;
52 }
static Ref< Texture2D > Create(uint32_t width, uint32_t height)
Definition Texture.cpp:10

◆ Load() [2/2]

Ref< Texture2D > Vesper::TextureLibrary::Load ( const std::string & name,
const std::string & filepath )

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

55 {
57 auto texture = Texture2D::Create(filepath);
58 Add(texture);
59 return texture;
60 }

Member Data Documentation

◆ m_Textures

std::unordered_map<std::string, Ref<Texture2D> > Vesper::TextureLibrary::m_Textures
private

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