From 2f99eee7c5f0088e3c39c21a5d2efd7335953ae8 Mon Sep 17 00:00:00 2001 From: Tyler Murphy Date: Mon, 19 Sep 2022 16:35:45 -0400 Subject: even more refactoring --- engine/xe_engine.cpp | 42 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 36 insertions(+), 6 deletions(-) (limited to 'engine/xe_engine.cpp') diff --git a/engine/xe_engine.cpp b/engine/xe_engine.cpp index ff9c95b..6de221a 100644 --- a/engine/xe_engine.cpp +++ b/engine/xe_engine.cpp @@ -1,15 +1,17 @@ #include "xe_engine.hpp" #include "xe_descriptors.hpp" +#include namespace xe { XeEngine::XeEngine(int width, int height, std::string name) - : xeWindow{width, height, name}, xeDevice{xeWindow}, xeRenderer{xeWindow, xeDevice} { + : xeWindow{width, height, name}, + xeDevice{xeWindow}, + xeRenderer{xeWindow, xeDevice}, + xeCamera{} { loadDescriptors(); }; -XeEngine::~XeEngine() {}; - void XeEngine::loadDescriptors() { xeDescriptorPool = XeDescriptorPool::Builder(xeDevice) .setMaxSets(XeSwapChain::MAX_FRAMES_IN_FLIGHT) @@ -22,12 +24,12 @@ void XeEngine::loadDescriptors() { .build(); } -std::unique_ptr XeEngine::createRenderSystem(const std::string &vert, const std::string &frag, typename pushCunstant, typename uniformBuffer) { +std::unique_ptr XeEngine::createRenderSystem(const std::string &vert, const std::string &frag, uint32_t pushCunstantDataSize, uint32_t uniformBufferDataSize) { return std::make_unique( xeDevice, xeRenderer, - xeDescriptorPool, - xeDescriptorSetLayout, + *xeDescriptorPool, + *xeDescriptorSetLayout, vert, frag, pushCunstantDataSize, @@ -35,4 +37,32 @@ std::unique_ptr XeEngine::createRenderSystem(const std::string & ); } +std::shared_ptr XeEngine::createModel(const std::string &filename) { + return XeModel::createModelFromFile(xeDevice, filename); +} + +void XeEngine::render( + XeRenderSystem& xeRenderSystem, + std::vector& gameObjects, + void* pushConstantData, + uint32_t pushConstantSize, + void* uniformBufferData, + uint32_t uniformBufferSize) { + + auto commandBuffer = xeRenderer.getCurrentCommandBuffer(); + xeRenderer.beginSwapChainRenderPass(commandBuffer); + + xeRenderSystem.renderGameObjects( + xeRenderer.getFrameIndex(), + commandBuffer, + gameObjects, + pushConstantData, + pushConstantSize, + uniformBufferData, + uniformBufferSize + ); + + xeRenderer.endSwapChainRenderPass(commandBuffer); +} + } \ No newline at end of file -- cgit v1.2.3-freya