百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
V

vg-renderer

> 编程语言
开源

一个基于 NanoVG 和 ImDrawList (Dear ImGUI) 思想的 bgfx 矢量图形渲染器

638 stars0 点赞1 次浏览
访问官网GitHub

工具介绍

一个基于 NanoVG 和 ImDrawList (Dear ImGUI) 思想的 bgfx 矢量图形渲染器

vg-renderer

A vector graphics renderer for bgfx, based on ideas from NanoVG and ImDrawList (Dear ImGUI)

Includes some small changes to FontStash. Optionally uses libtess2 for concave polygon decomposition.

Path and Stroker classes

Paths are tesselated using the Path struct (src/vg/path.cpp, .h). You can use vg::pathXXX() functions to convert your SVG commands to a polyline for uses outside this renderer.

Strokes and fills are generated using the Stroker struct (src/vg/stroker.cpp, .h). You can use vg::strokerXXX() functions to generate strokes and fills for your polylines for uses outside this renderer.

Compared to NanoVG/FontStash

  1. Generates fewer draw calls by batching multiple paths together (if they share the same state)
  2. Separate shader programs for gradients and image patterns to reduce uniform usage (NanoVG's bgfx backend uses a single program for all cases)
  3. Concave polygons are decomposed on the CPU.
  4. Command lists with support for tesselation caching.
  5. Clip in/out with the stencil buffer
  6. User-specified indexed triangle list rendering (i.e. for complex gradients and sprite atlases).
  7. Fills with image patterns can be colored.
  8. FontStash: glyph hashing uses BKDR (seems to give better distribution of glyphs in the LUT; fewer collisions when searching for cached glyphs)
  9. FontStash: optional (compile-time flag) caching of glyph indices and kerning info for ASCII chars in order to avoid repeated calls to stbtt functions.
  10. Per-fill and per-stroke control over whether anti-aliasing geometry should be generated.

What's not supported compared to NanoVG

  1. Miter limit (i.e miter joins never convert to bevel joins)
  2. Polygon holes (they can be emulated using clip in/out regions)
  3. Variable text line height, font blur effect, and letter-spacing control
  4. Skew transformation matrix

Example

For an example on how to use this library, take a look here.

A few tips when porting from NanoVG.

  • nvgBezierTo should be replaced by vg::cubicTo. Note that there is also vg::quadraticTo for a lower degree Bezier curve.
  • nvgSave and nvgRestore are to be replaced by vg::pushState() and vg::popState().
  • Thanks to the support for command lists, you may want to render your UI in layers, where every layer is a command list. This way, you can still traverse the UI-tree widget by widget, but store draw commands onto the command lists per layer, which can greatly reduce state changes. For example you may have a layer for widget shapes and outlines, and a layer for text.
  • When implementing UI widget with perfectly rectangular shape, you may consider omitting the anti-aliasing setting to generate less geometry.
  • When using a gradient fill that will be fully transparent at the edge of the shape, you may likely also want to not generate anti-aliasing geometry.
  • vg-renderer uses uint32_t as colors, instead of a struct of 4 floats. When converting, you might want to consider to use vg::color4ub instead of vg::color4f. Also note that there are a few predefined colors available in vg::Colors::.

Images

DLS SVG (using simple-svg) Demo Custom gradients (indexed triangle lists w/ per-vertex colors)

Using this in your project

In your project, you can add these files as a new CMake target, using the following, assuming you have this project as a submodule in a folder ext/vg-renderer:

…

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Cvector-graphics

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言