aboutsummaryrefslogtreecommitdiff
path: root/src/platform/vulkan/vulkan_renderer.h
diff options
context:
space:
mode:
authorhachem <im@hachem.wtf>2026-08-20 02:27:02 +0200
committerhachem <im@hachem.wtf>2026-08-20 02:40:07 +0200
commit5b361d81dbd2af0d0e99b9eb1adebea76ff05db0 (patch)
tree34db1df17e8c7248aeeb92156d635d31c2484e3f /src/platform/vulkan/vulkan_renderer.h
parente3abaaf59777258ba06705135a0cafcb5918ad12 (diff)
[chore]: MASSIVE refactor + more vulkan bs
Diffstat (limited to 'src/platform/vulkan/vulkan_renderer.h')
-rw-r--r--src/platform/vulkan/vulkan_renderer.h40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/platform/vulkan/vulkan_renderer.h b/src/platform/vulkan/vulkan_renderer.h
new file mode 100644
index 0000000..97a4e38
--- /dev/null
+++ b/src/platform/vulkan/vulkan_renderer.h
@@ -0,0 +1,40 @@
+#pragma once
+
+#include <glm/glm.hpp>
+#include <functional>
+
+// Live-window Vulkan backend: owns the instance, surface, device, swapchain,
+// render pass, framebuffers and per-frame synchronization, and drives the
+// acquire -> record -> submit -> present loop. Pure-C++ header (no vulkan.h /
+// glfw leak); the GLFW window is passed as an opaque handle.
+namespace Donut
+{
+ // Must be called BEFORE glfwInit() when the Vulkan API is selected: points
+ // GLFW at the loader the app links against (GLFW's own dlopen fails on
+ // macOS/Homebrew) and configures the MoltenVK ICD / layer paths.
+ auto vulkan_prepare_glfw() -> void;
+
+ class VulkanRenderer
+ {
+ public:
+ VulkanRenderer();
+ ~VulkanRenderer();
+
+ // glfwWindow must be a GLFW window created with GLFW_NO_API.
+ auto init(void* glfwWindow, int width, int height) -> bool;
+ auto shutdown() -> void;
+
+ // Creates the ImGui context + Vulkan/GLFW backends. Call after init().
+ auto init_im_gui() -> bool;
+
+ // Renders + presents one frame: clears to clearColor, then (if init_im_gui
+ // ran) opens an ImGui frame, invokes buildUI to populate it, and draws it.
+ auto draw_frame(const glm::vec4& clearColor, const std::function<void()>& buildUI = {}) -> void;
+
+ auto on_resize(int width, int height) -> void;
+
+ private:
+ struct Impl;
+ Impl* m_impl = nullptr;
+ };
+}