A modern Vulkan application starter template built with Vulkan Visualizer - a powerful rendering framework that simplifies Vulkan development.
# Clone the repository
git clone https://github.com/vulkan-visualizer/vulkan-visualizer-starter-template.git
cd vulkan-visualizer-starter-template
# Configure and build (Release)
cmake -B build -S . -DCMAKE_BUILD_TYPE=Release
cmake --build build --config Release --parallel
# Run the application
cd build
./example_template # Linux/macOS
# or
.\Release\example_template.exe # WindowsThe application will display a window with a simple colored triangle renderer.
- π¨ Ready-to-run Example - Colored triangle renderer with vertex shader-based geometry
- π§ Zero Dependencies - Automated SDK setup via CMake bootstrap
- π¦ Shader Pipeline - Automatic GLSL to SPIR-V compilation
- πͺ Cross-Platform - Windows, Linux, and macOS support with SDL3
- π― ImGui Ready - Built-in GUI framework integration
- β‘ Modern Vulkan - Dynamic rendering with Vulkan 1.3+ features
- β CI/CD - GitHub Actions workflows for all platforms
| Component | Version | Download |
|---|---|---|
| CMake | 3.26+ | cmake.org |
| C++ Compiler | C++23 | MSVC 2022 / GCC 13+ / Clang 16+ |
| Vulkan SDK | 1.3+ | vulkan.lunarg.com |
| Git | Any | git-scm.com |
Note: The Vulkan SDK is required for shader compilation (
glslctool).
vulkan-visualizer-starter-template/
βββ π main.cpp # Application entry point & TriangleRenderer
βββ π CMakeLists.txt # Build configuration
βββ π cmake/
β βββ bootstrap.cmake # Auto SDK setup script
βββ π shaders/
β βββ triangle.vert # Vertex shader (GLSL)
β βββ triangle.frag # Fragment shader (GLSL)
βββ π .github/
β βββ workflows/ # CI/CD pipelines
β βββ windows-build.yml
β βββ linux-build.yml
β βββ macos-build.yml
βββ π README.md
cmake -B build -S . -DCMAKE_BUILD_TYPE=Release
cmake --build build --config ReleaseOutput: build/Release/example_template.exe
cmake -B build -S . -DCMAKE_BUILD_TYPE=Release
cmake --build build --parallelOutput: build/example_template
cmake -B build -S . -DCMAKE_BUILD_TYPE=Release
cmake --build build --parallelOutput: build/example_template
Tip: For debug builds, replace
ReleasewithDebugin the commands above.
graph LR
A[main.cpp] --> B[VulkanEngine]
A --> C[TriangleRenderer]
C --> D[IRenderer Interface]
B --> E[SDL3 Window]
B --> F[Vulkan Context]
C --> G[Shaders]
G --> H[SPIR-V]
-
Bootstrap System (
bootstrap.cmake)- Automatically clones and builds Vulkan Visualizer SDK on first configure
- Installs to
build/vulkan-visualizer-sdk/ - Caches build to avoid redundant compilation
-
Shader Pipeline
- GLSL shaders in
shaders/directory - Compiled to SPIR-V during build using
glslc - Output:
build/shaders/*.spv
- GLSL shaders in
-
Renderer Implementation (
TriangleRenderer)- Inherits from
IRendererinterface - Implements lifecycle methods:
get_capabilities()- Define rendering requirementsinitialize()- Create pipelines and resourcesrecord_graphics()- Record render commandsdestroy()- Cleanup resources
- Inherits from
-
Engine Loop (
VulkanEngine)- Manages window lifecycle (SDL3)
- Handles Vulkan device/queue initialization
- Processes input events
- Orchestrates frame rendering
- Define a new renderer class:
class MyCustomRenderer : public IRenderer
{
public:
void query_required_device_caps(RendererCaps& caps) override {
// Request device features
}
void get_capabilities(const EngineContext&, RendererCaps& caps) override {
// Define attachments, formats, etc.
caps.presentation_mode = PresentationMode::EngineBlit;
caps.preferred_swapchain_format = VK_FORMAT_B8G8R8A8_UNORM;
// ... add color/depth attachments
}
void initialize(const EngineContext& ctx, const RendererCaps&, const FrameContext&) override {
// Create pipelines, descriptors, buffers
}
void record_graphics(VkCommandBuffer cmd, const EngineContext&, const FrameContext& frame) override {
// Record rendering commands
}
void destroy(const EngineContext& ctx, const RendererCaps&) override {
// Cleanup Vulkan resources
}
};- Update
main.cpp:
int main() {
VulkanEngine engine;
engine.configure_window(1280, 720, "My Custom Renderer");
engine.set_renderer(std::make_unique<MyCustomRenderer>());
engine.init();
engine.run();
engine.cleanup();
return 0;
}- Add your shaders:
# Add to shaders/ directory
shaders/
βββ my_shader.vert
βββ my_shader.frag- Update
CMakeLists.txt:
add_vv_example(
NAME my_example
SRC main.cpp
SHADERS shaders/my_shader.vert shaders/my_shader.frag
)This template includes production-ready GitHub Actions workflows:
| Platform | Runner | Configurations | Artifacts |
|---|---|---|---|
| Windows | windows-latest |
Release, Debug | .exe, .dll, shaders |
| Linux | ubuntu-latest |
Release, Debug | binary, shaders |
| macOS | macos-latest |
Release, Debug | binary, shaders |
- β
Automatic builds on push/PR to
main,master, ordevelop - β
Manual trigger support (
workflow_dispatch) - β Parallel matrix builds (Release + Debug)
- β Artifact uploads (7-day retention)
- β Vulkan SDK caching for faster builds
Main engine class managing application lifecycle.
void configure_window(uint32_t width, uint32_t height, const char* title);
void set_renderer(std::unique_ptr<IRenderer> renderer);
void init();
void run();
void cleanup();Interface for custom renderers.
virtual void query_required_device_caps(RendererCaps&);
virtual void get_capabilities(const EngineContext&, RendererCaps&);
virtual void initialize(const EngineContext&, const RendererCaps&, const FrameContext&);
virtual void record_graphics(VkCommandBuffer, const EngineContext&, const FrameContext&);
virtual void destroy(const EngineContext&, const RendererCaps&);For complete API documentation, see the Vulkan Visualizer repository.
CMake cannot find Vulkan SDK
# Set environment variable
export VULKAN_SDK=/path/to/vulkan/sdk # Linux/macOS
set VULKAN_SDK=C:\VulkanSDK\1.3.xxx.x # WindowsShader compilation fails
- Ensure
glslcis in your PATH (comes with Vulkan SDK) - Check shader syntax errors in
shaders/*.vertandshaders/*.frag
Runtime validation errors
- Enable validation layers by setting
VK_LAYER_PATH - Check
VK_CHECKmacro failures in console output
Linker errors on Windows
- Ensure you're using the correct MSVC runtime library (see
CMakeLists.txt) - Clean build directory:
rmdir /s /q build
This project is licensed under the MIT License - see the LICENSE file for details.
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
- Vulkan Visualizer Framework - Main framework repository
- Vulkan Guide - Comprehensive Vulkan tutorial
- Vulkan Specification - Official Khronos documentation
- GLSL Reference - Shader language specification
- SDL3 Documentation - Windowing system docs
If this template helped you get started with Vulkan development, please consider giving it a star β!
Report Bug β’ Request Feature β’ Discussions
Made with β€οΈ using Vulkan Visualizer