SimpleGL  1.1.0
A framework for platform independent rendering
surface.cpp
Go to the documentation of this file.
1 
10 
11 #include <stdexcept>
12 
13 #include <GLFW/glfw3.h>
14 
16 
17 using namespace std;
18 
19 namespace sgl {
20 
21  Surface::Surface(WindowVK* window) {
22  VkInstance instance = VulkanContext::getCurrent()->getInstance()->getHandle();
23 
24  /* Create the window surface */
25  if (glfwCreateWindowSurface(instance, window->getHandle(), nullptr, &handle) != VK_SUCCESS) {
26  throw runtime_error("Could not create a window surface!");
27  }
28  }
29 
30  Surface::~Surface(void) {
31  VkInstance instance = VulkanContext::getCurrent()->getInstance()->getHandle();
32 
33  /* Destroy the window surface */
34  vkDestroySurfaceKHR(instance, handle, nullptr);
35  }
36 
37  VkSurfaceKHR Surface::getHandle() {
38  return handle;
39  }
40 }
This class provides a GLFW window with a Vulkan instance.
Generic namespace for the SimpleGL framework.
Definition: application.hpp:18
GLFWwindow * getHandle()
Returns the handle of the window.
Definition: glfw_window.cpp:28