jjYBdx4IL / nanovg-vulkan-min-integration-demo

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

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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), 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.

License:MIT License


Languages

Language:C 98.1%Language:GLSL 1.4%Language:CMake 0.4%Language:Shell 0.0%