diff options
Diffstat (limited to 'src/core/application.cpp')
| -rw-r--r-- | src/core/application.cpp | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/src/core/application.cpp b/src/core/application.cpp index 433f0e7..e53e420 100644 --- a/src/core/application.cpp +++ b/src/core/application.cpp @@ -12,6 +12,7 @@ #include <algorithm> #include <thread> #include <chrono> +#include <cstdlib> // std::getenv (the DONUT_AUTOEXPORT dev hook) namespace Donut { @@ -79,11 +80,9 @@ namespace Donut m_ui = create_scope<UILayer>(); m_device->init_imgui(); - // load the UI font into the device-created ImGui context (backend-agnostic; - // the backend rebuilds the atlas on the next frame). - ImGuiIO& io = ImGui::GetIO(); - if (!io.Fonts->AddFontFromFileTTF("assets/fonts/inter/static/Inter_18pt-Regular.ttf", 16.0f)) - io.Fonts->AddFontDefault(); + // the UI layer owns its typography and its imgui.ini section; both go into + // the device-created ImGui context before its first NewFrame reads the ini. + m_ui->init(); g_prev_scroll = glfwSetScrollCallback((GLFWwindow*)m_window->get_native_window(), donut_scroll_callback); @@ -166,6 +165,25 @@ namespace Donut m_scene->scene_camera.set_projection(45.0f, (float)w / (float)std::max(h, 1), 0.1f, 1000.0f); View view = m_ui->draw(UIContext{ *m_scene, m_device->device_name(), *this }); + + // dev hook: DONUT_AUTOEXPORT=<frame> fires one export from this exact + // mid-frame spot (the Export button runs inside ui->draw, i.e. between + // begin_frame and render) at that frame (30 if it's not a number), then + // quits. lets the mid-frame export path be exercised headlessly — exit 0 + // means no segfault. + if (const char* autoexport = std::getenv("DONUT_AUTOEXPORT")) + { + static int frame = 0; + const int at = std::atoi(autoexport) > 0 ? std::atoi(autoexport) : 30; + if (++frame == at) + { + ExportConfig cfg; + cfg.width = 1280; cfg.height = 720; + int written = export_frame(cfg); + DONUT_INFO("autoexport wrote {} file(s)", written); + close(); + } + } update_input(view); m_render_path->sync_hdri(m_scene->hdri_path); |
