This is a personal reference for getting started with Vulkan and ImGui (using the Vulkan backend). The code is heavily annotated for learning purposes.
Each chapter of the vulkan tutorial is in branches:
00-end-of-drawing
01-drawing-a-triangle
02-vertex-buffers
03-uniform-buffers
04-texture-mapping
05-depth-buffering
06-loading-models
07-generating-mipmaps
08-multisampling
09-compute-shader
main
branch contains an imgui-vulkan-app.cpp file that integrates imgui with the resulting vulkan renderer.
These are the project dependencies
imgui
with glfw, opengl and vulkan bindingsglfw
- windowingglm
- linear algebra, good compatibility with GLSL.stb
- loading imagestinyobjloader
- loading obj modelsVulkan
You can follow this guide for setting up dependencies:
You can install Vulkan from: LunarG
Note the install location. Run the vkcube
executable in the Bin
directory to verify a successful installation.
Copy Vulkan SDK installation path to the CMakeLists.txt
file.
Note that it might also be automatically installed by vcpkg
.
vcpkg
is used for package and dependency management.
A vcpkg.json
user manifest file is provided to help install dependencies or you can install them globally.
# run this in any folder that vcpkg.json is in.
# triplet is optional, but useful on windows
path_to_vcpkg install --triplet triplet_name
# e.g
C:/dev/vcpkg/vcpkg install --triplet x64-windows
Global install:
path_to_vcpkg install imgui[glfw-binding,opengl3-binding,vulkan-binding]:triplet_name
path_to_vcpkg install glad:triplet_name
path_to_vcpkg install glfw3:triplet_name
path_to_vcpkg install glm:triplet_name
path_to_vcpkg install tinyobjloader[double]:triplet_name
path_to_vcpkg install stb:triplet_name
path_to_vcpkg integrate install
For branches that make use of the shader code, you would need to compile them before use. Scripts for most platform have been provided to help in the compilation of the shaders.
Consult the shaders readme
for more information.
You would need to do this for both shaders
and compute-shaders
directories.
# for example
cd ./resources/shaders
./compile.bat
cd ../compute-shaders
./compile.bat
# Linux
cd ./resources/shaders
./compile
cd ../compute-shaders
./compile
Do the following steps
Install dependencies
Compile shaders
- Generate and/or Building with CMake
CMake
is used to generate project files.
If you are working with vcpkg for dependency management, you can pass the toolchain file when you call cmake to generate:
cmake -B ./build -S ./ "-DCMAKE_TOOLCHAIN_FILE=the_path_to/vcpkg/scripts/buildsystems/vcpkg.cmake"
# e.g
cmake -B ./build -S ./ "-DCMAKE_TOOLCHAIN_FILE=C:/dev/vcpkg/scripts/buildsystems/vcpkg.cmake"
This command will run vcpkg install for you if you have a vcpkg.json
file.
After configuration and generation is done, you can run
cd build
cmake build .
This will build the project.
On Windows, if you prefer working in Visual Studio, after generation is done, you can open the generated sln
file and build any target you want.
Just make sure it is the selected as a Startup project. The working directory and post build commands have been automatically configured.
vulkan-tutorial.com
Integrating Dear ImGui in a custom Vulkan renderer - Frguthmann's blog
Walnut by TheCherno
thomasherzog response to What things in the Vulkan code should be changed for the ImGui window rendering?
ImGui GLFW Vulkan example code
Sascha Willems imgui example
vkguide-implementing imgui