# 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 )

##### Share on other sites

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

##### 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

##### Share on other sites

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

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

Edited by Promit

##### 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 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 on other sites

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

##### 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

##### 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 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

## Create an account

Register a new account

• ## Partner Spotlight

• ### Forum Statistics

• Total Topics
627689
• Total Posts
2978659
• ### Similar Content

• Both functions are available since 3.0, and I'm currently using glMapBuffer(), which works fine.
But, I was wondering if anyone has experienced advantage in using glMapBufferRange(), which allows to specify the range of the mapped buffer. Could this be only a safety measure or does it improve performance?
Note: I'm not asking about glBufferSubData()/glBufferData. Those two are irrelevant in this case.
• By xhcao
Before using void glBindImageTexture(    GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format), does need to make sure that texture is completeness.
• By cebugdev
hi guys,
are there any books, link online or any other resources that discusses on how to build special effects such as magic, lightning, etc. in OpenGL? i mean, yeah most of them are using particles but im looking for resources specifically on how to manipulate the particles to look like an effect that can be use for games,. i did fire particle before, and I want to learn how to do the other 'magic' as well.
Like are there one book or link(cant find in google) that atleast featured how to make different particle effects in OpenGL (or DirectX)? If there is no one stop shop for it, maybe ill just look for some tips on how to make a particle engine that is flexible enough to enable me to design different effects/magic
let me know if you guys have recommendations.
• By dud3
How do we rotate the camera around x axis 360 degrees, without having the strange effect as in my video below?
Mine behaves exactly the same way spherical coordinates would, I'm using euler angles.
Tried googling, but couldn't find a proper answer, guessing I don't know what exactly to google for, googled 'rotate 360 around x axis', got no proper answers.

References:
Code: https://pastebin.com/Hcshj3FQ
The video shows the difference between blender and my rotation:

• By Defend
I've had a Google around for this but haven't yet found some solid advice. There is a lot of "it depends", but I'm not sure on what.
My question is what's a good rule of thumb to follow when it comes to creating/using VBOs & VAOs? As in, when should I use multiple or when should I not? My understanding so far is that if I need a new VBO, then I need a new VAO. So when it comes to rendering multiple objects I can either:
* make lots of VAO/VBO pairs and flip through them to render different objects, or
* make one big VBO and jump around its memory to render different objects.
I also understand that if I need to render objects with different vertex attributes, then a new VAO is necessary in this case.
If that "it depends" really is quite variable, what's best for a beginner with OpenGL, assuming that better approaches can be learnt later with better understanding?

• 18
• 14
• 12
• 10
• 12