lmgl 1.0.0
A lightweight OpenGL graphics engine library written in C++
Loading...
Searching...
No Matches
texture_library.hpp
Go to the documentation of this file.
1
13
14#pragma once
15
17
18#include <memory>
19#include <string>
20#include <unordered_map>
21
22namespace lmgl {
23
24namespace assets {
25
34class TextureLibrary {
35 public:
40 static TextureLibrary &get_instance();
41
51 std::shared_ptr<renderer::Texture> load(const std::string &fpath);
52
62 bool exists(const std::string &fpath) const;
63
73 std::shared_ptr<renderer::Texture> get(const std::string &fpath) const;
74
80 void clear();
81
89 inline size_t size() const { return m_textures.size(); }
90
91 private:
93 TextureLibrary() = default;
94
96 ~TextureLibrary() = default;
97
99 TextureLibrary(const TextureLibrary &) = delete;
100
102 TextureLibrary &operator=(const TextureLibrary &) = delete;
103
105 std::unordered_map<std::string, std::shared_ptr<renderer::Texture>> m_textures;
106};
107
108} // namespace assets
109
110} // namespace lmgl
Manages loading and caching of textures.
Definition texture_library.hpp:34
bool exists(const std::string &fpath) const
Check if a texture exists in the cache.
Definition texture_library.cpp:25
std::shared_ptr< renderer::Texture > load(const std::string &fpath)
Load a texture from a file path.
Definition texture_library.cpp:15
size_t size() const
Get the number of cached textures.
Definition texture_library.hpp:89
static TextureLibrary & get_instance()
Get the singleton instance of the TextureLibrary.
Definition texture_library.cpp:10
std::shared_ptr< renderer::Texture > get(const std::string &fpath) const
Retrieve a cached texture.
Definition texture_library.cpp:27
void clear()
Clear the texture cache.
Definition texture_library.cpp:34
Namespace for asset loading utilities.
Definition model_loader.cpp:14
Forward declarations for Assimp Material structure.
Definition model_loader.cpp:12
Texture class for managing OpenGL textures.