Skip to content

Commit 98f8e83

Browse files
Merge pull request #226 from KhronosGroup/clarify_vulkan_hpp
Update 00_Base_code chapter to Vulkan-hpp code we actually use in our code
2 parents 28e5c15 + b21dd7b commit 98f8e83

File tree

1 file changed

+9
-14
lines changed

1 file changed

+9
-14
lines changed

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

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -141,33 +141,28 @@ 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",
159147
.applicationVersion = VK_MAKE_VERSION( 1, 0, 0 ),
160148
.pEngineName = "No Engine",
161149
.engineVersion = VK_MAKE_VERSION( 1, 0, 0 ),
162150
.apiVersion = vk::ApiVersion14 };
151+
163152
vk::InstanceCreateInfo createInfo{
164153
.pApplicationInfo = &appInfo
165154
};
155+
166156
instance = vk::raii::Instance(context, createInfo);
167157
----
168158

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

172167
== Integrating GLFW
173168

0 commit comments

Comments
 (0)