# SDL2 vector graphics image loader

This topic is 1179 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I'm looking for library to load vector graphics into SDL2. I have found cairo which I only find tutorials for sdl1.2. I have also found sdl_svg also sdl1.2 and so on.

I can't find any information on loading vector graphic that uses the SDL2. Is the svg file format dead or something.

##### Share on other sites

Hi there.

In shorts: you must obtain some kind of parser/rasterizer library ( such as nanosvg ), integrate it into your project, then use it to load & rasterize SVG image & then pass the results as a pixel data to your SDL_Surface. Then you are free to go with the creation of SDL_Texture or whatever.

Neither SDL1.2 nor SDL2 have direct support for SVG.

P.S.

SVG format is a way far from being dead.

##### Share on other sites

Has anyone used the nanosvg examples before. I need to install glfw3 on linux. I downloaded to source and compiled it and moved the GLEW directory into the /usr/include. I get errors for all the glfw system calls. I have not used glfw for a while and can't remember what else to do.

I just want to get it running with the example before I start making my implementation in SDL.

Edited by workaround

##### Share on other sites

I'm trying to build examples and getting the same errors.

I'll report my progress as I'll solve something.

##### Share on other sites

Then go to console and type the following:

unzip glfw-3.1.1.zip
cd glfw-3.1.1/
mkdir curbuild && cd curbuild
cmake -G "Unix Makefiles" -DBUILD_SHARED_LIBS=ON ../
make -j3
sudo make install

this will place your glfw headers and .so files in appropriate folders under the /usr/local ( you don't have to manually move anything ).

Then some part of magic takes effect.

It happened so, that nanosvg has some kind of unhealthy build system inside ( premake4 + pre-made makefiles + damaged ( ??? ) Makefile generated from premake4 ).

To build example do the following.

unzip nanosvg-master.zip
cd nanosvg-master/example
cp ../src/nanosvg* .
gcc -O2 example1.c -L/usr/local/lib -lGL -lglfw -lm -Wl,-rpath=/usr/local/lib -o example1
gcc -O2 example2.c -L/usr/local/lib -lGL -lglfw -lm -Wl,-rpath=/usr/local/lib -o example2

After performing these actions I was able to launch both examples. Good luck to you, and if you need any further explanations ( i.e. makefiles, command line invocations ) feel free to ask.

P.S.

I don't know if GLEW is really needed here, cause I have one installed in /usr/local, but it seems that GLFW and nanosvg have no dependencies on GLEW, and I was able to compile, link and run without linking against libGLEW.so.

btw, my current system is Linux Mint 17.

Linux host 3.13.0-24-generic #47-Ubuntu SMP Fri May 2 23:30:00 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
gcc (Ubuntu 4.8.2-19ubuntu1) 4.8.2

I have Debian 8 x64 at home, if you need, I can test this there too.

##### Share on other sites

syskrank thanks for the help on installing glfw and compiling nanosvg.

Everything works fine. I'm using Linux mint 17 also with slightly updated kernel and it all worked.

I'm sure GLEW is also not needed. I think that I was using GLEW for opneGL to test using depth in my game. I must have typed it by mistake because of that.

Edited by workaround

##### Share on other sites

Also because the second example does not display the image there is no need for the glfw linking along with gl. glfw is just a window manager.

gcc -O2 example2.c -L/usr/local/lib -lm -Wl,-rpath=/usr/local/lib -o example2


##### Share on other sites

Also because the second example does not display the image there is no need for the glfw linking along with gl. glfw is just a window manager.

Yeah, I know, I've just been lazy hitting 'up' and changing 1s to 2s in gcc command =)

1. 1
2. 2
Rutin
18
3. 3
4. 4
5. 5

• 14
• 12
• 9
• 12
• 37
• ### Forum Statistics

• Total Topics
631428
• Total Posts
3000027
×