diff options
| author | hachem <im@hachem.wtf> | 2026-08-23 17:21:37 +0200 |
|---|---|---|
| committer | hachem <im@hachem.wtf> | 2026-08-23 17:21:37 +0200 |
| commit | 3fd33ecff7472e4d6fc9e6b3905f56982e497ef2 (patch) | |
| tree | 66e5812f1a18b926e88a0dd549fe14e7c7327165 /src/rendering/renderer_backend.h | |
| parent | e3aa33fc9a99d8b817bda42a567a4c347e18ab32 (diff) | |
[feat]: complete RHI api
Diffstat (limited to 'src/rendering/renderer_backend.h')
| -rw-r--r-- | src/rendering/renderer_backend.h | 53 |
1 files changed, 6 insertions, 47 deletions
diff --git a/src/rendering/renderer_backend.h b/src/rendering/renderer_backend.h index 6a4f1af..d34983f 100644 --- a/src/rendering/renderer_backend.h +++ b/src/rendering/renderer_backend.h @@ -1,14 +1,15 @@ #pragma once #include <glm/glm.hpp> -#include <functional> -#include <string> -#include <vector> namespace Donut { - // A placeable/editable sphere in the world-builder scene view. Backend- - // agnostic: the app owns the list, every backend renders it the same way. + // Backend-agnostic scene/black-hole data shared by the Application and the + // portable renderers (SceneRenderer, BlackHoleRenderer). The rendering itself + // is written once on the RHI (rendering/rhi.h); these are just the inputs. + + // A placeable/editable sphere in the world-builder scene view. The app owns + // the list; SceneRenderer draws it the same way on every backend. struct SceneObject { glm::vec3 position = { 0.0f, 2.0f, 0.0f }; @@ -28,46 +29,4 @@ namespace Donut int quality_steps = 15000; // geodesic integration steps float fov_degrees = 60.0f; // camera field of view }; - - // The swappable high-level renderer. Each graphics backend (OpenGL, Vulkan, - // and later Metal / D3D12) implements this one interface; the Application, - // states and UI drive it identically, so the app behaves the same no matter - // which backend is active. Backends own their own device/swapchain/pipelines - // and translate these high-level calls into their native API. - class RendererBackend - { - public: - virtual ~RendererBackend() = default; - - // glfwWindow is an opaque GLFW handle (created NO_API for Vulkan/Metal, - // with a GL context for OpenGL). Returns false on failure. - virtual auto init(void* glfwWindow, int width, int height) -> bool = 0; - - // Creates the ImGui context + this backend's ImGui platform/render impl. - virtual auto init_ui() -> bool = 0; - virtual auto shutdown() -> void = 0; - virtual auto resize(int width, int height) -> void = 0; - - // Renders one frame: draws the current view (black hole or scene) from - // the shared state, then invokes build_ui to draw the ImGui panel on top. - virtual auto draw_frame(const glm::vec4& clear_color, - const std::function<void()>& build_ui) -> void = 0; - - // --- shared view / camera state ------------------------------------ - virtual auto set_scene_mode(bool enabled) -> void = 0; // black hole vs scene view - virtual auto is_scene_mode() const -> bool = 0; - virtual auto set_free_fly(bool enabled) -> void = 0; // free-fly vs orbital camera - virtual auto is_free_fly() const -> bool = 0; - virtual auto reset_camera() -> void = 0; - - // --- shared content ------------------------------------------------ - virtual auto set_hdri(const std::string& path) -> void = 0; - virtual auto current_hdri() const -> const std::string& = 0; - virtual auto scene_objects() -> std::vector<SceneObject>& = 0; - virtual auto set_selected_object(int index) -> void = 0; - virtual auto black_hole_params() -> BlackHoleParams& = 0; - - // --- introspection for the UI -------------------------------------- - virtual auto device_name() const -> const std::string& = 0; - }; } |
