+
Skip to content
/ vgl Public
forked from regularshmo/vgl

A small, header-only, GPU-accelerated vector graphics renderer for OpenGL.

Notifications You must be signed in to change notification settings

leranger/vgl

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 

Repository files navigation

VGL

A small, header-only, dependency free, GPU-accelerated vector graphics renderer for OpenGL 3.3+

  • 256x coverage based anti-aliasing
  • Fast! (batched drawing using a single draw call)
  • Fill modes (non-zero, even-odd, intersection)
  • Gradients (linear, box, radial)
  • Stroked paths
  • TTF fonts

USAGE

#define VGL_IMPLEMENTATION
#include <vgl.h>
vg_begin();
vg_clear(0xFF000000);
vg_moveto(100, 100);
vg_lineto(200, 100);
vg_curveto(200, 200, 100, 200);
vg_lineto(100, 100);
vg_fill(0xFF0000FF);
vg_stroke(0xFFFFFFFF, 1);
vg_end();

RENDERS

alt text alt text

IMPLEMENTATION

Inspired by https://hhoppe.com/ravg.pdf

VGL works by cutting paths into tiles and evaluating trapezoidal coverage on the GPU.

Edges use 8bit fixed-point coordinates (x0,y0,x1,y1), totaling 32bits per edge and are uploaded to a texture.

Tiles are rendered with quads using GPU instancing, each tile contains an edge-list pointer, fill-info pointer along with the sign (inside/outside) state of it's bottom-left corner.

A sign buffer is used to track when paths cross the top/bottom of tiles. Before filling, the sign buffer is scanned from left to right, accumilating sign per tile.

TODO

  • OpenGL 3.0 Support (no instancing)
  • Line Caps & Joins
  • TTF Compound Glyph Support
  • TTF Kerning
  • SVG Image Parser
  • Texture Fill
  • Texture Caching

About

A small, header-only, GPU-accelerated vector graphics renderer for OpenGL.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C 100.0%
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载