Skip to content

Commit 0e3035d

Browse files
committed
Move note on Vulkan-hpp an designated initializers to the top and add some additional details
People seem to trip over this, esp. when writing code from scratch
1 parent 1b2dfc4 commit 0e3035d

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

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

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,23 @@
22

33
= Base code
44

5+
== Vulkan-hpp and designated initializers
6+
7+
NOTE: We are going to use designated initializers introduced with C++ 20. By default,
8+
Vulkan-hpp uses a different way of initializing and we need to explicitly enable this
9+
by using the `VULKAN_HPP_NO_STRUCT_CONSTRUCTORS` define.
10+
11+
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].
12+
13+
If you use a different build setup or want to write code from scratch, you need to manually define this before including the Vulkan-hpp headers like this:
14+
[,c++]
15+
----
16+
#define VULKAN_HPP_NO_STRUCT_CONSTRUCTORS
17+
#include <vulkan/vulkan.hpp>
18+
// or
19+
#include <vulkan/vulkan_raii.hpp>
20+
----
21+
522
== General structure
623

724
In the previous chapter, you've created a Vulkan project with all the proper
@@ -156,14 +173,6 @@ vk::InstanceCreateInfo createInfo{
156173
instance = vk::raii::Instance(context, createInfo);
157174
----
158175

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.
166-
167176
== Integrating GLFW
168177

169178
Vulkan works perfectly fine without creating a window if you want to use it for

0 commit comments

Comments
 (0)