| Best approach to Rendering Vector Graphics with SDL? |
| Best approach to Rendering Vector Graphics with SDL? |
|
Sik
|
First obvious answer: OpenGL (or in the case of phones, OpenGL ES).
Then you can render pretty much any primitive you want with it. Also there was a function proposed for the SDL renderers which lets you draw arbitrary polygons (there are already some for some basic primitives, as well as scaling bitmaps), I don't think it's in SDL yet though. Note that ultimately you'd be drawing the primitives on your own, there isn't e.g. a SDL_DrawSVG function or something like that. But it's something, I suppose. 2013/3/13, bazz:
SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org |
|||||||||||||
|
|
||||||||||||||
| Best approach to Rendering Vector Graphics with SDL? |
|
Scott Percival
Guest
|
Depends what you want to use it for. In SDL, where you're managing all
the rendering yourself and not piggybacking off a UI library, 99.9% of the time you'd want to pre-rasterise your vector assets (i.e. load them in as PNGs) because it's so much freaking easier and cheaper. Otherwise, you'd have to include a separate stack for parsing the XML, decoding the SVG data, rasterising on-the-fly, and keeping the screen updates acceptable enough so that your test hardware doesn't catch fire from all the extra work. Even if you wanted to do this using librsvg/cairo/libxml2, and didn't mind taking several kilograms of hallucinogens to understand and write working GObject code, the LGPL prohibits static linking and you'd be locked out of iOS. So yeah, save your assets as bitmap. Need more resolution? Save them at a bigger size. New screen technology comes along? Save them even huger still. If you still really think you need SVG rendering, you might want to wait for Digia to finish scrubbing up Qt 5 for iOS and Android; they've thrown a lot of work at their QML stack to crank out accelerated vector graphics. On 13 March 2013 13:05, bazz wrote:
SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org |
|||||||||||||
|
|
||||||||||||||
| Best approach to Rendering Vector Graphics with SDL? |
|
LM
Guest
|
bazz wrote:
Supposedly faster more efficient downloads for browsers (if you're displaying via the web). However, not all browsers support it. As to vector formats, IE used VML for a long time. It's finally switching to the W3C standard. W3C promotes SVG. Xfig format has been around for a long time (longer than SVG) and is mainly used by applications on a system. Haven't seen much if any web use of Xfig format.
I thought the SDL_svg library ( http://www.linuxmotors.com/SDL_svg/ ) looked promising. I'm not particular about whether something's currently supported or not. Most Open Source programs I've run across use libRSVG. (Here's a note about it with Tux Paint: http://forums.libsdl.org/viewtopic.php?t=4968&sid=a6a67aec3d184e5d522f35c9f1d3b513) I wasn't particularly thrilled with this approach because it brings in a lot of dependencies which I'm not otherwise using on my system. You could look into xfig/winfig, transfig, netpbm options and store graphics in vector format for space concerns, but convert to bitmap before drawing. One other link I thought was interesting: http://code.google.com/p/svg-edit/ It's a SVG editor in a browser. Speaking of browsers, netsurf is a lightweight browser that supports, among other things, SDL display. You may want to check out how they're adding SVG support to their browser: http://www.netsurf-browser.org/projects/libsvgtiny/ It's an active project if that's what you're looking for.
Phones are using a subset of SVG (partly for speed and partly for compatibility). It's basically the same format, just not all the features.
Hopefully, I've given you a few ideas. Would be interested to hear if you turn up any other useful resources for vector graphics. Sincerely, Laura http://www.distasis.com/cpp _______________________________________________ SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org |
|||||||||||||||||||
|
|
||||||||||||||||||||
| Best approach to Rendering Vector Graphics with SDL? |
|
Jonny D
|
It's important to note that you shouldn't expect "vector graphics" to be a magical solution and that it means different things depending on the context.
First off, no matter what you do, vector graphics must be rasterized at some point (unless you use a specialized display). For the best performance, you want this rasterization to happen on the GPU. There isn't really a widely accepted solution for rendering vector graphics on the GPU. Hopefully OpenVG will get wider adoption so we can depend on it. Some hardware vendors are trying, but it's far from common. Cairo is a software solution (also has an OpenGL backend which might be worth looking at). Next, when someone says "vector graphics", they might actually mean "vector art". Vector art is used in a lot of games (Aquaria is one of my favorite examples), almost never with an actual runtime vector graphics rendering pipeline. You can create a nice-looking graphic in Inkscape (which I highly recommend), save it to a high-res png, then use it in your game. As long as you're using a hardware-accelerated backend (like OpenGL), it's going to perform much better than parsing an SVG file and going through all of the rasterization steps at runtime and you an do all the rotation and scaling you want. Also, vector graphics usually look simpler than raster graphics for good reason. If you want complex details in your visuals, then it will probably not work well (computationally, or your time effort to put those details in). It's good for a few specific art styles and techniques. Lastly, the actual work you have to do for achieving resolution independence with raster graphics vs. vector graphics is about the same. You have to define the drawing region and calculate the scaling (and possibly positioning) and everything either way. The real differences are that you're going to save memory using vector graphics (usually only important for low-resolution mobile devices, but remember that the computational cost is higher) and you'll get better quality at high resolution for the same low memory cost. Depending on your art tools, you can usually export appropriately-sized raster images for the display resolutions that you are targeting and be just fine. In my opinion, it's best not to spend your time trying to work out how to use vector graphics at runtime unless the lower memory needs of vector formats is important (as it is for browsers since download speeds are a bottleneck). Wait until the hardware support has improved before going down that path. Do definitely use Inkscape to create vector art assets and use them in your hardware-accelerated games. Jonny D On Wed, Mar 13, 2013 at 7:21 AM, LM wrote:
|
|||||||||||||||||||||
|
|
||||||||||||||||||||||

