I haven't played around much yet with calling into emscripten code from JS, but the nanovg API is very simple and pure C, so it should be possible:
- the context is actually an pointer, but never used as a pointer, only as an opaque handle
- images and fonts have normal int's as id
- the image and font creation functions could be a bit tricky, they either take a filename, or a memory pointer/size pair
Vanilla nanovg at first had shockingly bad perf on Chrome, but that turned out to be the many glGetError calls, also the test scene currently has 538 draw calls and 6182 GL calls, which seems a bit heavy, hopefully this can be reduced with a bit of optimization work, I'll write a few nanovg tickets today and step a bit through the code to understand it better.
Cheers,
-Floh