I'm looking into building a cross-platform opensource 2D RPG style game engine for ChaiScript.

I want to be able to do all of the graphics with SVG and need joystick input. I also need the libraries I use to be opensource and compatible with the BSD license.

I'm familiar with allegro, ClanLib, and SDL. As far as I can tell, none of these libraries have built in or obvious integration for SVG. Also, I'm aware of the previous conversations on this site regarding Qt for SVG game development.

I'm hoping to avoid Qt because of the size and complexity of making it a requirement. Also, Qt does not seem to have joystick input support, which would require that SDL or some other library also be used.

So my question can be summed up as this:

  • What is the best way to get SVG and joystick support in a 2D C++ library while minimizing dependencies as much as possible (preferably avoiding Qt altogether)?

closed as off-topic by Josh Apr 7 '14 at 16:40

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions about "how to get started," "what to learn next," or "which technology to use" are discussion-oriented questions which involve answers that are either based on opinion, or which are all equally valid. Those kinds of questions are outside the scope of this site. Visit our help center for more information." – Josh
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    Why do you need SVG? – AttackingHobo Mar 19 '11 at 18:17
  • I don't need SVG, but it would help provide the look and feel I want. I want the engine to be easily scalable to many different screen sizes, plus have dynamic zooming of the active game area. – lefticus Mar 19 '11 at 20:42
  • 1
    If you need a lot of scaling that might be a good way to go. But with SVG or any other vector format, there is a large downside, each object takes longer to draw the more complex it is. While with raster art, most of the drawing time depends on the size of the object, and to some extent the amount of transformations. – AttackingHobo Mar 19 '11 at 21:18
  • 1
    The reason why SVG is a GOOD IDEA(tm) for a format to use in a 2D vector based game engine can be summarized in one word: Inkscape. The truth is that the code is only half the game. Without a great tool for content production you will not succeed in making all but the smallest of games. – Lennart Rolland Jan 25 '13 at 12:14
  • 1
    You can always render the SVG to a spritesheet first on load – Sidar Apr 16 '13 at 9:35

I don't see any reason why you couldn't use SDL or another input library with a 2D graphics library like libcairo.

As for ChaiScript, have you heard of Lua?

  • I have heard of Lua. I'm one of the authors of ChaiScript and am aiming to work on a project that exercises the language. Besides that it is significantly less work to use ChaiScript with C++ then Lua (event taking into account SWIG or LuaBind). – lefticus Mar 20 '11 at 3:45
  • Regarding libcairo. It seems that there's a lot of work and a significant number of dependencies to get libcairo rendering to SDL, or am I missing something? – lefticus Mar 20 '11 at 3:45
  • Oh, one other thing. I don't see any methods for actually loading an SVG file and rendering it with libcairo. – lefticus Mar 20 '11 at 3:52
  • SVG is just XML. I'm sure there are libraries for reading svg files that would suit your needs. Cairo however is a fast 2D graphics library that would give you the visual style that you are after. Using Cairo with SDL makes it look simple. – bkersten Mar 20 '11 at 4:40
  • So, if I'm really set on SVG and I don't want to roll my own renderer, that'd mean librsvg which requires libcairo, which requires libgdk and libgtk and then sdl for crossplatform input management. Or just Qt. Out of curiosity, does anyone have experience with building an SVG based game engine that's crossplatform? – lefticus Mar 21 '11 at 15:03

I'm familiar with allegro, ClanLib, and SDL. As far as I can tell, none of these libraries have built in or obvious integration for SVG.

Has it ever occurred to you to ask... why that is?

Sure, SVG is a complicated specification to implement on a basic "getting the XML into memory and validating it" level. But I don't think you fully appreciate the simple fact that SVG rendering is not fast.

Web browsers are fast if they render a webpage in less than 500ms or so. SVG images may take 20ms+ to render, and that's for small, simple ones. Something you might find in a game, a non-graphically-trivial game, are going to take much, much longer. SVG image rendering is not intended for fast animation.

Even something lower-level like libCairo isn't exactly a high-performance renderer. Sure, it's fast enough for a browser, but it isn't exactly blazing in its software-rendering performance.

In short, I would ditch SVG entirely and see if libCairo can serve your needs. That's just for evaluation purposes, to see if it performs fast enough in circumstances that approximate the purpose you intend for them. Once that's determined, you can decide what to do next in terms of technology (Qt, SDL, whatever).

In regards to this SVG is not the best for generating on-the-fly content and for real-time rendering, even in 2d, however....

If you were to use the SVG files to make your original content you could then have a pre-level/area generation phase with appropriate loading screen/cut-scene where you would use the SVG content to render standard images of the resolution you need, this would allow you to code simply with normal images as whilst retaining the flexibility of the SVG for multi-resolution targeting. It is not idea but this way you can leverage the hardware to play with the prerendered images in the way it was designed to do, rather than trying to generate content on the fly from SVG files. As the computer would only be displaying the loading screen/cut-scene you could dedicate a huge proportion of available resources to generating the standard images from SVG and therefore do it in a fast and efficient fashion.

Irrlicht have SVG and joystick support

  • 3
    With some links and further explanation this could be a good answer. – MichaelHouse Apr 26 '12 at 19:55

Not the answer you're looking for? Browse other questions tagged or ask your own question.