Skip to content
This repository has been archived by the owner on May 31, 2024. It is now read-only.

Example of NanoVG Vulkan render pass integration to custom render pass.

License

Notifications You must be signed in to change notification settings

danilw/nanovg-vulkan-min-integration-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Note 2024:

This is old, before danilw/nanovg_vulkan#7 in nanovg_vulkan repo. Im not going to update this to new.


nanovg-vulkan-min-integration-demo

What is it - this project show Vulkan NanoVG integration to custom render pass, not using any external libraries.

NanoVG Vulkan port github link - nanovg_vulkan

Remember this is not GUI example, NanoVG is UI rendering library


What you need to do for NanoVG integration - call init_nanovg_vulkan(...) after your full Vulkan initialization, and copy-paste NanoVG render pass after end of your render pass vkCmdEndRenderPass. Remember to use VK_ATTACHMENT_LOAD_OP_LOAD for loadOp in VkAttachmentDescription for color attachment of renderpass(line 1346 vk_utils/vk_utils.c). And clean framebuffer before next frame.

This commit 11e4dce shows NanoVG render pass integration. And remember to clean framebuffer if you integrating render pass commit b81f66a.

Can be copy-pasted to any other render pass. (or compare main.c to main_original.c)


As an example of render pass I use my own "single triangle" example Vulkan code from vulkan-shader-launcher (example_minimal there)

Platform supported - Windows and Linux (X11/Wayland).

To build Wayland set USE_WAYLAND_LINUX to ON in example_minimal_nanovg/CMakeLists.txt file.

Build:

Use cmake to build.

git clone https://github.com/danilw/nanovg-vulkan-min-integration-demo
cd nanovg-vulkan-min-integration-demo/example_minimal_nanovg
mkdir build
cd build
cmake ../
make
./Vkexample_nvg

Release download has example build for Windows and Linux x11/Wayland.

Hotkeys - 1 (NanoVG demo hotkey), 2 (set fps to 30), 3 (hide NanoVG event example), Space pause.

Launch option - --gpu X (X is 0/1/2 etc) select Vulkan GPU to use, by default selected Discrete GPU.


All changes in main.c search for nanovg Vulkan related functions

In demo.c changed only path to demo files (font/images) to nanovg_vulkan_resources folder.


main.c - example with integration

main_original.c - original single triangle example without NanoVG


Screenshot:

img

About

Example of NanoVG Vulkan render pass integration to custom render pass.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages