aboutsummaryrefslogtreecommitdiff
path: root/src/core/application.h
diff options
context:
space:
mode:
authorhachem <im@hachem.wtf>2026-08-23 17:21:37 +0200
committerhachem <im@hachem.wtf>2026-08-23 17:21:37 +0200
commit3fd33ecff7472e4d6fc9e6b3905f56982e497ef2 (patch)
tree66e5812f1a18b926e88a0dd549fe14e7c7327165 /src/core/application.h
parente3aa33fc9a99d8b817bda42a567a4c347e18ab32 (diff)
[feat]: complete RHI api
Diffstat (limited to 'src/core/application.h')
-rw-r--r--src/core/application.h64
1 files changed, 46 insertions, 18 deletions
diff --git a/src/core/application.h b/src/core/application.h
index 4c377f0..4b67c84 100644
--- a/src/core/application.h
+++ b/src/core/application.h
@@ -1,16 +1,25 @@
#pragma once
-#include "state_manager.h"
#include "memory.h"
#include "window.h"
#include "event.h"
#include "log.h"
+#include "camera.h"
-#include "engine/engine.h"
-#include "rendering/renderer_backend.h"
+#include "rendering/rhi.h"
+#include "rendering/scene_renderer.h"
+#include "rendering/black_hole_renderer.h"
+
+#include <string>
+#include <vector>
namespace Donut
{
+ // The application owns ONE RHI::Device (OpenGL or Vulkan, chosen at startup)
+ // and the two portable renderers written on top of it, plus all the shared
+ // state (cameras, scene objects, disk parameters, HDRI). Because the rendering
+ // lives in the RHI and the shared renderers, the app behaves identically no
+ // matter which backend is active.
class Application
{
public:
@@ -21,33 +30,52 @@ namespace Donut
auto run() -> void;
auto close() -> void;
- auto get_window() -> Window& { return *m_window; }
- auto get_state_manager() -> StateManager& { return *m_state_manager; }
- auto get_engine() -> Engine& { return *m_engine; }
- static auto get() -> Application& { return *s_instance; }
+ auto get_window() -> Window& { return *m_window; }
+ static auto get() -> Application& { return *s_instance; }
private:
auto on_init() -> void;
auto on_shutdown() -> void;
- auto on_update() -> void;
- auto on_render() -> void;
auto on_event(Event& event) -> void;
- auto setup_docking_layout() -> void;
- auto build_ui() -> void; // shared ImGui panel, drives the active RendererBackend
- auto build_scene_ui() -> void; // scene-view (object list) section of the UI
+
+ auto build_ui() -> void; // shared ImGui panel
+ auto build_scene_ui() -> void; // scene-view (object list) section
+
+ auto process_input() -> void; // orbit / free-fly / zoom, was per-backend
+ auto set_free_fly(bool enabled) -> void;
+ auto reset_camera() -> void;
+ auto set_hdri(const std::string& path) -> void;
+
+ auto render_frame() -> void;
private:
- Scope<StateManager> m_state_manager;
Scope<Window> m_window;
- Scope<Engine> m_engine;
- Scope<RendererBackend> m_renderer; // active backend (non-null once a backend runs the app)
+
+ // The unified renderer: one device + the shared renderers on top of it.
+ Scope<RHI::Device> m_device;
+ Scope<SceneRenderer> m_scene_renderer;
+ Scope<BlackHoleRenderer> m_black_hole_renderer;
+ Ref<RHI::Texture> m_cubemap; // shared HDRI environment
+
+ Camera m_camera{ 60.0f, 16.0f / 9.0f, 0.1f, 100.0f }; // black-hole view
+ Camera m_scene_camera{ 45.0f, 16.0f / 9.0f, 0.1f, 1000.0f }; // world-builder view
+
+ BlackHoleParams m_bh_params;
+ std::vector<SceneObject> m_scene_objects{ SceneObject{} };
+ int m_selected_object = 0;
+ bool m_scene_mode = false;
+ std::string m_hdri_path;
+
+ // input tracking (mirrors the old per-backend process_input)
+ bool m_left_was_down = false;
+ double m_fps_last_x = 0.0, m_fps_last_y = 0.0;
+ double m_last_frame_time = 0.0;
+ double m_start_time = 0.0;
+ bool m_user_moving = false;
bool m_running;
bool m_minimized;
- float m_delta_time = 0.0f;
- float m_last_frame = 0.0f;
-
static Application* s_instance;
};
}