From ba3a49eccf6a9fdf3e09e041991089fbdfc983d2 Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Fri, 1 Sep 2017 12:14:15 +1000 Subject: [PATCH] instance: add constructor from base info type --- instance.cpp | 35 +++++++++++++++++++++++------------ instance.hpp | 3 ++- 2 files changed, 25 insertions(+), 13 deletions(-) diff --git a/instance.cpp b/instance.cpp index 99f790f..1978ad3 100644 --- a/instance.cpp +++ b/instance.cpp @@ -21,24 +21,35 @@ using cruft::vk::instance; /////////////////////////////////////////////////////////////////////////////// -instance::create_info::create_info () -{ - sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO; - pNext = nullptr; - flags = 0; +static const VkInstanceCreateInfo DEFAULT_INFO = { + .sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO, + .pNext = nullptr, + .flags = 0, - pApplicationInfo = nullptr; + .pApplicationInfo = nullptr, - enabledLayerCount = 0; - ppEnabledLayerNames = nullptr; + .enabledLayerCount = 0, + .ppEnabledLayerNames = nullptr, - enabledExtensionCount = 0; - ppEnabledExtensionNames = nullptr; -} + .enabledExtensionCount = 0, + .ppEnabledExtensionNames = nullptr +}; //----------------------------------------------------------------------------- -instance::instance (const VkInstanceCreateInfo &info): +instance::create_info::create_info (): + create_info (DEFAULT_INFO) +{ ; } + + +//----------------------------------------------------------------------------- +instance::create_info::create_info (const VkInstanceCreateInfo &base): + VkInstanceCreateInfo (base) +{ ; } + + +/////////////////////////////////////////////////////////////////////////////// +instance::instance (const create_info &info): instantiated (&info, nullptr) { ; } diff --git a/instance.hpp b/instance.hpp index 272007f..4cd1f8b 100644 --- a/instance.hpp +++ b/instance.hpp @@ -30,9 +30,10 @@ namespace cruft::vk { struct instance : public instantiated { struct create_info : public VkInstanceCreateInfo { create_info (); + create_info (const VkInstanceCreateInfo&); }; - instance (const VkInstanceCreateInfo &info); + instance (const create_info &info); std::set extensions (void) const; };