-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsurface.cppm
More file actions
49 lines (38 loc) · 1.28 KB
/
surface.cppm
File metadata and controls
49 lines (38 loc) · 1.28 KB
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
module;
#define GLFW_INCLUDE_VULKAN
#if _WIN32
#define VK_USE_PLATFORM_WIN32_KHR
#include <GLFW/glfw3.h>
#define GLFW_EXPOSE_NATIVE_WIN32
#include <GLFW/glfw3native.h>
#include <vulkan/vulkan.h>
#else
#include <GLFW/glfw3.h>
#include <vulkan/vulkan.h>
#endif
export module vk:surface;
export import :types;
export import :utilities;
export import :instance;
export namespace vk {
inline namespace v1 {
class surface {
public:
surface(const VkInstance& p_instance, GLFWwindow* p_window_handle) : m_instance(p_instance) {
vk_check(glfwCreateWindowSurface( m_instance, p_window_handle, nullptr, &m_surface_handler), "glfwCreateWindowSurface");
}
[[nodiscard]] bool alive() const { return m_surface_handler; }
void destroy() {
if (m_surface_handler != nullptr) {
vkDestroySurfaceKHR(m_instance, m_surface_handler, nullptr);
}
vkDestroyInstance(m_instance, nullptr);
}
operator VkSurfaceKHR() const { return m_surface_handler; }
operator VkSurfaceKHR() { return m_surface_handler; }
private:
VkInstance m_instance = nullptr;
VkSurfaceKHR m_surface_handler = nullptr;
};
};
};