VoxelEngine
 
Loading...
Searching...
No Matches
TextureManager.h
1#pragma once
2
3#include <glm/glm.hpp>
4
5#include <string>
6#include <unordered_map>
7
8#include "../Globals.h"
9
10#include <LWGL/texture/TextureArray.h>
11
12namespace engine {
13
15 public:
16 void add(std::string&& name, TexID id) { m_textures.emplace(name, id); }
17
18 TexID texture(std::string name) { return m_textures.at(name); }
19
20 std::string getTextureName(TexID id) {
21 for (const auto& [name, texture] : m_textures) {
22 if (texture == id) {
23 return name;
24 }
25 }
26 return "";
27 }
28
29 static TextureManager& Get() {
30 static TextureManager instance;
31 return instance;
32 }
33
34 gl::TextureArray* blockTextures() { return &m_blockTextures; }
35 gl::TextureArray* cascadeShadowMaps() { return &m_cascadeShadowMaps; }
36
37 private:
38 TextureManager() = default;
39
40 std::unordered_map<std::string, TexID> m_textures;
41 gl::TextureArray m_blockTextures;
42 gl::TextureArray m_cascadeShadowMaps;
43 };
44} // namespace engine
Definition TextureManager.h:14