diff --git a/CMakeLists.txt b/CMakeLists.txt index 5958fe0..f3483f8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.25) -set(BLT_GRAPHICS_VERSION 0.13.32) +set(BLT_GRAPHICS_VERSION 0.13.33) set(BLT_GRAPHICS_TEST_VERSION 0.0.1) project(BLT_WITH_GRAPHICS VERSION ${BLT_GRAPHICS_VERSION}) diff --git a/src/blt/gfx/renderer/resource_manager.cpp b/src/blt/gfx/renderer/resource_manager.cpp index 2d995a9..9dcccde 100644 --- a/src/blt/gfx/renderer/resource_manager.cpp +++ b/src/blt/gfx/renderer/resource_manager.cpp @@ -23,6 +23,9 @@ namespace blt::gfx { + std::mutex log_lock; +#define LOG_LOCKED(log) do { std::scoped_lock lock(log_lock); log; } while(0) + void resource_manager::cleanup() { for (const auto& p : textures_2d) @@ -46,10 +49,10 @@ namespace blt::gfx textures_to_load.pop_back(); } auto path = resource_prefix + texture.get_path(); - BLT_DEBUG("Loading texture file %s", path.c_str()); + LOG_LOCKED(BLT_DEBUG("Loading texture file %s", path.c_str())); if (!std::filesystem::exists(path)) { - BLT_WARN("Texture '%s' does not exist on disk!", path.c_str()); + LOG_LOCKED(BLT_WARN("Texture '%s' does not exist on disk!", path.c_str())); return; } auto* file = new texture_file(path, texture.get_name(), texture.get_desired_channels()); @@ -94,7 +97,7 @@ namespace blt::gfx { auto* back = loaded_textures.back(); textures_2d.insert({back->getName(), new texture_gl2D(back->texture())}); - BLT_DEBUG("Loaded texture '%s'", back->getName().c_str()); + LOG_LOCKED(BLT_DEBUG("Loaded texture '%s'", back->getName().c_str())); delete back; loaded_textures.pop_back(); } @@ -106,13 +109,12 @@ namespace blt::gfx auto gl = new gl_texture2D_array(reference_v->width(), reference_v->height(), static_cast(back.second.size())); for (auto [index, texture] : blt::enumerate(back.second)) { - BLT_TRACE(index); gl->upload(texture->texture().data(), static_cast(index)); delete texture; } texture_arrays_2d.insert({back.first.c_str(), gl}); loaded_arrays.pop_back(); - BLT_DEBUG("Loaded texture array '%s' of size %ld", back.first.c_str(), back.second.size()); + LOG_LOCKED(BLT_DEBUG("Loaded texture array '%s' of size %ld", back.first.c_str(), back.second.size())); } } } \ No newline at end of file