]> git.tdb.fi Git - libs/gui.git/blobdiff - source/graphics/vulkancontext.h
Add a class for creating Vulkan graphics contexts
[libs/gui.git] / source / graphics / vulkancontext.h
diff --git a/source/graphics/vulkancontext.h b/source/graphics/vulkancontext.h
new file mode 100644 (file)
index 0000000..44ac4a5
--- /dev/null
@@ -0,0 +1,61 @@
+#ifndef MSP_GRAPHICS_VULKANCONTEXT_H_
+#define MSP_GRAPHICS_VULKANCONTEXT_H_
+
+#include <stdexcept>
+#include <string>
+
+namespace Msp {
+namespace Graphics {
+
+class Display;
+class Window;
+
+class vulkan_error: public std::runtime_error
+{
+public:
+       vulkan_error(unsigned, const char *);
+       virtual ~vulkan_error() throw() { }
+
+private:
+       static std::string get_error_message(unsigned);
+};
+
+struct VulkanOptions
+{
+       bool enable_validation;
+       bool enable_debug_report;
+
+       VulkanOptions();
+};
+
+class VulkanContext
+{
+private:
+       struct Private;
+
+       Display &display;
+       Window &window;
+       Private *priv;
+
+public:
+       VulkanContext(Window &, const VulkanOptions & = VulkanOptions());
+private:
+       void platform_init(const VulkanOptions &);
+public:
+       ~VulkanContext();
+
+       template<typename T>
+       T get_function(const std::string &name) const
+       { return reinterpret_cast<T>(_get_function(name)); }
+
+private:
+       void (*_get_function(const std::string &) const)();
+
+public:
+       const Private &get_private() const { return *priv; }
+};
+
+} // namespace Graphics
+} // namespace Msp
+
+#endif