]> git.tdb.fi Git - libs/gui.git/blob - source/graphics/vulkancontext.h
666a2b06daafdca22d4467efa5d38d857ef155d6
[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         bool enable_geometry_shader;
28         bool enable_tessellation_shader;
29
30         VulkanOptions();
31 };
32
33 class VulkanContext
34 {
35 private:
36         struct Private;
37
38         Display &display;
39         Window &window;
40         Private *priv;
41
42 public:
43         VulkanContext(Window &, const VulkanOptions & = VulkanOptions());
44 private:
45         void platform_init(const VulkanOptions &);
46 public:
47         ~VulkanContext();
48
49         template<typename T>
50         T get_function(const std::string &name) const
51         { return reinterpret_cast<T>(_get_function(name)); }
52
53 private:
54         void (*_get_function(const std::string &) const)();
55
56 public:
57         const Private &get_private() const { return *priv; }
58 };
59
60 } // namespace Graphics
61 } // namespace Msp
62
63 #endif