diff --git a/include/vkcv/Core.hpp b/include/vkcv/Core.hpp index 61ccc299939284282292f2cf58e2aa2f242c1d88..b9f4dea8230b11eaf0051e47d7c2326df7166fd0 100644 --- a/include/vkcv/Core.hpp +++ b/include/vkcv/Core.hpp @@ -79,6 +79,10 @@ namespace vkcv SyncResources m_SyncResources; uint32_t m_currentSwapchainImageIndex; + /** + * sets up swapchain images + * @param swapchainHandles of swapchain + */ void setSwapchainImages(SwapchainHandle handle); public: @@ -223,6 +227,14 @@ namespace vkcv bool supportColorAttachment = false, Multisampling multisampling = Multisampling::None); + /** + * creates a new window and returns it's handle + * @param applicationName window name + * @param windowWidth + * @param windowHeight + * @param resizeable resizeability bool + * @return windowHandle + */ [[nodiscard]] WindowHandle createWindow( const char *applicationName, @@ -230,24 +242,58 @@ namespace vkcv uint32_t windowHeight, bool resizeable); + /** + * getter for window reference + * @param handle of the window + * @return the window + */ [[nodiscard]] Window& getWindow(const WindowHandle& handle ); + /** + * gets the swapchain of the current focused window + * @return swapchain + */ [[nodiscard]] - Swapchain getSwapchainOfCurrentWindow(); + Swapchain& getSwapchainOfCurrentWindow(); + /** + * returns the swapchain reference + * @param handle of the swapchain + * @return swapchain + */ [[nodiscard]] Swapchain& getSwapchain(const SwapchainHandle& handle); + /** + * gets the swapchain handle from the window + * @param handle of the window + * @return the swapchain from getSwapchain( SwapchainHandle ) + */ [[nodiscard]] Swapchain& getSwapchain(const WindowHandle& handle); + /** + * returns the image width + * @param image handle + * @return imageWidth + */ [[nodiscard]] uint32_t getImageWidth(const ImageHandle& image); - + + /** + * returns the image height + * @param image handle + * @return imageHeight + */ [[nodiscard]] uint32_t getImageHeight(const ImageHandle& image); - + + /** + * returns the image format of the image + * @param image handle + * @return imageFormat + */ [[nodiscard]] vk::Format getImageFormat(const ImageHandle& image); diff --git a/include/vkcv/Swapchain.hpp b/include/vkcv/Swapchain.hpp index cffb268a9a529be00b311b1b367b434a7888a607..9dbd6f08bef06b157e0d20933c05cd3eae565010 100644 --- a/include/vkcv/Swapchain.hpp +++ b/include/vkcv/Swapchain.hpp @@ -36,15 +36,18 @@ namespace vkcv std::atomic<bool> m_RecreationRequired; - /** - * Constructor of a SwapChain object - * glfw is not initialized in this class because ist must be sure that there exists a context first - * glfw is already initialized by the window class - * @param surface used by the swapchain - * @param swapchain to show images in the window - * @param format - */ - // TODO: + /** + * Constructor of a SwapChain object + * glfw is not initialized in this class because ist must be sure that there exists a context first + * glfw is already initialized by the window class + * @param surface used by the swapchain + * @param swapchain to show images in the window + * @param format of the swapchain + * @param colorSpace of the swapchain + * @param presentMode of the swapchain + * @param imageCount of the swapchain + * @param extent of the swapchain + */ Swapchain(const Surface &surface, vk::SwapchainKHR swapchain, vk::Format format, @@ -54,22 +57,20 @@ namespace vkcv vk::Extent2D extent) noexcept; /** - * TODO - * - * @return + * checks if the update flag is true + * @return if an update is needed */ bool shouldUpdateSwapchain() const; /** - * TODO - * + * recreates the swapchain * context * window */ void updateSwapchain(const Context &context, const Window &window); /** - * + * signal that the swapchain needs to be recreated */ void signalSwapchainRecreation(); @@ -116,9 +117,7 @@ namespace vkcv uint32_t getImageCount() const; /** - * TODO - * - * @return + * @return the 2d extent of the swapchain */ [[nodiscard]] const vk::Extent2D& getExtent() const; diff --git a/include/vkcv/Window.hpp b/include/vkcv/Window.hpp index b0b40e87d456b3a700848e304eb56c497c942764..d996637737b5be76b78b63eef424f85c2a9b4804 100644 --- a/include/vkcv/Window.hpp +++ b/include/vkcv/Window.hpp @@ -69,8 +69,8 @@ namespace vkcv { static Window& getFocusedWindow(); /** - * - * @return + * checks if any GLFWWindows are open + * @return bool if a window is open */ static bool hasOpenWindow(); diff --git a/src/vkcv/Core.cpp b/src/vkcv/Core.cpp index f55730b80f510f6de09fbd0606c7a2ae218b4afd..838f3981615df7944bb0499826946b194f3c7742 100644 --- a/src/vkcv/Core.cpp +++ b/src/vkcv/Core.cpp @@ -680,7 +680,7 @@ namespace vkcv return m_ImageManager->getImageFormat(image); } - Swapchain Core::getSwapchainOfCurrentWindow() { + Swapchain& Core::getSwapchainOfCurrentWindow() { return m_SwapchainManager->getSwapchain(Window::getFocusedWindow().getSwapchainHandle()); } diff --git a/src/vkcv/SwapchainManager.hpp b/src/vkcv/SwapchainManager.hpp index 703314cd0a709db282ced954de7c953792fad991..58478ef09af1734bef7df217550d43af74fd8424 100644 --- a/src/vkcv/SwapchainManager.hpp +++ b/src/vkcv/SwapchainManager.hpp @@ -35,15 +35,38 @@ namespace vkcv { SwapchainManager &operator=(const SwapchainManager &other) = delete; + /** + * creates a swapchain and returns the handle + * @param window of the to creatable window + * @return the swapchainHandle of the created swapchain + */ SwapchainHandle createSwapchain(Window &window); + /** + * @param handle of the swapchain to get + * @return the reference of the swapchain + */ [[nodiscard]] Swapchain &getSwapchain(const SwapchainHandle& handle); + /** + * sets the recreation flag fot the swapchain + * @param handle of the swapchain that should be recreated + */ void signalRecreation(const SwapchainHandle& handle); + /** + * gets the swapchain images + * @param handle of the swapchain + * @return a vector of the swapchain images + */ std::vector<vk::Image> getSwapchainImages(const SwapchainHandle& handle); + /** + * creates the swapchain imageViews for the swapchain + * @param handle of the swapchain which ImageViews should be created + * @return a ov ImageViews of the swapchain + */ std::vector<vk::ImageView> createSwapchainImageViews(SwapchainHandle& handle); }; } \ No newline at end of file diff --git a/src/vkcv/WindowManager.cpp b/src/vkcv/WindowManager.cpp index 2a19094efb59abaa098d565675d9f0ae3d7e2934..d0f4dc0df9df77062dfd8dfbb21d02bee3a93adf 100644 --- a/src/vkcv/WindowManager.cpp +++ b/src/vkcv/WindowManager.cpp @@ -1,5 +1,4 @@ #include "WindowManager.hpp" -#include "vkcv/Context.hpp" namespace vkcv { diff --git a/src/vkcv/WindowManager.hpp b/src/vkcv/WindowManager.hpp index 01846b51197bdbaed3a3a799973702b9fb79dcb9..66186c494c38a5af46ffe34cc31b2e86bbbc95db 100644 --- a/src/vkcv/WindowManager.hpp +++ b/src/vkcv/WindowManager.hpp @@ -18,7 +18,7 @@ namespace vkcv { private: std::vector<Window*> m_windows; - + void destroyWindowById(uint64_t id); public: @@ -34,12 +34,25 @@ namespace vkcv { WindowManager &operator=(const WindowManager &other) = delete; + /** + * creates a window and returns it's handle + * @param swapchainManager for swapchain creation + * @param applicationName name of the window + * @param windowWidth + * @param windowHeight + * @param resizeable if the window is resizable + * @return window handle + */ WindowHandle createWindow(SwapchainManager &swapchainManager, const char *applicationName, uint32_t windowWidth, uint32_t windowHeight, bool resizeable); + /** + * @param handle of the window to get + * @return the reference of the window + */ [[nodiscard]] Window &getWindow(const WindowHandle handle) const; - + }; } \ No newline at end of file