fixing put pixel, adding scene change checker

This commit is contained in:
2024-10-21 01:48:01 +02:00
parent 4f755f8a6f
commit 0304834008
28 changed files with 302 additions and 201 deletions

View File

@@ -10,7 +10,7 @@ namespace mlx
{
Application::Application() : p_mem_manager(std::make_unique<MemManager>()), p_sdl_manager(std::make_unique<SDLManager>()), m_fps(), m_in()
{
EventBus::RegisterListener({[](const EventBase& event)
EventBus::RegisterListener({ [](const EventBase& event)
{
if(event.What() == Event::FatalErrorEventCode)
std::abort();
@@ -53,7 +53,7 @@ namespace mlx
MLX_PROFILE_FUNCTION();
Texture* texture;
try { texture = new Texture({}, w, h, VK_FORMAT_R8G8B8A8_SRGB, false, "mlx_user_image"); }
catch(...) { return NULL; }
catch(...) { return nullptr; }
m_image_registry.RegisterTexture(texture);
return texture;
}
@@ -63,7 +63,7 @@ namespace mlx
MLX_PROFILE_FUNCTION();
Texture* texture = StbTextureLoad(file, w, h);
if(texture == nullptr)
return NULL; // NULL for C compatibility
return nullptr;
m_image_registry.RegisterTexture(texture);
return texture;
}

View File

@@ -13,10 +13,7 @@ namespace mlx
// TODO : re-enable render targets
m_renderer.Init(nullptr);
m_scene_renderer.Init(m_renderer);
SceneDescriptor descriptor{};
descriptor.renderer = &m_renderer;
p_scene = std::make_unique<Scene>(std::move(descriptor));
p_scene = std::make_unique<Scene>();
}
GraphicsSupport::GraphicsSupport(std::size_t w, std::size_t h, std::string title, int id) :
@@ -28,10 +25,7 @@ namespace mlx
MLX_PROFILE_FUNCTION();
m_renderer.Init(p_window.get());
m_scene_renderer.Init(m_renderer);
SceneDescriptor descriptor{};
descriptor.renderer = &m_renderer;
p_scene = std::make_unique<Scene>(std::move(descriptor));
p_scene = std::make_unique<Scene>();
}
void GraphicsSupport::Render() noexcept
@@ -39,6 +33,7 @@ namespace mlx
MLX_PROFILE_FUNCTION();
if(m_renderer.BeginFrame())
{
m_draw_layer = 0;
m_scene_renderer.Render(*p_scene, m_renderer);
m_renderer.EndFrame();
}
@@ -47,7 +42,7 @@ namespace mlx
// dump memory to file every two seconds
using namespace std::chrono_literals;
static std::int64_t timer = static_cast<std::uint64_t>(std::chrono::duration_cast<std::chrono::nanoseconds>(std::chrono::high_resolution_clock::now().time_since_epoch()).count());
if(std::chrono::duration<std::uint64_t>{static_cast<std::uint64_t>(std::chrono::duration_cast<std::chrono::nanoseconds>(std::chrono::high_resolution_clock::now().time_since_epoch()).count()) - timer} >= 1s)
if(std::chrono::duration<std::uint64_t>{ static_cast<std::uint64_t>(std::chrono::duration_cast<std::chrono::nanoseconds>(std::chrono::high_resolution_clock::now().time_since_epoch()).count()) - timer } >= 1s)
{
RenderCore::Get().GetAllocator().DumpMemoryToJson();
timer = static_cast<std::uint64_t>(std::chrono::duration_cast<std::chrono::nanoseconds>(std::chrono::high_resolution_clock::now().time_since_epoch()).count());