From 8a056e72fca47bbe8fd82ff466c9d1bad1fe5eba Mon Sep 17 00:00:00 2001 From: Sascha Willems Date: Thu, 13 Nov 2025 17:43:36 +0100 Subject: [PATCH 1/2] Show Vulkan-hpp code we actually use in our code Clarifcation on designated initializers and Vulkan-hpp --- .../00_Setup/00_Base_code.adoc | 21 +++++++------------ 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/en/03_Drawing_a_triangle/00_Setup/00_Base_code.adoc b/en/03_Drawing_a_triangle/00_Setup/00_Base_code.adoc index 462e85f8..e6966913 100644 --- a/en/03_Drawing_a_triangle/00_Setup/00_Base_code.adoc +++ b/en/03_Drawing_a_triangle/00_Setup/00_Base_code.adoc @@ -141,18 +141,6 @@ vkDestroyInstance(instance, nullptr); can be directly replaced by this: -[,c++] ----- -vk::raii::Context context; -constexpr auto appInfo = vk::ApplicationInfo("Hello Triangle", 1, "No Engine", 1, vk::ApiVersion11); -vk::InstanceCreateInfo createInfo({}, &appInfo, {}, {}); -vk::raii::instance = std::make_unique(context, createInfo); ----- - -As this can be a little hard to read when we look at the structures. We have - opted to turn on VULKAN_HPP_NO_STRUCT_CONSTRUCTORS. This option means that - the above code will look like this throughout the tutorial: - [,c++] ---- constexpr vk::ApplicationInfo appInfo{ .pApplicationName = "Hello Triangle", @@ -166,8 +154,13 @@ vk::InstanceCreateInfo createInfo{ instance = vk::raii::Instance(context, createInfo); ---- -This provides a better meaning towards what each option relates to in the -structures that we're depending upon. +NOTE: We use Vulkan-hpp with designated initializers introduced with C++ 20. By default, +Vulkan-hpp uses a different way of initializing and we need to explicitly enable this +by using the `VULKAN_HPP_NO_STRUCT_CONSTRUCTORS` define. This provides a better meaning +towards what each option relates to in the structures that we're depending upon. +For this tutorial, said define is declared in the xref:../../02_Development_environment.adoc#cmake[CMake build setup]. +If you use a different build setup, you need to manually define this before including +Vulkan-hpp. == Integrating GLFW From b21dd7bc8aee3cd677da822424e861b69ae423b4 Mon Sep 17 00:00:00 2001 From: Sascha Willems Date: Thu, 13 Nov 2025 17:47:59 +0100 Subject: [PATCH 2/2] Add some spacing to code example --- en/03_Drawing_a_triangle/00_Setup/00_Base_code.adoc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/en/03_Drawing_a_triangle/00_Setup/00_Base_code.adoc b/en/03_Drawing_a_triangle/00_Setup/00_Base_code.adoc index e6966913..e5dc53eb 100644 --- a/en/03_Drawing_a_triangle/00_Setup/00_Base_code.adoc +++ b/en/03_Drawing_a_triangle/00_Setup/00_Base_code.adoc @@ -148,9 +148,11 @@ constexpr vk::ApplicationInfo appInfo{ .pApplicationName = "Hello Triangle", .pEngineName = "No Engine", .engineVersion = VK_MAKE_VERSION( 1, 0, 0 ), .apiVersion = vk::ApiVersion14 }; + vk::InstanceCreateInfo createInfo{ .pApplicationInfo = &appInfo }; + instance = vk::raii::Instance(context, createInfo); ----