add openal lib

This commit is contained in:
Tyler Murphy 2022-09-21 16:49:43 -04:00
parent 76bae46dbc
commit b1e71a70a4
8 changed files with 29 additions and 9 deletions

3
.gitmodules vendored
View file

@ -7,3 +7,6 @@
[submodule "stb"] [submodule "stb"]
path = lib/stb path = lib/stb
url = https://github.com/nothings/stb.git url = https://github.com/nothings/stb.git
[submodule "openal-soft"]
path = lib/openal
url = https://github.com/kcat/openal-soft.git

View file

@ -5,6 +5,7 @@ INCFLAGS += -Iengine
INCFLAGS += -Ilib/glfw/include INCFLAGS += -Ilib/glfw/include
INCFLAGS += -Ilib/glm INCFLAGS += -Ilib/glm
INCFLAGS += -Ilib/stb INCFLAGS += -Ilib/stb
INCFLAGS += -Ilib/openal/include
CCFLAGS = -std=c++17 -O2 -g CCFLAGS = -std=c++17 -O2 -g
CCFLAGS += $(INCFLAGS) CCFLAGS += $(INCFLAGS)
@ -13,6 +14,7 @@ LDFLAGS = -lm
LDFLAGS += $(INCFLAGS) LDFLAGS += $(INCFLAGS)
LDFLAGS += lib/glfw/src/libglfw3.a LDFLAGS += lib/glfw/src/libglfw3.a
LDFLAGS += lib/glm/glm/libglm_static.a LDFLAGS += lib/glm/glm/libglm_static.a
LDFLAGS += lib/openal/build/libcommon.a
LDFLAGS += -lvulkan LDFLAGS += -lvulkan
SRC = $(shell find src -name "*.cpp") SRC = $(shell find src -name "*.cpp")
@ -32,6 +34,7 @@ all: dirs libs shader build
libs: libs:
cd lib/glfw && cmake . && make cd lib/glfw && cmake . && make
cd lib/glm && cmake . && make cd lib/glm && cmake . && make
cd lib/openal/build && cmake .. && make
dirs: dirs:
mkdir -p ./$(BIN) mkdir -p ./$(BIN)

View file

@ -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) { std::shared_ptr<XeModel> XeEngine::loadModelFromData(std::vector<XeModel::Vertex> vertices, std::vector<uint32_t> indices) {
XeModel::Builder builder{}; XeModel::Builder builder{};
builder.vertices = vertices; builder.vertices = vertices;
if(&indices == NULL) { if(indices.size() > 0) {
builder.indices = indices; builder.indices = indices;
} }
return std::make_shared<XeModel>(xeDevice, builder); return std::make_shared<XeModel>(xeDevice, builder);

View file

@ -145,7 +145,7 @@ namespace xe {
configInfo.rasterizationInfo.rasterizerDiscardEnable = VK_FALSE; configInfo.rasterizationInfo.rasterizerDiscardEnable = VK_FALSE;
configInfo.rasterizationInfo.polygonMode = VK_POLYGON_MODE_FILL; configInfo.rasterizationInfo.polygonMode = VK_POLYGON_MODE_FILL;
configInfo.rasterizationInfo.lineWidth = 1.0f; 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.frontFace = VK_FRONT_FACE_CLOCKWISE;
configInfo.rasterizationInfo.depthBiasEnable = VK_FALSE; configInfo.rasterizationInfo.depthBiasEnable = VK_FALSE;
configInfo.rasterizationInfo.depthBiasConstantFactor = 0.0f; configInfo.rasterizationInfo.depthBiasConstantFactor = 0.0f;

View file

@ -22,7 +22,8 @@ XeRenderSystem::XeRenderSystem(
std::string frag, std::string frag,
std::map<uint32_t, uint32_t> uniformBindings, std::map<uint32_t, uint32_t> uniformBindings,
std::map<uint32_t, XeImage*> imageBindings, std::map<uint32_t, XeImage*> imageBindings,
uint32_t pushCunstantDataSize uint32_t pushCunstantDataSize,
bool cullingEnabled
) : xeDevice{xeEngine.xeDevice}, ) : xeDevice{xeEngine.xeDevice},
xeRenderer{xeEngine.xeRenderer}, xeRenderer{xeEngine.xeRenderer},
xeDescriptorPool{xeEngine.xeDescriptorPool}, xeDescriptorPool{xeEngine.xeDescriptorPool},
@ -34,7 +35,7 @@ XeRenderSystem::XeRenderSystem(
createUniformBuffers(); createUniformBuffers();
createDescriptorSets(); createDescriptorSets();
createPipelineLayout(); 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"); assert(pipelineLayout != nullptr && "Cannot create pipeline before pipeline layout");
PipelineConfigInfo pipelineConfig{}; PipelineConfigInfo pipelineConfig{};
XePipeline::defaultPipelineConfigInfo(pipelineConfig); XePipeline::defaultPipelineConfigInfo(pipelineConfig);
if (cullingEnabled) {
pipelineConfig.rasterizationInfo.cullMode = VK_CULL_MODE_BACK_BIT;
}
pipelineConfig.renderPass = renderPass; pipelineConfig.renderPass = renderPass;
pipelineConfig.pipelineLayout = pipelineLayout; pipelineConfig.pipelineLayout = pipelineLayout;
xePipeline = std::make_unique<XePipeline>( xePipeline = std::make_unique<XePipeline>(

View file

@ -36,8 +36,13 @@ class XeRenderSystem {
return *this; return *this;
} }
Builder& setCulling(bool enabled) {
cullingEnabled = enabled;
return *this;
}
std::unique_ptr<XeRenderSystem> build() { 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: private:
@ -49,6 +54,8 @@ class XeRenderSystem {
std::string vert; std::string vert;
std::string frag; std::string frag;
bool cullingEnabled{false};
XeEngine &xeEngine; XeEngine &xeEngine;
}; };
@ -58,7 +65,8 @@ class XeRenderSystem {
std::string frag, std::string frag,
std::map<uint32_t, uint32_t> uniformBindings, std::map<uint32_t, uint32_t> uniformBindings,
std::map<uint32_t, XeImage*> imageBindings, std::map<uint32_t, XeImage*> imageBindings,
uint32_t pushCunstantDataSize uint32_t pushCunstantDataSize,
bool cullingEnabled
); );
~XeRenderSystem(); ~XeRenderSystem();
@ -81,7 +89,7 @@ class XeRenderSystem {
void createDescriptorSets(); void createDescriptorSets();
void updateDescriptorSet(int frameIndex, bool allocate); void updateDescriptorSet(int frameIndex, bool allocate);
void createPipelineLayout(); 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 boundPipeline{false};
bool boundDescriptor{false}; bool boundDescriptor{false};

1
lib/openal Submodule

@ -0,0 +1 @@
Subproject commit c52df6d78ab7131a543326cd2257f267036754e1

View file

@ -10,6 +10,7 @@ SimpleRenderer::SimpleRenderer(xe::XeEngine &xeEngine, xe::XeImage *xeImage) {
.addPushConstant(sizeof(PushConstant)) .addPushConstant(sizeof(PushConstant))
.addUniformBinding(0, sizeof(UniformBuffer)) .addUniformBinding(0, sizeof(UniformBuffer))
.addTextureBinding(1, xeImage) .addTextureBinding(1, xeImage)
.setCulling(true)
.build(); .build();
} }