From 1f6f5f642b6355aeea8fa2acc7c1a3741efdc054 Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Thu, 7 Sep 2017 15:53:38 +1000 Subject: [PATCH] hello-tool: use surface object --- tools/hello.cpp | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/tools/hello.cpp b/tools/hello.cpp index 93cbb83..992bc92 100644 --- a/tools/hello.cpp +++ b/tools/hello.cpp @@ -2,6 +2,7 @@ #include #include #include +#include #include #include @@ -129,18 +130,15 @@ main (void) auto pdevices = cruft::vk::physical_device::find (instance); auto &pdevice = pdevices[0]; - VkSurfaceKHR surface; - cruft::vk::error::try_code ( - glfwCreateWindowSurface (instance.id (), window, nullptr, &surface) - ); + cruft::vk::surface surface { + cruft::vk::error::try_query ( + glfwCreateWindowSurface, instance.id (), window, nullptr + ) + }; auto surface_capabilities = pdevice.surface_capabilities (surface); - std::vector surface_formats = cruft::vk::error::try_array ( - vkGetPhysicalDeviceSurfaceFormatsKHR, pdevice.id (), surface - ); - std::vector present_modes = cruft::vk::error::try_array ( - vkGetPhysicalDeviceSurfacePresentModesKHR, pdevice.id (), surface - ); + auto surface_formats = pdevice.surface_formats (surface); + auto present_modes = pdevice.present_modes (surface); auto queues = pdevice.queue_families (); int graphics_queue_id = -1, present_queue_id = -1; @@ -150,7 +148,7 @@ main (void) VkBool32 present_support = false; cruft::vk::error::try_func ( - &vkGetPhysicalDeviceSurfaceSupportKHR, pdevice.id (), i, surface, &present_support + &vkGetPhysicalDeviceSurfaceSupportKHR, pdevice.id (), i, surface.id (), &present_support ); if (present_support) present_queue_id = i; @@ -222,7 +220,7 @@ main (void) .sType = cruft::vk::structure_type_v, .pNext = nullptr, .flags = {}, - .surface = surface, + .surface = surface.id (), .minImageCount = image_count, .imageFormat = surface_format.format, .imageColorSpace = surface_format.colorSpace,