OpenGL and SVG rendering in C++

Started by
8 comments, last by OlegMax 9 years, 8 months ago

Hi ai am looking for some way how to render SVG graphics.

I have come up with two possible solutions:

1) Convert it to set of triangles and fill them with colors

2) Render to texture SVG and then only display it

For either one of them, I am not able to find any solution written in C++ and being multiplaform (Windows, Linux, Mac, iOS, Android). Do you know something that can be used ?

Or I can write something on my own, but I am not very familiar with SVG, so I dont know how complex it is (I have written collada loader once and it was pain in the ass.. so wacko.png )

Advertisement

One way to do this is to build it on top of OpenVG. This SO thread has some suggestions of OpenVG implementations.

SlimDX | Ventspace Blog | Twitter | Diverse teams make better games. I am currently hiring capable C++ engine developers in Baltimore, MD.

I have looked at OpenVG and its not directly supported on mobile devices, as I see it. Last stable version is 1.1 and little old (2008). Extensions build on top of it are either for mobile or desktop, nothing really multiplatform. And most of the projects is also pretty outdated. Wonder why, since SVG is the only vector format widely used and supported by HTML5 unsure.png

Try this one: https://github.com/micahpearlman/MonkVG

Built on top of OpenGL ES 2.0, supports most iOS/Android.

SlimDX | Ventspace Blog | Twitter | Diverse teams make better games. I am currently hiring capable C++ engine developers in Baltimore, MD.

I have looked at that, but it violates my requirement for desktop support (eg. full OpenGL). I am afraid, that realtime library with ES and full OpenGL support together doesnt exist.

I would just be happy for something that only convert SVG to raster texture. I can generate it during install or resolution change and than only use it as background. But even for this I have not found suitable solution.

Last time I had to port something from ES to desktop OpenGL, I think it took half an hour. Maybe less. I don't think you should consider that a deal breaker. But if you just need something to offline render it, I think Cairo might be able to do it?

SlimDX | Ventspace Blog | Twitter | Diverse teams make better games. I am currently hiring capable C++ engine developers in Baltimore, MD.

For now, thanks.. I will give it a try :)

I would just be happy for something that only convert SVG to raster texture. I can generate it during install or resolution change and than only use it as background. But even for this I have not found suitable solution.

At Mazatech we have developed AmanithSVG, a middleware aimed to the static SVG rendering: http://www.mazatech.com/amanithsvg/

We are releasing our SDK as Unity3d plug-in and as Standalone library.

The software is written in pure ANSI C++ and it's crossplatform:

  • Android (ARM, ARMv7, MIPS, X86)
  • iOS7 (Universal Binary)
  • MacOS X (Universal Binary)
  • Windows (X86, X86_64)
  • Linux (ARM, ARMv7, MIPS, PPC, X86, X86_64).

If a closed source solution could fit you requirements, feel free to send me a PM.

Watch the video tutorial (Unity3d plugin version) at: https://vimeo.com/100983415

ScreenShot00.png

ScreenShot01.png

Last time I had to port something from ES to desktop OpenGL, I think it took half an hour. Maybe less. I don't think you should consider that a deal breaker. But if you just need something to offline render it, I think Cairo might be able to do it?


I have myself been keeping an eye open for good open source SVG rendering libraries, but have found none that works really well. (Any tips anyone might have are welcome).

Cairo has the primitives needed to render SVG, but I think it has no way of doing SVG filters like blur and so on. If you don't need that, it can probably be made to work. It won't be trivial, though. Cairo has no built in support for rendering an SVG. Inkscape (SVG editing program) has been struggling for years with attempting to convert their renderer to use Cairo instead. They still are not done.

There exists a library built on top of Cairo called librsvg. I don't know how well it supports advanced features like filters, though. The problem with librsvg is that it isn't very standalone, it requires a lot of the base libraries for the GTK+ toolkit.

QT also has an SVG renderer. I tried it, and it doesn't support filters. It also isn't very standalone as it requires much of QT functionality.

The problem with making a decent SVG renderer seems to be text support. Most of the dependencies in librsvg and QTs implementation seem to be because of this.

My plan from the beginning was to have SVG as textures in a game, but after some research I just gave up and surrendered to use pixel graphics instead.


I have myself been keeping an eye open for good open source SVG rendering libraries, but have found none that works really well. (Any tips anyone might have are welcome).

Hi. I'm now finishing development of first public version of SVG++ library that is intended to take most SVG headache from the developer. There is still documentation and samples to be done, but anyone interested may look onto it here

This topic is closed to new replies.

Advertisement