-
Notifications
You must be signed in to change notification settings - Fork 35
/
Copy pathsurface.cc
74 lines (57 loc) · 1.92 KB
/
surface.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#include <vkpp/surface.hh>
#include <vkpp/debug_marker.hh>
#include <vkpp/exception.hh>
namespace vkpp {
Surface::Surface(VkInstance& instance,
VkSurfaceKHR& surface)
: instance { instance },
handle { surface } { }
Surface::~Surface() noexcept {
if (handle != VK_NULL_HANDLE) {
vkDestroySurfaceKHR(instance, handle, nullptr);
}
}
Surface::Surface(Surface&& surface) noexcept {
swap(*this, surface);
}
Surface& Surface::operator=(Surface&& surface) noexcept {
swap(*this, surface);
return *this;
}
void swap(Surface& lhs, Surface& rhs) {
using std::swap;
swap(lhs.handle, rhs.handle);
swap(lhs.instance, rhs.instance);
swap(lhs.window, rhs.window);
}
VkSurfaceKHR& Surface::get_handle() {
return handle;
}
void Surface::set_glfw_window(vkhr::Window& window) {
this->window = &window;
}
vkhr::Window& Surface::get_glfw_window() const {
return *this->window;
}
void Surface::set_capabilities(const VkSurfaceCapabilitiesKHR& capabilities) {
this->capabilities = capabilities;
}
void Surface::set_presentation_modes(const std::vector<VkPresentModeKHR>& modes) {
this->present_modes = modes;
}
void Surface::set_formats(const std::vector<VkSurfaceFormatKHR>& formats) {
this->formats = formats;
}
const VkSurfaceCapabilitiesKHR& Surface::get_capabilities() const {
return capabilities;
}
const std::vector<VkPresentModeKHR>& Surface::get_presentation_modes() const {
return present_modes;
}
const std::vector<VkSurfaceFormatKHR>& Surface::get_formats() const {
return formats;
}
void Surface::label(VkDevice device) {
DebugMarker::object_name(device, *this, VK_OBJECT_TYPE_SURFACE_KHR, "Window Surface");
}
}