vOOlkan
An object oriented approach to Vulkan
Swapchain.h
Go to the documentation of this file.
1#ifndef VULKAN_SWAPCHAIN
2#define VULKAN_SWAPCHAIN
3
4#define GLFW_INCLUDE_VULKAN
5#include <GLFW/glfw3.h>
6#include <vector>
7#include <algorithm>
8
12
13
14namespace Vulkan { class Swapchain; class PhysicalDevice; class LogicalDevice; class WindowSurface; class Window; class Image; }
15
20 public:
21
30 Swapchain(const PhysicalDevice& realGpu, const LogicalDevice& virtualGpu, const WindowSurface& windowSurface, const Window& window);
31
32 Swapchain(const PhysicalDevice& realGpu, const LogicalDevice& virtualGpu, const WindowSurface& windowSurface, const Window& window, Swapchain& oldSwapchain);
33
34 ~Swapchain();
35
36 Swapchain(const Swapchain&) = delete;
37 Swapchain& operator=(const Swapchain&) = delete;
38 Swapchain(Swapchain&&) noexcept;
39 Swapchain& operator=(Swapchain&&) noexcept;
40
46 const VkSwapchainKHR& operator+() const;
47
48
49 const SwapchainOptions::SurfaceFormat& getImageFormat();
50
51 const SwapchainOptions::Capabilities& getSwapchainCapabilities();
52
58 const std::vector<Image>& getImages() const;
59
60
66 std::pair<unsigned int, unsigned int> getResolution() const;
67
68
69
77 static bool isSwapchainSupported(const PhysicalDevice& realGpu, const WindowSurface& windowSurface);
78
79 private:
80
81 //Used only for move ctor and assignment operator (move and swap)
82 Swapchain();
83
84
85 //Saves the images of the swap chain to be able to access them later on
86 void saveSwapchainImages();
87
88
89 //Creates the swapchain (it is not directly in the ctor because it is reused by recreate(...) )
90 void create(const PhysicalDevice& realGpu, const LogicalDevice& virtualGpu, const WindowSurface& windowSurface, const Window& window, VkSwapchainKHR oldSwapchain = VK_NULL_HANDLE);
91
92
93 VkSwapchainKHR swapchain;
94 SwapchainOptions::Capabilities swapchainCapabilities;
95 SwapchainOptions::SurfaceFormat swapchainSurfaceFormat;
96 SwapchainOptions::PresentMode swapchainPresentMode;
97
98 std::vector<Image> images; //the images which the swapchain holds
99 LogicalDevice const * virtualGpu;
100};
101
102#endif
An Image is an object representing what can be passed to the swapchain: the content of the image is w...
Definition: Image.h:19
A logical device is an abstraction of the physical GPU which we can mainly use to send commands.
Definition: LogicalDevice.h:15
Represents the GPU (or any other device) that will be used with Vulkan to perform computer graphics.
Definition: PhysicalDevice.h:17
Object which holds images to be presented to the WindowSurface.
Definition: Swapchain.h:19
static bool isSwapchainSupported(const PhysicalDevice &realGpu, const WindowSurface &windowSurface)
Checks whether there exist a swapchain for this physiscal GPU and windows surface.
Definition: Swapchain.cpp:100
Swapchain & operator=(const Swapchain &)=delete
~Swapchain()
Definition: Swapchain.cpp:40
std::pair< unsigned int, unsigned int > getResolution() const
Returns the width and height of the images in this swapchain.
Definition: Swapchain.cpp:95
const SwapchainOptions::Capabilities & getSwapchainCapabilities()
Definition: Swapchain.cpp:85
const SwapchainOptions::SurfaceFormat & getImageFormat()
Definition: Swapchain.cpp:81
Swapchain(const Swapchain &)=delete
const std::vector< Image > & getImages() const
Returns the images of this swapchain.
Definition: Swapchain.cpp:90
Swapchain(Swapchain &&) noexcept
Manages the creation and lifetime of an OS window.
Definition: Window.h:15
A window surface is the connection between Vulkan and the OS windows environment.
Definition: WindowSurface.h:13
Types of queue families.
Definition: Animations.h:17