Monday, April 23, 2012

Adding font display to the SDL graphics.

[[caption id="attachment_282" align="alignnone" width="300" caption="SDL Font Demo"][/caption]


I had to install the SDL_ttf dev library to compile this one.

The command line to compile this is:

gcc `sdl-config --cflags --libs` -lSDL_ttf fontdemo.c

Notice the additional


that was added.

The original example code is here.

The arial ttf library is at that link. It has to be renamed to all lowercase to work.

I added a check to see of the font was loaded, the program crashes if font is not found. I made the font background transparent so the font would overlay onto the graphic. I added the graphic.

Updated this to use a different method of creating the text.

Everything the same as above, here is the new code:


No comments:

Post a Comment