working on texture manager

This commit is contained in:
Vladislav Khorev committed 2026-05-01 21:00:51 +03:00
1 parent e04fcbb9bd
commit be6a8cca9e
9 files changed
+92 -39

No files matched your search

+19
View File
@@ -2,6 +2,8 @@
#include "render/OpenGlExtensions.h"
#include "utils/Utils.h"
#include <memory>
#include <unordered_map>
#if defined EMSCRIPTEN || defined __ANDROID__
#define PNG_ENABLED
@@ -30,6 +32,7 @@ namespace ZL
Format format = RGBA;
MipmapType mipmap = GENERATE;
};
class Texture
{
size_t width = 0;
@@ -59,5 +62,21 @@ namespace ZL
TextureDataStruct CreateTextureDataFromPng(const std::string& fullFileName, const std::string& ZIPFileName = "");
#endif
class TextureManager
{
public:
std::shared_ptr<Texture> LoadFromBmp24(const std::string& fileName, const std::string& zipFile = "");
std::shared_ptr<Texture> LoadFromBmp32(const std::string& fileName, const std::string& zipFile = "");
#ifdef PNG_ENABLED
std::shared_ptr<Texture> LoadFromPng(const std::string& fileName, const std::string& zipFile = "");
#endif
void Unload(const std::string& fileName, const std::string& zipFile = "");
void UnloadAll();
private:
std::unordered_map<std::string, std::shared_ptr<Texture>> textureMap;
static std::string MakeKey(const std::string& fileName, const std::string& zipFile);
};
}