Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 19 additions & 6 deletions en/03_Drawing_a_triangle/00_Setup/00_Base_code.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,22 @@ import vulkan_hpp;
#include <cstdlib>

class HelloTriangleApplication {
----

The `#if defined(__INTELLISENSE__) || !defined(USE_CPP20_MODULES)` block picks
Comment thread
gpx1000 marked this conversation as resolved.
between two ways of pulling in the Vulkan-Hpp API, both of which provide the
same functions, structures, and enumerations. By default we include the
traditional `<vulkan/vulkan_raii.hpp>` header. If you enable C{pp}20 modules
(`-DENABLE_CPP20_MODULE=ON`), the `USE_CPP20_MODULES` define set by CMake
makes the code `import vulkan_hpp;` instead. Either way, Visual Studio and VS
Code's IntelliSense engine doesn't yet understand `import` for modules and
will flag it as an error even though the code compiles fine, so we fall back
to the header whenever `__INTELLISENSE__` is defined (which IntelliSense
itself defines while analyzing the code) or when modules are turned off
entirely.

[,c++]
----
public:
void run() {
initVulkan();
Expand Down Expand Up @@ -76,12 +92,9 @@ int main()
}
----

We first include the Vulkan-Hpp RAII header by default, which provides the
functions, structures and enumerations. If you enable C{pp}20 modules
(`-DENABLE_CPP20_MODULE=ON`), the code will `import vulkan_hpp;` instead via the
`USE_CPP20_MODULES` define set by CMake. The `stdexcept` and `iostream` headers
are included for reporting and propagating errors. The `cstdlib` header
provides the `EXIT_SUCCESS` and `EXIT_FAILURE` macros.
The `stdexcept` and `iostream` headers are included for reporting and
propagating errors. The `cstdlib` header provides the `EXIT_SUCCESS` and
`EXIT_FAILURE` macros.

The program itself is wrapped into a class where we'll store the Vulkan objects
as private class members and add functions to initiate each of them, which will
Expand Down
Loading