diff options
author | Tyler Murphy <tylermurphy534@gmail.com> | 2022-09-21 16:49:43 -0400 |
---|---|---|
committer | Tyler Murphy <tylermurphy534@gmail.com> | 2022-09-21 16:49:43 -0400 |
commit | b1e71a70a489ee6042de216c93992c3f4d50984a (patch) | |
tree | d4d23be9f1dc102bf6a8a838a4fe736852325369 | |
parent | self define descriptors (diff) | |
download | minecraftvulkan-b1e71a70a489ee6042de216c93992c3f4d50984a.tar.gz minecraftvulkan-b1e71a70a489ee6042de216c93992c3f4d50984a.tar.bz2 minecraftvulkan-b1e71a70a489ee6042de216c93992c3f4d50984a.zip |
add openal lib
-rw-r--r-- | .gitmodules | 3 | ||||
-rw-r--r-- | Makefile | 5 | ||||
-rw-r--r-- | engine/xe_engine.cpp | 2 | ||||
-rwxr-xr-x | engine/xe_pipeline.cpp | 2 | ||||
-rw-r--r-- | engine/xe_render_system.cpp | 10 | ||||
-rw-r--r-- | engine/xe_render_system.hpp | 14 | ||||
m--------- | lib/openal | 0 | ||||
-rw-r--r-- | src/simple_renderer.cpp | 1 |
8 files changed, 28 insertions, 9 deletions
diff --git a/.gitmodules b/.gitmodules index c48bf84..ec4e33c 100644 --- a/.gitmodules +++ b/.gitmodules @@ -7,3 +7,6 @@ [submodule "stb"] path = lib/stb url = https://github.com/nothings/stb.git +[submodule "openal-soft"] + path = lib/openal + url = https://github.com/kcat/openal-soft.git @@ -5,6 +5,7 @@ INCFLAGS += -Iengine INCFLAGS += -Ilib/glfw/include INCFLAGS += -Ilib/glm INCFLAGS += -Ilib/stb +INCFLAGS += -Ilib/openal/include CCFLAGS = -std=c++17 -O2 -g CCFLAGS += $(INCFLAGS) @@ -13,6 +14,7 @@ LDFLAGS = -lm LDFLAGS += $(INCFLAGS) LDFLAGS += lib/glfw/src/libglfw3.a LDFLAGS += lib/glm/glm/libglm_static.a +LDFLAGS += lib/openal/build/libcommon.a LDFLAGS += -lvulkan SRC = $(shell find src -name "*.cpp") @@ -32,6 +34,7 @@ all: dirs libs shader build libs: cd lib/glfw && cmake . && make cd lib/glm && cmake . && make + cd lib/openal/build && cmake .. && make dirs: mkdir -p ./$(BIN) @@ -55,4 +58,4 @@ clean: rm -rf app rm -rf $(BIN) $(OBJ) rm -rf res/shaders/*.spv - rm -rf lib/glfw/CMakeCache.txt
\ No newline at end of file + rm -rf lib/glfw/CMakeCache.txt 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<XeModel> XeEngine::loadModelFromFile(const std::string &filename std::shared_ptr<XeModel> XeEngine::loadModelFromData(std::vector<XeModel::Vertex> vertices, std::vector<uint32_t> indices) { XeModel::Builder builder{}; builder.vertices = vertices; - if(&indices == NULL) { + if(indices.size() > 0) { builder.indices = indices; } return std::make_shared<XeModel>(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<uint32_t, uint32_t> uniformBindings, std::map<uint32_t, XeImage*> 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<XePipeline>( 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<XeRenderSystem> build() { - return std::make_unique<XeRenderSystem>(xeEngine, std::move(vert), std::move(frag), std::move(uniformBindings), std::move(imageBindings), std::move(pushCunstantDataSize)); + return std::make_unique<XeRenderSystem>(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<uint32_t, uint32_t> uniformBindings, std::map<uint32_t, XeImage*> 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}; diff --git a/lib/openal b/lib/openal new file mode 160000 +Subproject c52df6d78ab7131a543326cd2257f267036754e diff --git a/src/simple_renderer.cpp b/src/simple_renderer.cpp index 82c2e38..921019a 100644 --- a/src/simple_renderer.cpp +++ b/src/simple_renderer.cpp @@ -10,6 +10,7 @@ SimpleRenderer::SimpleRenderer(xe::XeEngine &xeEngine, xe::XeImage *xeImage) { .addPushConstant(sizeof(PushConstant)) .addUniformBinding(0, sizeof(UniformBuffer)) .addTextureBinding(1, xeImage) + .setCulling(true) .build(); } |