Skip to content

Commit 8a056e7

Browse files
committed
Show Vulkan-hpp code we actually use in our code
Clarifcation on designated initializers and Vulkan-hpp
1 parent fa08fee commit 8a056e7

File tree

1 file changed

+7
-14
lines changed

1 file changed

+7
-14
lines changed

en/03_Drawing_a_triangle/00_Setup/00_Base_code.adoc

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -141,18 +141,6 @@ vkDestroyInstance(instance, nullptr);
141141

142142
can be directly replaced by this:
143143

144-
[,c++]
145-
----
146-
vk::raii::Context context;
147-
constexpr auto appInfo = vk::ApplicationInfo("Hello Triangle", 1, "No Engine", 1, vk::ApiVersion11);
148-
vk::InstanceCreateInfo createInfo({}, &appInfo, {}, {});
149-
vk::raii::instance = std::make_unique<vk::raii::Instance>(context, createInfo);
150-
----
151-
152-
As this can be a little hard to read when we look at the structures. We have
153-
opted to turn on VULKAN_HPP_NO_STRUCT_CONSTRUCTORS. This option means that
154-
the above code will look like this throughout the tutorial:
155-
156144
[,c++]
157145
----
158146
constexpr vk::ApplicationInfo appInfo{ .pApplicationName = "Hello Triangle",
@@ -166,8 +154,13 @@ vk::InstanceCreateInfo createInfo{
166154
instance = vk::raii::Instance(context, createInfo);
167155
----
168156

169-
This provides a better meaning towards what each option relates to in the
170-
structures that we're depending upon.
157+
NOTE: We use Vulkan-hpp with designated initializers introduced with C++ 20. By default,
158+
Vulkan-hpp uses a different way of initializing and we need to explicitly enable this
159+
by using the `VULKAN_HPP_NO_STRUCT_CONSTRUCTORS` define. This provides a better meaning
160+
towards what each option relates to in the structures that we're depending upon.
161+
For this tutorial, said define is declared in the xref:../../02_Development_environment.adoc#cmake[CMake build setup].
162+
If you use a different build setup, you need to manually define this before including
163+
Vulkan-hpp.
171164

172165
== Integrating GLFW
173166

0 commit comments

Comments
 (0)