FastEngine 0.9.3
A multiplayer oriented 2D engine made with Vulkan.
Loading...
Searching...
No Matches
C_swapChain.hpp
1/*
2 * Copyright 2024 Guillaume Guillet
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef _FGE_VULKAN_C_SWAPCHAIN_HPP_INCLUDED
18#define _FGE_VULKAN_C_SWAPCHAIN_HPP_INCLUDED
19
20#include "FastEngine/fge_extern.hpp"
21#include "volk.h"
22#include <vector>
23
24namespace fge::vulkan
25{
26
27class PhysicalDevice;
28class LogicalDevice;
29class Surface;
30
31class FGE_API SwapChain
32{
33public:
34 SwapChain();
35 SwapChain(SwapChain const& r) = delete;
36 SwapChain(SwapChain&& r) noexcept;
37 ~SwapChain();
38
39 SwapChain& operator=(SwapChain const& r) = delete;
40 SwapChain& operator=(SwapChain&& r) noexcept = delete;
41
42 void create(VkExtent2D actualExtent,
43 LogicalDevice const& logicalDevice,
44 PhysicalDevice const& physicalDevice,
45 Surface const& surface,
46 VkPresentModeKHR wantedPresentMode);
47 void destroy();
48
49 [[nodiscard]] VkSwapchainKHR getSwapChain() const;
50 [[nodiscard]] std::vector<VkImage> const& getSwapChainImages() const;
51 [[nodiscard]] VkFormat getSwapChainImageFormat() const;
52 [[nodiscard]] VkExtent2D getSwapChainExtent() const;
53
54 [[nodiscard]] std::vector<VkImageView> const& getSwapChainImageViews() const;
55
56 [[nodiscard]] LogicalDevice const* getLogicalDevice() const;
57
58 static VkSurfaceFormatKHR chooseSwapSurfaceFormat(std::vector<VkSurfaceFormatKHR> const& availableFormats);
59 static VkPresentModeKHR chooseSwapPresentMode(std::vector<VkPresentModeKHR> const& availablePresentModes,
60 VkPresentModeKHR wantedPresentMode);
61 static VkExtent2D chooseSwapExtent(VkSurfaceCapabilitiesKHR const& capabilities, VkExtent2D actualExtent);
62
63private:
64 void createImageViews();
65
66 VkSwapchainKHR g_swapChain;
67 std::vector<VkImage> g_swapChainImages;
68 VkFormat g_swapChainImageFormat;
69 VkExtent2D g_swapChainExtent;
70
71 std::vector<VkImageView> g_swapChainImageViews;
72
73 VkPresentModeKHR g_presentMode;
74
75 LogicalDevice const* g_logicalDevice;
76};
77
78} // namespace fge::vulkan
79
80#endif //_FGE_VULKAN_C_SWAPCHAIN_HPP_INCLUDED
Logical device abstraction.
Definition C_logicalDevice.hpp:37
Vulkan physical device abstraction.
Definition C_physicalDevice.hpp:34
Vulkan surface abstraction.
Definition vulkan/C_surface.hpp:42
Definition C_swapChain.hpp:32