From b1e71a70a489ee6042de216c93992c3f4d50984a Mon Sep 17 00:00:00 2001 From: Tyler Murphy Date: Wed, 21 Sep 2022 16:49:43 -0400 Subject: add openal lib --- engine/xe_engine.cpp | 2 +- engine/xe_pipeline.cpp | 2 +- engine/xe_render_system.cpp | 10 +++++++--- engine/xe_render_system.hpp | 14 +++++++++++--- 4 files changed, 20 insertions(+), 8 deletions(-) (limited to 'engine') diff --git a/engine/xe_engine.cpp b/engine/xe_engine.cpp index 6a971c9..9384094 100644 --- a/engine/xe_engine.cpp +++ b/engine/xe_engine.cpp @@ -27,7 +27,7 @@ std::shared_ptr XeEngine::loadModelFromFile(const std::string &filename std::shared_ptr XeEngine::loadModelFromData(std::vector vertices, std::vector indices) { XeModel::Builder builder{}; builder.vertices = vertices; - if(&indices == NULL) { + if(indices.size() > 0) { builder.indices = indices; } return std::make_shared(xeDevice, builder); diff --git a/engine/xe_pipeline.cpp b/engine/xe_pipeline.cpp index c34d2a9..d06d09b 100755 --- a/engine/xe_pipeline.cpp +++ b/engine/xe_pipeline.cpp @@ -145,7 +145,7 @@ namespace xe { configInfo.rasterizationInfo.rasterizerDiscardEnable = VK_FALSE; configInfo.rasterizationInfo.polygonMode = VK_POLYGON_MODE_FILL; configInfo.rasterizationInfo.lineWidth = 1.0f; - configInfo.rasterizationInfo.cullMode = VK_CULL_MODE_BACK_BIT; + configInfo.rasterizationInfo.cullMode = VK_CULL_MODE_NONE; configInfo.rasterizationInfo.frontFace = VK_FRONT_FACE_CLOCKWISE; configInfo.rasterizationInfo.depthBiasEnable = VK_FALSE; configInfo.rasterizationInfo.depthBiasConstantFactor = 0.0f; diff --git a/engine/xe_render_system.cpp b/engine/xe_render_system.cpp index 0158e34..1e638ad 100644 --- a/engine/xe_render_system.cpp +++ b/engine/xe_render_system.cpp @@ -22,7 +22,8 @@ XeRenderSystem::XeRenderSystem( std::string frag, std::map uniformBindings, std::map imageBindings, - uint32_t pushCunstantDataSize + uint32_t pushCunstantDataSize, + bool cullingEnabled ) : xeDevice{xeEngine.xeDevice}, xeRenderer{xeEngine.xeRenderer}, xeDescriptorPool{xeEngine.xeDescriptorPool}, @@ -34,7 +35,7 @@ XeRenderSystem::XeRenderSystem( createUniformBuffers(); createDescriptorSets(); createPipelineLayout(); - createPipeline(xeRenderer.getSwapChainRenderPass(), vert, frag); + createPipeline(xeRenderer.getSwapChainRenderPass(), vert, frag, cullingEnabled); } @@ -163,11 +164,14 @@ void XeRenderSystem::createPipelineLayout() { } -void XeRenderSystem::createPipeline(VkRenderPass renderPass, std::string vert, std::string frag) { +void XeRenderSystem::createPipeline(VkRenderPass renderPass, std::string vert, std::string frag, bool cullingEnabled) { assert(pipelineLayout != nullptr && "Cannot create pipeline before pipeline layout"); PipelineConfigInfo pipelineConfig{}; XePipeline::defaultPipelineConfigInfo(pipelineConfig); + if (cullingEnabled) { + pipelineConfig.rasterizationInfo.cullMode = VK_CULL_MODE_BACK_BIT; + } pipelineConfig.renderPass = renderPass; pipelineConfig.pipelineLayout = pipelineLayout; xePipeline = std::make_unique( diff --git a/engine/xe_render_system.hpp b/engine/xe_render_system.hpp index ae68f53..a8b4145 100644 --- a/engine/xe_render_system.hpp +++ b/engine/xe_render_system.hpp @@ -36,8 +36,13 @@ class XeRenderSystem { return *this; } + Builder& setCulling(bool enabled) { + cullingEnabled = enabled; + return *this; + } + std::unique_ptr build() { - return std::make_unique(xeEngine, std::move(vert), std::move(frag), std::move(uniformBindings), std::move(imageBindings), std::move(pushCunstantDataSize)); + return std::make_unique(xeEngine, std::move(vert), std::move(frag), std::move(uniformBindings), std::move(imageBindings), std::move(pushCunstantDataSize), std::move(cullingEnabled)); } private: @@ -49,6 +54,8 @@ class XeRenderSystem { std::string vert; std::string frag; + bool cullingEnabled{false}; + XeEngine &xeEngine; }; @@ -58,7 +65,8 @@ class XeRenderSystem { std::string frag, std::map uniformBindings, std::map imageBindings, - uint32_t pushCunstantDataSize + uint32_t pushCunstantDataSize, + bool cullingEnabled ); ~XeRenderSystem(); @@ -81,7 +89,7 @@ class XeRenderSystem { void createDescriptorSets(); void updateDescriptorSet(int frameIndex, bool allocate); void createPipelineLayout(); - void createPipeline(VkRenderPass renderPass, std::string vert, std::string frag); + void createPipeline(VkRenderPass renderPass, std::string vert, std::string frag, bool cullingEnabled); bool boundPipeline{false}; bool boundDescriptor{false}; -- cgit v1.2.3-freya