Skip to content

Commit

Permalink
BLUGA-GRAPHICS: Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Saverio976 committed Nov 2, 2023
1 parent 8cd05a7 commit ca412f6
Showing 1 changed file with 0 additions and 36 deletions.
36 changes: 0 additions & 36 deletions libs/B-luga-graphics/src/RaylibImpl/Graphics/Graphics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,42 +82,6 @@ namespace Raylib {
return _image.data;
}

// TextureManager functions

// NOLINTBEGIN(cppcoreguidelines-avoid-non-const-global-variables)
TextureManager TextureManager::_instance = TextureManager();
// NOLINTEND(cppcoreguidelines-avoid-non-const-global-variables)

TextureManager::~TextureManager()
{
unloadTextures();
}

TextureManager &TextureManager::getInstance()
{
return _instance;
}

::Texture2D &TextureManager::getTexture(const std::string &fileName)
{
std::lock_guard<std::mutex> lock(_mutex);
auto it = _textures.find(fileName);

if (it == _textures.end()) {
_textures[fileName] = LoadTexture(ECS::ResourcesManager::convertPath(fileName).c_str());
it = _textures.find(fileName);
}
return _textures[fileName];
}

void TextureManager::unloadTextures()
{
std::lock_guard<std::mutex> lock(_mutex);
for (auto &it : _textures) {
UnloadTexture(it.second);
}
_textures.clear();
}

SpriteImpl::SpriteImpl(const std::string &fileName, float width, float height, std::size_t id)
: _texture(TextureManager::getInstance().getTexture(fileName)),
Expand Down

0 comments on commit ca412f6

Please sign in to comment.