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 4, 2023
1 parent 4bf2833 commit 366bde8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
20 changes: 10 additions & 10 deletions libs/B-luga-graphics/src/RaylibImpl/Graphics/Graphics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,23 @@ namespace Raylib {

::Texture2D &TextureManagerImpl::getTexture(const std::string &path)
{
std::lock_guard<std::mutex> lock(_mutex);
std::string fileName = PathResolver::resolve(path);
auto it = _textures.find(fileName);
return _loadTexture(path);
}

if (it == _textures.end()) {
_textures[fileName] = LoadTexture(fileName.c_str());
Logger::error("wtf: " + fileName);
}
return _textures[fileName];
::Texture2D TextureManagerImpl::loadTexture(const std::string &path)
{
std::lock_guard<std::mutex> lock(_mutex);
if (_textures.find(path) == _textures.end()) {
_textures[path] = LoadTexture(path.c_str());
}
return _textures[path];
}

void TextureManagerImpl::preloadTexture(const std::string &path)
{
std::lock_guard<std::mutex> lock(_mutex);
auto fileName = PathResolver::resolve(path);

_textures[fileName] = LoadTexture(fileName.c_str());
loadTexture(fileName);
}

void TextureManagerImpl::unloadTextures()
Expand Down
1 change: 1 addition & 0 deletions libs/B-luga-graphics/src/RaylibImpl/Graphics/Graphics.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ namespace Raylib {
private:
std::map<std::string, ::Texture2D> _textures;
std::mutex _mutex;
::Texture2D loadTexture(const std::string &path);
};

class SpriteImpl : public Sprite {
Expand Down

0 comments on commit 366bde8

Please sign in to comment.