From b256b90abbf3c601dd155db895649a145a05eacc Mon Sep 17 00:00:00 2001 From: Thraix Date: Tue, 1 Oct 2024 19:46:56 +0200 Subject: [PATCH] Minor improvements to Pipeline and Window --- CopiumEngine/src/copium/core/Window.cpp | 5 +++++ CopiumEngine/src/copium/core/Window.h | 1 + CopiumEngine/src/copium/pipeline/Pipeline.cpp | 14 ++++++++++++++ CopiumEngine/src/copium/pipeline/Pipeline.h | 1 + 4 files changed, 21 insertions(+) diff --git a/CopiumEngine/src/copium/core/Window.cpp b/CopiumEngine/src/copium/core/Window.cpp index 30ed5de..153e611 100644 --- a/CopiumEngine/src/copium/core/Window.cpp +++ b/CopiumEngine/src/copium/core/Window.cpp @@ -63,6 +63,11 @@ namespace Copium glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_NORMAL); } + bool Window::IsMouseGrabbed() const + { + return glfwGetInputMode(window, GLFW_CURSOR) == GLFW_CURSOR_DISABLED; + } + void Window::InitializeWindow(const std::string& windowName, int width, int height, WindowMode mode) { glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API); diff --git a/CopiumEngine/src/copium/core/Window.h b/CopiumEngine/src/copium/core/Window.h index 29ac83c..dafdcc9 100644 --- a/CopiumEngine/src/copium/core/Window.h +++ b/CopiumEngine/src/copium/core/Window.h @@ -38,6 +38,7 @@ namespace Copium GLFWwindow* GetWindow(); void GrabMouse(bool grap); + bool IsMouseGrabbed() const; private: void InitializeWindow(const std::string& windowName, int width, int height, WindowMode mode); diff --git a/CopiumEngine/src/copium/pipeline/Pipeline.cpp b/CopiumEngine/src/copium/pipeline/Pipeline.cpp index c64e08f..c316637 100644 --- a/CopiumEngine/src/copium/pipeline/Pipeline.cpp +++ b/CopiumEngine/src/copium/pipeline/Pipeline.cpp @@ -97,6 +97,20 @@ namespace Copium return std::make_unique(descriptorPool, descriptorSetLayouts[setIndex], bindings); } + // TODO: Attempt to move implementation to only use this instead + DescriptorSet Pipeline::CreateDescriptorSetRef(DescriptorPool& descriptorPool, int setIndex) const + { + std::set bindings; + for (auto& binding : shaderReflector.bindings) + { + if (binding.set != setIndex) + continue; + bindings.emplace(binding); + } + + return DescriptorSet{descriptorPool, descriptorSetLayouts[setIndex], bindings}; + } + void Pipeline::InitializeDescriptorSetLayout(const PipelineCreator& creator) { boundDescriptorSets.resize(creator.descriptorSetLayouts.size()); diff --git a/CopiumEngine/src/copium/pipeline/Pipeline.h b/CopiumEngine/src/copium/pipeline/Pipeline.h index de3e848..8d11b88 100644 --- a/CopiumEngine/src/copium/pipeline/Pipeline.h +++ b/CopiumEngine/src/copium/pipeline/Pipeline.h @@ -32,6 +32,7 @@ namespace Copium void BindDescriptorSets(const CommandBuffer& commandBuffer); std::unique_ptr CreateDescriptorSet(DescriptorPool& descriptorPool, int setIndex) const; + DescriptorSet CreateDescriptorSetRef(DescriptorPool& descriptorPool, int setIndex) const; private: void InitializeDescriptorSetLayout(const PipelineCreator& creator);