Jump to content

  • Log In with Google      Sign In   
  • Create Account

Resolution-independent graphics with SVG in SDL


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
5 replies to this topic

#1 vinnyvicious   Members   -  Reputation: 409

Like
0Likes
Like

Posted 14 January 2014 - 06:44 AM

Has anyone used SVG before with SDL, in order to achieve resolution-independent graphics in games? Most of our projects are born in Adobe Illustrator as vector art and we end up exporting a lot of PNG's for different resolutions: iPhone, iPad, Retinas, Droids, Droids HD, etc. I wanted to add some kind of support for SVG in our game, both with preload cache and live rasterization. For example: when a scene loads, i can rasterize the background and props based on the current resolution, but keep the player and enemies being rendered on each frame (since i can alter their SVG in-game). 

 

Do you guys recommend any library with good performance? Is there a SDL integration available, allowing me to render SVG's as SDL textures? I'm on SDL 2.0, by the way.



Sponsor:

#2 FLeBlanc   Crossbones+   -  Reputation: 3125

Like
0Likes
Like

Posted 14 January 2014 - 09:36 AM

It's not SDL-centric, but you might look at incorporating NanoSVG with your own custom rasterizer that rasterizes to an SDL image.

#3 vinnyvicious   Members   -  Reputation: 409

Like
1Likes
Like

Posted 14 January 2014 - 12:05 PM

But i'll have to save a bitmap from an SVG and then load into SDL? Isn't there a way of doing that in-memory?



#4 vinnyvicious   Members   -  Reputation: 409

Like
0Likes
Like

Posted 20 January 2014 - 12:45 PM

Bumping! :)



#5 nobodynews   Crossbones+   -  Reputation: 2194

Like
0Likes
Like

Posted 20 January 2014 - 06:14 PM

But i'll have to save a bitmap from an SVG and then load into SDL? Isn't there a way of doing that in-memory?

The example2.c file shows how to get the image into memory. After nsvgRasterize is called img will point to the image data. SDL_CreateRGBSurfaceFrom can be used to create a surface from img. It seems like img will contain 32-bit depth (4 bytes per pixel). So you'd probably call it like this:

 

surface = SDL_CreateRGBSurfaceFrom(img, w, h, 32, 0, 0, 0, 0);

 

According to the SDL remarks for that function, when done with surface you would need to call SDL_FreeSurface(surface); and also release the memory pointed to by img. example2.c uses malloc to get the memory so you'd need to use use free(img). If you're using C++ then you should probably allocate the memory with new[] and release with delete[].


C++: A Dialog | C++0x Features: Part1 (lambdas, auto, static_assert) , Part 2 (rvalue references) , Part 3 (decltype) | Write Games | Fix Your Timestep!


#6 Mfabbri77   Members   -  Reputation: 114

Like
0Likes
Like

Posted 19 July 2014 - 12:38 AM

Has anyone used SVG before with SDL, in order to achieve resolution-independent graphics in games? Most of our projects are born in Adobe Illustrator as vector art and we end up exporting a lot of PNG's for different resolutions: iPhone, iPad, Retinas, Droids, Droids HD, etc. I wanted to add some kind of support for SVG in our game, both with preload cache and live rasterization. For example: when a scene loads, i can rasterize the background and props based on the current resolution, but keep the player and enemies being rendered on each frame (since i can alter their SVG in-game). 

 

Do you guys recommend any library with good performance? Is there a SDL integration available, allowing me to render SVG's as SDL textures? I'm on SDL 2.0, by the way.

 

At Mazatech we have developed AmanithSVG, a middleware aimed to the static SVG renderinghttp://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: 

 

ScreenShot00.png

 

ScreenShot01.png






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS