]> git.tdb.fi Git - libs/gui.git/blob - source/graphics/vulkancontext.h
211f86a8af47a305ba0c8bc7bb515aafdc3dda03
[libs/gui.git] / source / graphics / vulkancontext.h
1 #ifndef MSP_GRAPHICS_VULKANCONTEXT_H_
2 #define MSP_GRAPHICS_VULKANCONTEXT_H_
3
4 #include <stdexcept>
5 #include <string>
6
7 namespace Msp {
8 namespace Graphics {
9
10 class Display;
11 class Window;
12
13 class vulkan_error: public std::runtime_error
14 {
15 public:
16         vulkan_error(unsigned, const char *);
17
18 private:
19         static std::string get_error_message(unsigned);
20 };
21
22 struct VulkanOptions
23 {
24         bool enable_validation = false;
25         bool enable_debug_report = false;
26         bool enable_geometry_shader = false;
27         bool enable_tessellation_shader = false;
28 };
29
30 class VulkanContext
31 {
32 private:
33         struct Private;
34
35         Display &display;
36         Window &window;
37         Private *priv = nullptr;
38
39 public:
40         VulkanContext(Window &, const VulkanOptions & = VulkanOptions());
41 private:
42         void platform_init(const VulkanOptions &);
43 public:
44         ~VulkanContext();
45
46         template<typename T>
47         T get_function(const std::string &name) const
48         { return reinterpret_cast<T>(_get_function(name)); }
49
50 private:
51         void (*_get_function(const std::string &) const)();
52
53 public:
54         const Private &get_private() const { return *priv; }
55 };
56
57 } // namespace Graphics
58 } // namespace Msp
59
60 #endif