What Is NanoVG? Vector Graphics for OpenGL

NanoVG is a small antialiased 2D vector graphics library for OpenGL. Minecraft clients use it through LWJGL to draw crisp HUDs, menus, and shapes.

Librariesby trqUpdated June 4, 2026
Key takeaways
  • NanoVG is a small antialiased 2D vector graphics library for OpenGL, written in C.
  • It draws shapes, text, and gradients from paths, with smooth edges at any size.
  • Minecraft clients reach it through LWJGL bindings to paint HUDs and menus.
  • Vector drawing wins for resizable UI; bitmaps still win for fixed artwork.

NanoVG is a small antialiased vector graphics library for OpenGL, written in C. It draws 2D shapes, text, and gradients with smooth edges from one compact API. In a Minecraft client, it is reached through LWJGL bindings so Java code can paint crisp HUDs and menus on top of the game.

Where Opal fits

Opal is a Fabric mod that draws its own interface over the game. If you want to add features yourself, the scripting guide shows how to do it in JavaScript.

What NanoVG does

NanoVG renders 2D vector graphics on the GPU through OpenGL. You describe shapes with paths (lines, curves, rectangles, circles), then fill or stroke them. The library handles antialiasing, so edges stay smooth at any size instead of going blocky the way a stretched bitmap would.

It is deliberately small. The whole library is a single C file with a focused API, which is part of why it shows up in graphics demos and lightweight UI layers rather than heavy engine code.

Why a Minecraft client uses it

A client draws its own interface over Minecraft: arraylists, menus, shape indicators, custom HUD elements. NanoVG gives that interface a clean way to draw vector shapes and text that scale to any resolution without looking jagged.

Because the rendering is path-based, a developer can build rounded panels, gradients, and outlines from primitives instead of pre-baked images. That keeps the look consistent across GUI scales and display sizes.

NanoVG and LWJGL

Minecraft and its mods run on the JVM, but NanoVG is a C library. LWJGL bridges the gap. It ships Java bindings to native libraries like NanoVG and OpenGL, so Java code can call the native functions directly.

A client links against the LWJGL NanoVG module, opens a drawing context, and issues path and paint calls inside the game's render loop. The native side does the actual rasterizing on the GPU.

NanoVG vs bitmap drawing

AspectNanoVG (vector)Bitmap textures
EdgesAntialiased at any sizeBlur or alias when scaled
ShapesBuilt from paths at runtimePre-made image assets
MemoryLight, no large texturesGrows with image count
Best forUI, shapes, dynamic textPhotos, fixed art, icons

Vector drawing wins for interface elements that change size or color. Bitmaps still win for detailed, fixed artwork.

FAQ