Skip to content

My take on the vulkan-tutorial.com up the texture mapping chapter.

License

Notifications You must be signed in to change notification settings

caiovpsilveira/Vulkan-Tutorial

Repository files navigation

Vulkan-Tutorial

This is my take on the Vulkan-Tutorial, up to the chapter of texture mapping.

I used class abstractions, VulkanMemoryAllocator and newer C++ features.

I'm using C++20 because of designated initializers, std::span, std::format, std::ranges and other nice features.

Dependencies

For third_party libraries, I'm using SDL2, GLM and STB_IMAGE. These are already embedded within the project.

For external dependencies, this requires the Vulkan SDK. You can download the latest Vulkan SDK here.

Vulkan SDK is required for Vulkan, VulkanMemoryAllocator, which is shipped with the Vulkan SDK since 1.3.216.0, and the glslangValidator, which is used to compile GLSL and HLSL shaders into SPIR-V, Vulkan's shader format.

Building

This project is configured with CMake. In-source builds are disabled. All relative paths consider that the binary is in a /build directory, relative to the project root.

mkdir build
cd build
cmake ..
make

This was tested with Clang 18.1.4 on Debian 12, but it should be cross-platform.

Check here to see which version of your compiler supports a certain feature.

For Clang, I had to add -stdlib=libc++ to CMAKE_CXX_FLAGS for it to recognize std::format, and install the libc++-dev package.

There may be some warnings that may be triggered by other compilers, so you might want to remove the -Werror target_compile_options in src/CMakeLists.txt to be able to compile.

Alternative, there is a cmake.sh script in the project root, which sets the compiler as Clang and overwrites some CMake rules with CMakeOverrides.txt, such as compile flags and setting CMAKE_EXPORT_COMPILE_COMMANDS for clangd.

Note that there are some target compile definitions set in the src/CMakeLists.txt, which are required for beign propely compiled. These definitions tell Vulkan.hpp and VMA to use dynamic entrypoints, which are loaded in the constructor of VulkanGraphicsContext, and also tell GLM to use the Vulkan depth range instead of the OpenGL range.

CMake is also configured to build the shaders under /shaders with glslangValidator. It's configured as a main target dependency, so the shaders will be compiled before compiling the main target.

About

My take on the vulkan-tutorial.com up the texture mapping chapter.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages