aboutsummaryrefslogtreecommitdiff
path: root/src/rendering/scene_renderer.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/rendering/scene_renderer.h
parente3aa33fc9a99d8b817bda42a567a4c347e18ab32 (diff)
[feat]: complete RHI api
Diffstat (limited to 'src/rendering/scene_renderer.h')
-rw-r--r--src/rendering/scene_renderer.h56
1 files changed, 56 insertions, 0 deletions
diff --git a/src/rendering/scene_renderer.h b/src/rendering/scene_renderer.h
new file mode 100644
index 0000000..eafd56e
--- /dev/null
+++ b/src/rendering/scene_renderer.h
@@ -0,0 +1,56 @@
+#pragma once
+
+#include "rhi.h"
+#include "renderer_backend.h" // SceneObject
+#include <glm/glm.hpp>
+#include <vector>
+
+namespace Donut
+{
+ // The world-builder scene view (skybox + lit spheres + reference grid),
+ // written ONCE against the RHI so it renders identically on every backend.
+ // The Application owns the camera, the object list and the HDRI cubemap and
+ // passes them in each frame; this class owns only the GPU resources (meshes,
+ // pipelines, per-object uniform buffers) and records the draws.
+ struct CameraView
+ {
+ glm::mat4 view;
+ glm::mat4 projection;
+ glm::vec3 position;
+ int fb_width = 1;
+ int fb_height = 1;
+ };
+
+ class SceneRenderer
+ {
+ public:
+ // Builds the grid/sphere/skybox meshes and pipelines on the given device.
+ auto init(RHI::Device& device) -> bool;
+
+ // Records the scene into the currently-open swapchain render pass. `cubemap`
+ // is the shared HDRI environment (sphere ambient + skybox background).
+ auto render(RHI::CommandList& cmd, const CameraView& cam,
+ const std::vector<SceneObject>& objects, int selected,
+ RHI::Texture* cubemap) -> void;
+
+ private:
+ static constexpr int MAX_OBJECTS = 64;
+
+ RHI::Device* m_device = nullptr;
+
+ Ref<RHI::Pipeline> m_grid_pipeline;
+ Ref<RHI::Buffer> m_grid_vb;
+ Ref<RHI::Buffer> m_grid_ubo;
+ int m_grid_vertex_count = 0;
+
+ Ref<RHI::Pipeline> m_sphere_pipeline;
+ Ref<RHI::Buffer> m_sphere_vb;
+ Ref<RHI::Buffer> m_sphere_ib;
+ int m_sphere_index_count = 0;
+ std::vector<Ref<RHI::Buffer>> m_sphere_ubos; // one per object slot
+
+ Ref<RHI::Pipeline> m_skybox_pipeline;
+ Ref<RHI::Buffer> m_skybox_vb;
+ Ref<RHI::Buffer> m_skybox_ubo;
+ };
+}