Draw smooth, resolution-independent UI elements like buttons and panels in a game or desktop app using OpenGL.
Render antialiased charts, graphs, or data visualizations on top of an OpenGL surface.
Port canvas-based 2D drawing code from JavaScript to a native C application using NanoVG's familiar API.
Requires an OpenGL context with a stencil buffer configured before NanoVG can render.
NanoVG is a small C library for drawing smooth, antialiased 2D vector graphics on top of OpenGL. It is designed for building user interfaces and data visualizations that need to scale cleanly across different screen sizes. The project is no longer actively maintained, but the code is stable and remains in use. The library's API follows the same general structure as the HTML5 canvas drawing API used in web browsers. You begin a path, define the shape using functions for rectangles, circles, ellipses, or freeform curves, set a fill color or stroke style, and then render it. Developers who have written canvas code in JavaScript will find the concepts familiar. NanoVG produces smooth edges through its own antialiasing approach built into the geometry rather than relying on the graphics card's multisampling. It works with several versions of OpenGL: 2.0, ES 2.0, 3.2 core profile, and ES 3. The render target needs a stencil buffer to function correctly. Text rendering and image loading are handled through companion libraries called stb_truetype (or freetype) and stb_image, which are bundled with the project. Drawing shapes with holes cut out requires a specific step. Because of how the back-end handles overlapping paths, you have to mark sub-paths as holes by calling a winding function after defining each hole shape. The documentation covers this with a short code example. Ports exist for DirectX 11, Metal, and bgfx, maintained by other contributors. The library is released under the zlib license, which allows use in commercial products without restrictions.
← memononen on gitmyhub — every repo by this author, as a profile.
Verify against the repo before relying on details.