hello-tool: use surface object

This commit is contained in:
Danny Robson 2017-09-07 15:53:38 +10:00
parent d18362e542
commit 1f6f5f642b

View File

@ -2,6 +2,7 @@
#include <cruft/vk/physical_device.hpp> #include <cruft/vk/physical_device.hpp>
#include <cruft/vk/queue.hpp> #include <cruft/vk/queue.hpp>
#include <cruft/vk/device.hpp> #include <cruft/vk/device.hpp>
#include <cruft/vk/surface.hpp>
#include <GLFW/glfw3.h> #include <GLFW/glfw3.h>
#include <GLFW/glfw3native.h> #include <GLFW/glfw3native.h>
@ -129,18 +130,15 @@ main (void)
auto pdevices = cruft::vk::physical_device::find (instance); auto pdevices = cruft::vk::physical_device::find (instance);
auto &pdevice = pdevices[0]; auto &pdevice = pdevices[0];
VkSurfaceKHR surface; cruft::vk::surface surface {
cruft::vk::error::try_code ( cruft::vk::error::try_query (
glfwCreateWindowSurface (instance.id (), window, nullptr, &surface) glfwCreateWindowSurface, instance.id (), window, nullptr
); )
};
auto surface_capabilities = pdevice.surface_capabilities (surface); auto surface_capabilities = pdevice.surface_capabilities (surface);
std::vector<VkSurfaceFormatKHR> surface_formats = cruft::vk::error::try_array ( auto surface_formats = pdevice.surface_formats (surface);
vkGetPhysicalDeviceSurfaceFormatsKHR, pdevice.id (), surface auto present_modes = pdevice.present_modes (surface);
);
std::vector<VkPresentModeKHR> present_modes = cruft::vk::error::try_array (
vkGetPhysicalDeviceSurfacePresentModesKHR, pdevice.id (), surface
);
auto queues = pdevice.queue_families (); auto queues = pdevice.queue_families ();
int graphics_queue_id = -1, present_queue_id = -1; int graphics_queue_id = -1, present_queue_id = -1;
@ -150,7 +148,7 @@ main (void)
VkBool32 present_support = false; VkBool32 present_support = false;
cruft::vk::error::try_func ( cruft::vk::error::try_func (
&vkGetPhysicalDeviceSurfaceSupportKHR, pdevice.id (), i, surface, &present_support &vkGetPhysicalDeviceSurfaceSupportKHR, pdevice.id (), i, surface.id (), &present_support
); );
if (present_support) if (present_support)
present_queue_id = i; present_queue_id = i;
@ -222,7 +220,7 @@ main (void)
.sType = cruft::vk::structure_type_v<VkSwapchainCreateInfoKHR>, .sType = cruft::vk::structure_type_v<VkSwapchainCreateInfoKHR>,
.pNext = nullptr, .pNext = nullptr,
.flags = {}, .flags = {},
.surface = surface, .surface = surface.id (),
.minImageCount = image_count, .minImageCount = image_count,
.imageFormat = surface_format.format, .imageFormat = surface_format.format,
.imageColorSpace = surface_format.colorSpace, .imageColorSpace = surface_format.colorSpace,