Skip to content

Lesson 1: Getting Started

The code for this tutorial should work with any compiler that supports the C++20 standard, so if you already have a C++ toolchain working, you’ll likely be able to use that. If not, here are a few suggestions:

  • if you’re on Windows, the Visual Studio Community Edition is probably the most convenient C++ environment to install
  • on Mac, Xcode is the default. I’m not really a fan of that IDE, but it does the job. You can easily install it from the AppStore.
  • if you’re on Linux or don’t want to use a full-fledged IDE, you might want to look at VS Code. It’s a pretty awesome editor that runs on multiple platforms. And with a few extensions it can be converted into a veritable C++ development environment.

Because we want to develop a cross-platform graphics application, we should make sure that our project can easily be built on multiple platforms. The most widespread way to do that for C++ is to use CMake. Please download and install the latest version for your platform.

vcpkg is a package manager for C++ libraries. Using vcpkg makes dependency management a lot easier and works seamlessly across Windows, macOS, and Linux. Please refer to their getting started guide for information on how to install it on your platform.

We want to develop a Vulkan application, so it might actually be a good idea to install the official Vulkan SDK. Please go to the LunarG website and download and execute the installer for your platform. The location where you put the SDK is not relevant. At the time of writing, version 1.4.328.0 was used; any recent version should work.

GLM and SDL will be introduced in later lessons and managed via vcpkg, so you do not need to select them during the Vulkan SDK installation.

Alright, your environment should be set up now, so let’s get going with our project.

Go to the bitbucket / github repository (see links in the sidebar on the right) and clone it to your computer. Then checkout the branch for lesson_1:

Terminal window
$ git checkout lesson_1

The project includes a CMakePresets.json that handles the vcpkg toolchain configuration automatically. Make sure the VCPKG_ROOT environment variable is set to your vcpkg installation directory, then configure the project from your project folder. Use the debug preset while following this tutorial:

Terminal window
$ cmake --preset debug

CMake will create a build/debug subfolder and configure the project there. vcpkg will automatically download and build the dependencies specified in vcpkg.json. At this point we only depend on Vulkan, so this should complete quickly. See the vcpkg CMake integration docs for more info on how vcpkg integrates with CMake.

You can also optionally specify a generator if you prefer a specific project file type:

Terminal window
$ cmake --preset debug -G <your desired project file type>

That’s it, you now should have a project file for your environment in the build/debug folder. Open it in your IDE (if that’s what you use), or build from the command line:

Terminal window
$ cmake --build --preset debug

Configure and build release presets are also available when you want an optimized build.

If the build completes without errors and you can run the executable from the commandline (it should produce no output), your environment is correctly configured and you are ready to continue with the tutorial.

We’re now set up to get started for real. In the next lesson we’ll have a look at some of the basic concepts in the C++ wrapper before we finally get our hands dirty and start programming Vulkan.