]> git.tdb.fi Git - libs/gui.git/blob - source/graphics/vulkancontext.h
Add a class for creating Vulkan graphics contexts
[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         virtual ~vulkan_error() throw() { }
18
19 private:
20         static std::string get_error_message(unsigned);
21 };
22
23 struct VulkanOptions
24 {
25         bool enable_validation;
26         bool enable_debug_report;
27
28         VulkanOptions();
29 };
30
31 class VulkanContext
32 {
33 private:
34         struct Private;
35
36         Display &display;
37         Window &window;
38         Private *priv;
39
40 public:
41         VulkanContext(Window &, const VulkanOptions & = VulkanOptions());
42 private:
43         void platform_init(const VulkanOptions &);
44 public:
45         ~VulkanContext();
46
47         template<typename T>
48         T get_function(const std::string &name) const
49         { return reinterpret_cast<T>(_get_function(name)); }
50
51 private:
52         void (*_get_function(const std::string &) const)();
53
54 public:
55         const Private &get_private() const { return *priv; }
56 };
57
58 } // namespace Graphics
59 } // namespace Msp
60
61 #endif