Does Kha have a vector drawing API like Nanovg? If not, do would it be of interest?
Posts 5 | Views 844
There is http://api.kha.technology/kha/graphics2/Graphics.html and http://api.kha.technology/kha/graphics2/GraphicsExtension.html
But this is quite different - graphics2 is designed to be mapped easily to <canvas> and similar apis and when running directly on a lower level graphics api it is designed to be fast so it only supports hardware antialiasing.
If you are interested in for example porting nanovg to Kha I think a bunch or people would be interested in that but I wouldn't want to put it into Kha directly - or any other higher level functionality, Kha itself is purely a low level portability framework.
@Robert Hmm.....I did a little digging and found someone has already has C++ externs for Haxe (https://github.com/dazKind/hx-nanovg). Also, NanoVG does do an Emscripten compile to work with canvas. The bgfx engine incorporates nanovg and is HTML5 compatible.
I'm wondering though if a pure Kha implementation would be better. At the end of the day GPU's don't really draw curves (excluding the new NV_path thing-a-majig). They draw small lines on quads and calculate the vertex position to make it look like a curve. You've already got line drawing capabilities in Kha (is it based on GL_LINES mode?) so drawing curves isn't far off. I would just have to whip out some math skills I haven't used in about 8 years or so......:-)
A pure Kha implementation could run on all of the targets which Kha supports, would of course be better.
Lines are triangulated because GL_LINES is weird (see https://mattdesl.svbtle.com/drawing-lines-is-hard) and I don't even know if modern hardware actually supports lines or if it's all just triangulated in the driver anyway.
@Robert: Awesome! I'll see what I can whip up. I also found this (https://github.com/Chlumsky/msdfgen). It gives nice sharp lines in addition to being a good text renderer. I'll see if I can comprehend the algo and implement it in Haxe. The core however has no dependencies if C++11 is used. It will probably compile for emscripten if its that light. Hmm....option options.....