locking to print
parent
36159a33b8
commit
b8a3d3171b
|
@ -1,6 +1,6 @@
|
||||||
cmake_minimum_required(VERSION 3.25)
|
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)
|
set(BLT_GRAPHICS_TEST_VERSION 0.0.1)
|
||||||
|
|
||||||
project(BLT_WITH_GRAPHICS VERSION ${BLT_GRAPHICS_VERSION})
|
project(BLT_WITH_GRAPHICS VERSION ${BLT_GRAPHICS_VERSION})
|
||||||
|
|
|
@ -23,6 +23,9 @@
|
||||||
namespace blt::gfx
|
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()
|
void resource_manager::cleanup()
|
||||||
{
|
{
|
||||||
for (const auto& p : textures_2d)
|
for (const auto& p : textures_2d)
|
||||||
|
@ -46,10 +49,10 @@ namespace blt::gfx
|
||||||
textures_to_load.pop_back();
|
textures_to_load.pop_back();
|
||||||
}
|
}
|
||||||
auto path = resource_prefix + texture.get_path();
|
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))
|
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;
|
return;
|
||||||
}
|
}
|
||||||
auto* file = new texture_file(path, texture.get_name(), texture.get_desired_channels());
|
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();
|
auto* back = loaded_textures.back();
|
||||||
textures_2d.insert({back->getName(), new texture_gl2D(back->texture())});
|
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;
|
delete back;
|
||||||
loaded_textures.pop_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<blt::i32>(back.second.size()));
|
auto gl = new gl_texture2D_array(reference_v->width(), reference_v->height(), static_cast<blt::i32>(back.second.size()));
|
||||||
for (auto [index, texture] : blt::enumerate(back.second))
|
for (auto [index, texture] : blt::enumerate(back.second))
|
||||||
{
|
{
|
||||||
BLT_TRACE(index);
|
|
||||||
gl->upload(texture->texture().data(), static_cast<blt::i32>(index));
|
gl->upload(texture->texture().data(), static_cast<blt::i32>(index));
|
||||||
delete texture;
|
delete texture;
|
||||||
}
|
}
|
||||||
texture_arrays_2d.insert({back.first.c_str(), gl});
|
texture_arrays_2d.insert({back.first.c_str(), gl});
|
||||||
loaded_arrays.pop_back();
|
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()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue