Rendering SVG's and changing color?

Im wanting all graphics in my project to be salable but i cant seem to figure out how to render SVG’s in LWJGL v2 and its becoming a nightmare, any ideas?

One way is to use NV_path_rendering, which works absolutely fantastically. I’m hoping it finds its way into the ARB specs soon.

Cas :slight_smile:

I looked at NanoSVG and NanoVG recently and the plan is to add bindings to both after LWJGL 3.0 is released.

So i’m guessing (at work cant check), you would read the SVG to get all the points, add some scaling factor and feed it into that?

Well… er… not exactly, rendering SVG is a bit more complex than that. Have a good read up on it on Nvidia’s site when you get back from work.

Cas :slight_smile:

Wouldn’t a pure port of NanoVG be more useful? NanoSVG seems to be less interesting as there are already a few simple SVG parsers written in Java including SVG Salamander.

If it improved the original in some way. If someone had the time to write it. If someone had the time to maintain it. Then, yes, it would be useful.

I have created a class that lets me load SVG’s and im working on animating them now :smiley:

Hi, I’m look to use nanovg to render the data parse from nanosvg.
Hi, can you help me correct this code?

NSVGimage* g_image = = nsvgParseFromFile(“drawing.svg”, “px”, 96.0f);
NSVGshape * shape;
NSVGpath * path;
int i;

nvgStrokeColor(vg, nvgRGBA(0,0,0,255));
for (shape = g_image->shapes; shape != NULL; shape = shape->next) {
    
    nvgStrokeWidth(vg, shape->strokeWidth);
    
    for (path = shape->paths; path != NULL; path = path->next) {
        for (i = 0; i < path->npts-1; i += 3) {
            float* p = &path->pts[i*2];

            nvgBeginPath(vg);
            nvgMoveTo(vg, p[0], p[1]);
            nvgBezierTo(vg, p[2], p[3], p[4], p[5], p[6], p[7]);
            nvgStroke(vg);
        }
    }
}