All Projects → audulus → vger

audulus / vger

Licence: MIT license
2D GPU renderer for dynamic UIs

Programming Languages

c
50402 projects - #5 most used programming language
Objective-C++
1391 projects
objective c
16641 projects - #2 most used programming language
C++
36643 projects - #6 most used programming language
swift
15916 projects
Metal
113 projects
shell
77523 projects

Projects that are alternatives of or similar to vger

Fidocadj
FidoCadJ is a free user-friendly vector graphic editor for MacOSX, Linux, Windows and Android
Stars: ✭ 76 (-37.7%)
Mutual labels:  vector-graphics, 2d-graphics
ModernUI
Modern desktop framework from low-level 3D graphics API to high-level view model, for development of 2D/3D rendering software or game engine, with internationalization support and many new technologies.
Stars: ✭ 168 (+37.7%)
Mutual labels:  vector-graphics, 2d-graphics
Picasso
Picasso is a high quality 2D vector graphic rendering library. It support path , matrix , gradient , pattern , image and truetype font.
Stars: ✭ 205 (+68.03%)
Mutual labels:  vector-graphics, 2d-graphics
Luxor.jl
Simple drawings using vector graphics; Cairo "for tourists!"
Stars: ✭ 293 (+140.16%)
Mutual labels:  vector-graphics, 2d-graphics
Generative-Art
A selection of generative art scripts written in Python
Stars: ✭ 284 (+132.79%)
Mutual labels:  vector-graphics, 2d-graphics
ScalaTIKZ
ScalaTIKZ is an open-source library for PGF/TIKZ vector graphics.
Stars: ✭ 18 (-85.25%)
Mutual labels:  vector-graphics
metal-shading-language-specification
just a Chinese version of metal-shading-language-specification
Stars: ✭ 52 (-57.38%)
Mutual labels:  metal
sokol gp
Minimal modern efficient cross platform 2D graphics painter in C
Stars: ✭ 228 (+86.89%)
Mutual labels:  metal
MetalPlayer
A video player using Metal.
Stars: ✭ 68 (-44.26%)
Mutual labels:  metal
rend3
Easy to use, customizable, efficient 3D renderer library built on wgpu.
Stars: ✭ 546 (+347.54%)
Mutual labels:  metal
balanced
BalanceD is a Layer-4 Linux Virtual Server (LVS) based load balancing platform for Kubernetes.
Stars: ✭ 34 (-72.13%)
Mutual labels:  metal
awesome-metal
A collection of Metal and MetalKit projects and resources. Very much work in progress.
Stars: ✭ 152 (+24.59%)
Mutual labels:  metal
core
Create 2d primitive shapes, encapsulate and repeat them by handling each repetition and generate recursive shapes
Stars: ✭ 34 (-72.13%)
Mutual labels:  2d-graphics
sparta
Sparta is a canvas on top of Skia.
Stars: ✭ 28 (-77.05%)
Mutual labels:  vector-graphics
LOST--Java-2D-Game
2D side-scrolling game made in JAVA with sprite sheet animations
Stars: ✭ 2 (-98.36%)
Mutual labels:  2d-graphics
MetalGlobe
Simple demo project with Metal on Swift
Stars: ✭ 18 (-85.25%)
Mutual labels:  metal
delta-client
An open source Minecraft Java Edition client built for speed.
Stars: ✭ 168 (+37.7%)
Mutual labels:  metal
cocos2d-bgfx
cocos2d-x-lite use bgfx as the rendering backend
Stars: ✭ 54 (-55.74%)
Mutual labels:  metal
MushROMs
Super Nintendo game editing libraries and tools
Stars: ✭ 24 (-80.33%)
Mutual labels:  2d-graphics
metal-chests
Better alternative to IronChests
Stars: ✭ 13 (-89.34%)
Mutual labels:  metal

vger

build status Swift Package Manager (SPM) compatible

vger is a vector graphics renderer which renders a limited set of primitives, but does so almost entirely on the GPU. Works on iOS and macOS. API is plain C.

demo

Each primitive can be filled with a solid color, gradient, or texture. vger renders primitives as instanced quads, with most of the calculations done in the fragment shader.

Here's an early screenshot from vger in use for Audulus:

Here's it rendering that svg tiger (the cubic curves are converted to quadratic by a lousy method, and I've omitted the strokes):

Why?

I was previously using nanovg for Audulus, which was consuming too much CPU for the immediate-mode UI. nanovg is certainly more full featured, but for Audulus, vger maintains 120fps while nanovg falls to 30fps on my 120Hz iPad because of CPU-side path tessellation, and other overhead. vger renders analytically without tessellation, leaning heavily on the fragment shader.

vger isn't cross-platform (just iOS and macOS), but the API is simple enough that it could be ported fairly easily. If Audulus goes cross-platform again, I will port vger to vulkan or wgpu.

How it works

vger draws a quad for each primitive and computes the actual primitive shape in the fragment function. For path fills, vger splits paths into horizontal slabs (see vgerPathScanner) to reduce the number of tests in the fragment function.

The bezier path fill case is somewhat original. To avoid having to solve quadratic equations (which has numerical issues), the fragment function uses a sort-of reverse Loop-Blinn. To determine if a point is inside or outside, vger tests against the lines formed between the endpoints of each bezier curve, flipping inside/outside for each intersection with a +x ray from the point. Then vger tests the point against the area between the bezier segment and the line, flipping inside/outside again if inside. This avoids the pre-computation of Loop-Blinn, and the AA issues of Kokojima.

Status

  • Quadratic bezier strokes
  • Round Rectangles
  • Circles
  • Line segments (need square ends for Audulus)
  • Arcs
  • Text (Audulus only uses one font, but could add support for more if anyone is interested)
  • Multi-line text
  • Path Fills.

Installation

To add vger to your Xcode project, select File -> Swift Packages -> Add Package Depedancy. Enter https://github.com/audulus/vger for the URL. Check the use branch option and enter main.

Usage

See vger.h for the complete API. You can get a good sense of the usage by looking at these tests.

Vger has a C interface and can be used from C, C++, ObjC, or Swift. vgerEncode must be called from either ObjC or Swift since it takes a MTLCommandBuffer.

See the demo app for an example of using vger in a iOS/macOS SwiftUI app. vger includes VgerView to make it really easy to use Vger within SwiftUI:

import SwiftUI
import vger      // C/C++/ObjC interface.
import vgerSwift // Swift nicities.

struct HelloView: View {

    let cyan = SIMD4<Float>(0,1,1,1)

    var body: some View {
        VgerView(renderCallback: { vger in
            vgerText(vger, "Hello world. This is V'Ger.", cyan, 0)
        })
    }
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].