Elevate Engine 1
Loading...
Searching...
No Matches
TextureManager.h
Go to the documentation of this file.
1#pragma once
2
3#include <vector>
4#include <unordered_map>
5#include <mutex>
6
8
9namespace Elevate
10{
12 {
13 unsigned char* data;
15 };
16
18 {
19 public:
21
22 static TexturePtr GetTexture(const std::string& path);
23 static TexturePtr LoadTextureAsync(const std::string& path, TextureType usage = TextureType::Diffuse);
24
25 inline static TexturePtr GetDefaultTexture() { return instance().m_defaultTexture; }
26
27 inline static bool IsAllLoaded() { return instance().m_loadingTextures.empty(); }
28
29 friend class Application;
30 protected:
31 static void UpdateLoadingTextures();
32 private:
34
35 static TextureManager& instance()
36 {
37 static TextureManager instance;
38 return instance;
39 }
40
41 TexturePtr m_defaultTexture;
42
43 // Async loading
44 std::vector<TextureLoadResult> m_loadingTextures;
45 std::mutex m_textureMutex;
46
47 std::unordered_map<std::string, TexturePtr> m_Textures;
48 };
49}
static TexturePtr RegisterTexture(TexturePtr texture)
static TexturePtr GetDefaultTexture()
static TexturePtr GetTexture(const std::string &path)
FUNCTION TO LOAD AND GET A TEXTURE SYNCED WITH THE CURRENT THREAD.
static void UpdateLoadingTextures()
static TexturePtr LoadTextureAsync(const std::string &path, TextureType usage=TextureType::Diffuse)
TextureType
Definition Texture.h:29
std::shared_ptr< Texture > TexturePtr
Definition Texture.h:13