GitXplorerGitXplorer
s

nanovg-nanort

public
51 stars
10 forks
0 issues

Commits

List of commits on branch master.
Unverified
8d312fae6c1ebb133e14974c69e3ecf9e05d9e8e

Update NanoVG and STB.

ssyoyo committed 6 years ago
Verified
85a9e49c9839947e73f8c1191d0bb0a4d7285bf6

Merge pull request #2 from Type1J/bounds

ssyoyo committed 7 years ago
Unverified
b670d4a227856e2b4c42fcd4dd779cf852f935df

Add bound check. Fixes #1.

ssyoyo committed 7 years ago
Unverified
3ecae7811046464b2bab350833b6548d288e3694

Add bounds checks.

TType1J committed 7 years ago
Unverified
c89b4d20f2a1cd91028a4ffee2d5604f3f797f49

Suppress VS compiler warnings.

ssyoyo committed 9 years ago
Unverified
b61d147aa2fea73094c4e09d87025f3564342d7b

Add AppVeyor script.

ssyoyo committed 9 years ago

README

The README file for this repository.

NanoRT backend for NanoVG

nanovg-nanort is a CPU backend using software ray tracer(NanoRT) for Mikko Mononen’s awesome vector graphics renderer NanoVG(https://github.com/memononen/nanovg).

nanovg-nanort does not require OpenGL environment, thus it can draw vector graphics in various environment(e.g. server-side, no-GPU/no-OpenGL machine, virtual machine environment, etc).

In contrast to default OpenGL backend for NanoVG, nanovg-nanort requires C++(C++-98 + STL) compiler.

How to use.

Simply copy src/** files to your project. See example/example_rt.cc for example.

#include "nanovg.h"

// Defined these in *one* .cc
#define NANOVG_RT_IMPLEMENTATION
#define NANORT_IMPLEMENTATION
#include "nanovg_rt.h"

NVGcontext* vg = NULL;

int winWidth = 1024;
int winHeight = 1024;
float pxRatio = 1.0f;

vg = nvgCreateRT(NVG_DEBUG, winWidth, winHeight);
if (vg == NULL) {
	printf("Could not init nanovg.\n");
	return -1;
}

nvgClearBackgroundRT(vg, 0.3f, 0.3f, 0.32f, 1.0f);

nvgBeginFrame(vg, winWidth, winHeight, pxRatio);

// ... call nvg API here as usual ...

nvgEndFrame(vg);

// Grab rendered image
unsigned char* rgba = nvgReadPixelsRT(vg);

//stbi_write_png("render.png",  winWidth, winHeight, 4, rgba, winWidth * 4);

nvgDeleteRT(vg);

TODO

  • [ ] Anti-alasing.
  • [ ] compositeOperation
  • [ ] Robust alpha-blending.
  • [ ] Premultiplied alpha validation.
  • [ ] Optimization.
    • [ ] Draw call optimization.
    • [ ] Multi-threaded rendering.

License

nanovg-nanort is licensed under zlib license. See LICENSE.txt for details. NanoVG is licensed under zlib license. NanoRT is licensed under MIT license.