   SVG in games
  I've sure have been posting questions on GDNet often lately. I must be failing as a programmer! ;) Anyway, I'm currently developing a 2D game on three major computer platforms (Win32, OSX/Cocoa, Unix/X11), but I may want to port it to mobile devices (Android, iPhone, PSP, etc) later on. Some of these systems, especially iPhone 4 at 326 DPI, have ridiculously high resolution. 32x32 tiles would be FAR too tiny on such screens! My first thought was to scale the same static graphics to a more managable size, which would result in blocky graphics.I've been considering using a vector format for in-game graphics, which would prevent ugliness on high DPI screens. I'm having trouble finding a suitable format. I've been studying W3C's SVG format, but it appears bloated and packed with thousands of features I would never use, even in the SVG Tiny profile. What I'm looking for is a static graphic without animation or interaction. One way around this could be using SVG, but prerendering graphics as they appear initially, before any sort of interaction.So it looks like I have 3 options:1. Use a minimal subset of SVG features.2. Find or develop a simpler format that suits my goal.3. Revert to my original plan of using pixmap graphics.What are your thoughts on the situation? Any help is appreciated.EDIT: Looks like I can't count to 3![Edited by - Daggerbot on November 17, 2010 10:30:49 AM]
  Creating your own vectorial format is easier than using a complex one like SVG, especially since your probably want only a list of 2d points forming polygon shapes.What's harder is to use a good graphic library available on all those platforms which allow you to draw polygons, and not just rectangular surfaces. I had this problem before, SDL only allow rectangular surface and DirectX/OpenGL needs triangle list, not polygons, so you have to "triangulize" the polygons so they get rendered as a bunch of triangles. With SFML though, you can draw shapes directly the way you want it.   ;  If there is no animation or sizing at runtime, why not draw in a vectorformat (whatever format/drawing program fits you) and render these images to bitmaps for the platforms/DPIs? Implementing a vector format is a lot of work.   ;Quote:Creating your own vectorial format is easier than using a complex one like SVG, especially since your probably want only a list of 2d points forming polygon shapes.What's harder is to use a good graphic library available on all those platforms which allow you to draw polygons, and not just rectangular surfaces. I had this problem before, SDL only allow rectangular surface and DirectX/OpenGL needs triangle list, not polygons, so you have to "triangulize" the polygons so they get rendered as a bunch of triangles. With SFML though, you can draw shapes directly the way you want it.What I was thinking is more along the lines of rendering the graphic to a texture a load time, then rendering the texture when the graphic is needed. Scaling wouldn't be possible, but that's not a huge problem.Quote:If there is no animation or sizing at runtime, why not draw in a vectorformat (whatever format/drawing program fits you) and render these images to bitmaps for the platforms/DPIs?Implementing a vector format is a lot of work.I was hoping to use a single data archive that would be used by the game on all platforms, but I will probably end up doing what you mentioned instead. Keeping a separate data profile for each system would be far more easy than writing a vector graphics renderer.   ;  You would still have a single data archive except that you generate different sets of bitmaps from it. Just like compiling the same C code for different platforms, one code base.   ;Quote:Original post by DungeCreating your own vectorial format is easier than using a complex one like SVG, especially since your probably want only a list of 2d points forming polygon shapes.A custom format would make it easier to load assets into your game (I tried writing an SVG parser once; SVG is a monster). But now you have to create an export plugin for Illustrator or Inkscape or whatever you're using to create these vector images. Which would not be that unusual (most 3D games use their own model format) but it's still something you have to keep in mind.Best of luck to you. I would really like to see more 2D games that use vector graphics (without Flash).   ;Quote:Original post by VideroBoyQuote:Original post by DungeCreating your own vectorial format is easier than using a complex one like SVG, especially since your probably want only a list of 2d points forming polygon shapes.A custom format would make it easier to load assets into your game (I tried writing an SVG parser once; SVG is a monster). But now you have to create an export plugin for Illustrator or Inkscape or whatever you're using to create these vector images. Which would not be that unusual (most 3D games use their own model format) but it's still something you have to keep in mind.Best of luck to you. I would really like to see more 2D games that use vector graphics (without Flash).Another option is instead of writing a plugin to programs, write a small command line program that parses the SVG tree and outputs a file in your format.   