Sign in to follow this  
Martin Perry

OpenGL OpenGL and SVG rendering in C++

Recommended Posts

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 )

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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?

Edited by Promit

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites


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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this