#pragma once #include "hk_device.hpp" #include "hk_swap_chain.hpp" #include "hk_window.hpp" #include "hk_game_object.hpp" // std #include #include namespace hk { class Renderer { public: Renderer(Window &window, Device &device); ~Renderer(); Renderer(const Renderer &) = delete; Renderer &operator=(const Renderer &) = delete; VkRenderPass getSwapChainRenderPass() const { return m_swapChain->getRenderPass(); } bool isFrameInProgress() const {return m_isFrameStarted;} VkCommandBuffer getCurrentCommandBuffer() const { assert(m_isFrameStarted && "Cannot get command buffer when frame not in progress"); return m_commandBuffers[m_currentImageIndex]; } VkCommandBuffer beginFrame(); void endFrame(); void beginSwapChainRenderPass(VkCommandBuffer commandBuffer); void endSwapChainRenderPass(VkCommandBuffer commandBuffer); private: void createCommandBuffers(); void freeCommandBuffers(); void drawFrame(); void recreateSwapChain(); Window& m_window; Device& m_device; std::unique_ptr m_swapChain; std::vector m_commandBuffers; uint32_t m_currentImageIndex; bool m_isFrameStarted; }; }