8
\$\begingroup\$

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)?
\$\endgroup\$
5
  • 1
    \$\begingroup\$ Why do you need SVG? \$\endgroup\$ Commented Mar 19, 2011 at 18:17
  • \$\begingroup\$ 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. \$\endgroup\$
    – lefticus
    Commented Mar 19, 2011 at 20:42
  • 1
    \$\begingroup\$ 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. \$\endgroup\$ Commented Mar 19, 2011 at 21:18
  • 1
    \$\begingroup\$ 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. \$\endgroup\$ Commented Jan 25, 2013 at 12:14
  • 1
    \$\begingroup\$ You can always render the SVG to a spritesheet first on load \$\endgroup\$
    – Sidar
    Commented Apr 16, 2013 at 9:35

4 Answers 4

2
\$\begingroup\$

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?

\$\endgroup\$
5
  • \$\begingroup\$ 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). \$\endgroup\$
    – lefticus
    Commented Mar 20, 2011 at 3:45
  • \$\begingroup\$ 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? \$\endgroup\$
    – lefticus
    Commented Mar 20, 2011 at 3:45
  • \$\begingroup\$ Oh, one other thing. I don't see any methods for actually loading an SVG file and rendering it with libcairo. \$\endgroup\$
    – lefticus
    Commented Mar 20, 2011 at 3:52
  • \$\begingroup\$ 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. \$\endgroup\$
    – bkersten
    Commented Mar 20, 2011 at 4:40
  • \$\begingroup\$ 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? \$\endgroup\$
    – lefticus
    Commented Mar 21, 2011 at 15:03
2
\$\begingroup\$

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

\$\endgroup\$
1
\$\begingroup\$

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.

\$\endgroup\$
0
\$\begingroup\$

Irrlicht have SVG and joystick support

\$\endgroup\$
1
  • 4
    \$\begingroup\$ With some links and further explanation this could be a good answer. \$\endgroup\$
    – House
    Commented Apr 26, 2012 at 19:55

Not the answer you're looking for? Browse other questions tagged .