高级 Vulkan 2D 向量图形 API(C++)
NOTE: this isn't very actively maintained at the moment. It might still be useful as a proof of concept. Just for reference, you might prefer to look at an experimental rework I worked on for a while, where rendering is a lot more optimized. Development here might be resumed in future
Vulkan library for high-level 2D vector-like rendering in modern C++17. Modeled loosely after svg, inspired by nanoVG. Uses an object-oriented, retained mode idiom for rendering which makes it highly efficient for rendering with vulkan since curves and shapes are not recomputed and uploaded every frame but just once (or when changed). Does not even need a command buffer rerecord every frame, even things like paints, shapes or transforms can be changed without triggering the need for a command buffer rerecord which makes it use way less cpu performance than immediate mode alternatives. Aims to provide a compromise between high level drawing functionality and an api that can efficiently be implemented on the gpu. Could e.g. easily be used for a vulkan gui library.
The project builds upon tested and proven libraries where possible, such as fontstash for font atlas building and some stb headers. Note that the project is still in a rather early stage, please report all issues and questions (simple things such as spelling errors or missing docs on a function are appreciated as well).
For more information check out the example concepts below, the example showing off many features, or read the introduction which documents some basic concepts and shows how to integrate rvg in more detail.
Since rvg uses a retained mode you will first have to create the resources you might to use/draw and then actually draw them (via recording into a command buffer). The example below shows initialization of some basic rvg resources (on the highest abstraction level), there are more and more advanced settings, refer to the inline documentation in the headers:
…After having all these resources created we naturally want to render them. Since rvg tries to stay as modular and univerally usable as possible, the interface all resources use for rendering is a raw vulkan command buffer. Binding state (like transform/paint/scissor) will result in a simple descriptor set bind while rendering shapes will result always in an indirect draw. Assuming the resources from above, this could look like this:
…It's now probably pretty easy to imagine how you could use rvg to further build your own (roughly) object-oriented interfaces and divide the work into small components.
Screenshot of example/example.cpp:
The library uses meson as build system. It uses a few of my other
libraries as dependencies to stay modular but those will be automatically
built using meson. The only hard dependencies are vulkan as well as glslang
for building the spirv shaders.
You need a solid C++17 compiler (currently not tested with msvc),
gcc >= 7 is tested. For gcc 7 you currently have to turn off werror
in meson (meson configure -Dwerror=false in build dir).
For the glfw example you need the glfw3 library (obviously with vulkan
support).
After building
meson build -Dexample-glfw=true
cd build
ninjayou should be able to run the example in the build dir via ./example/example_glfw.
There is also an example using my experimental ny window abstraction instead of glfw,
enable it via -Dexample-ny=true (requires several low level xcb/wayland libraries).
Please read the linked introduction (requirements) before reporting build issues. Contributions welcome, always want to hear ideas and suggestions.
This library is the successor of/inspired my attempt to write a nanoVG vulkan backend, which worked but didn't really make use of vulkans advantages. That inspired me to look into which kind of abstraction would make sense for vulkan.
暂无开放 Issues,或尚未同步最近议题。