Code Monkey home page Code Monkey logo

vg-renderer's Introduction

vg-renderer

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

WIP and doesn't compile as is! Requires structs and functions from my codebase which aren't present in this repo. Nothing too complicated (it needs a Vec2 struct and several math/utility functions) so if you really want to make it compile, you can try writing/using your own version of those.

Also includes some small changes to FontStash.

Based on NanoVG and FontStash versions included in bgfx repo.

Compared to NanoVG/FontStash

  1. Generates fewer draw calls, by batching multiple paths together, and using indexed triangle lists (like ImDrawList)
  2. Separate shader program for gradients to reduce uniform usage (NanoVG's bgfx backend uses a single program for all cases)
  3. Circle() and RoundedRect() are implemented without Beziers
  4. All textures are RGBA (even the font altas)
  5. Concave polygons are decomposed into convex parts and rendered normally instead of using the stencil buffer (not tested extensively; might have issues with AA) (uses algorithm from https://mpen.ca/406/bayazit)
  6. Stack-based Bezier tesselation
  7. FontStash glyph hashing uses BKDR for better distribution of glyphs in the LUT (fewer collisions when searching for cached glyphs)
  8. Shapes (aka prebaked command lists, aka display lists) with dynamic text support (i.e. the actual text string is retrieved at the time the shape is submitted for rendering, via a callback) (can be disabled with a compile-time flag (VG_SHAPE_DYNAMIC_TEXT)).
  9. Caching of tessellated shapes.

What's not supported compared to NanoVG

  1. Miter limit
  2. Arbitrary polygon winding
  3. Polygon holes
  4. Variable text line height
  5. Skew transformation matrix

Comparison screenshots

The code is currently used in DLS for rendering both the schematic and the UI. Below are two screenshots comparing NanoVG's output with vg-renderer's output.

NanoVG vg-renderer

vg-renderer's People

Contributors

jdryg avatar

Watchers

SeniorPlayer avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.