SDL_prims — simple 2D graphics primitives for SDL

SDL_prims is (yet another) implementation of simple 2D graphics primitives for SDL. (The others that I know of either try to do way too much or else fail horribly to compile on some architecture/OS or other.) SDL_prims is presented as a single C source file (with accompanying header file) that you can just compile and link into the rest of your SDL-based project. SDL_prims provides: All of the above work in 8-, 16-, 24- and 32-bit depths and will obey the clipping rectangle set for the destination surface.

SDL_prims was an evening hack to add some badly-needed functionality to an SDL project; as such it currently does not provide antialiasing or alpha blending, nor does it have any documentation beyond the notes below. Sorry!

Download the source code: SDL_prims-0.2.tar.gz
Browse the source code: SDL_prims-0.2
A trivial program is included with the library that demonstrates some of the shapes that can be drawn. (Just type make and hope for the best.)

SDL_prims is distributed under the MIT license. It will not infect your project with a contagious disease if you decide to use and/or modify it.

Using the library

Drop the SDL_prims.c file next to your other source files and add it to your Makefile. Include the SDL_prims.h in any source file that needs to call any of the following functions: All of the above functions answer 0 if they succeed, or -1 if they fail.

The SDL_Point structures that represent vertices in the polygon functions are simply the first half of the familiar SDL_Rect structure:

typedef struct SDL_Point {
  Sint16 x;
  Sint16 y;
} SDL_Point;

If you fix any bugs, please send your fixes to Ian Piumarta by email at 'first-name at last-name dot com'. Thanks!