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

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

#include <Texture.h>

Public Member Functions

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

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 Muto::TextureLibrary::Add ( const Ref< Texture2D > &  texture)

Adds a texture to the library using its own name.

40 {
42 std::string name = texture->GetName();
44 }
#define MU_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
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::TextureLibrary::Add ( const std::string &  name,
const Ref< Texture2D > &  texture 
)

Adds a texture to the library with the specified name.

33 {
35 MU_CORE_ASSERT(!Exists(name), "Texture already exists!");
37 }
#define MU_CORE_ASSERT(x,...)
Definition Asserts.h:32
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:68

◆ Exists()

bool Muto::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 > Muto::TextureLibrary::Get ( const std::string &  name) const

Retrieves a texture from the library by name.

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

◆ Load() [1/2]

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

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

47 {
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 > Muto::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 {
58 Add(texture);
59 return texture;
60 }

Member Data Documentation

◆ m_Textures

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

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