Graphics drawing primitives and other support functions wrapped up in an addon, C-based library for the Simple Direct Media (SDL) cross-platform API layer. SDL_gfx supports the original SDL1 library using software surfaces, and SDL2_gfx supports SDL2 using rendering functions.

SDL2_gfx Library

SDL2 graphics drawing primitives and other support functions

Latest Version (Ver 1.0.1 – Sun Jun 15 2014)

SDL2_gfx-1.0.1.tar.gz (.zip) (or on SourceForge)

Older versions



Doxygen generated API documentation

(C) A. Schiffler, aschiffler [at] 2012-2015, licensed under the zlib license

SDL_gfx Library

SDL graphics drawing primitives and other support functions

The SDL_gfx library evolved out of the SDL_gfxPrimitives code which provided basic drawing routines such as lines, circles or polygons and SDL_rotozoom which implemented a interpolating rotozoomer for SDL surfaces.

The current components of the SDL_gfx library are:

  • Graphic Primitives (SDL_gfxPrimitves.h)
  • Rotozoomer (SDL_rotozoom.h)
  • Framerate control (SDL_framerate.h)
  • MMX image filters (SDL_imageFilter.h)
  • Custom Blit functions (SDL_gfxBlitFunc.h)

The library is backwards compatible to the above mentioned code. Its is written in plain C and can be used in C++ code.

(C) A. Schiffler, aschiffler [at] 1999-2013, licensed under the zlib license




Overview and doxygen generated API documentation


Latest Version (Ver 2.0.25 – Sun Oct 28 2013)

SDL_gfx-2.0.25.tar.gz (or on SourceForge)

Current Development Version via SVN

Older Releases


Supported Platforms

The library compiles and is tested for a Linux target (gcc compiler) and a Win32 target (VisualC, xmingw32 cross-compiler) as well as BeOS and MacOS X PowerBuilder See README for VC and PowerBuilder compile information. When using the cross-compiler (available on the author’s homepage), the build process generates .DLLs. You can use the command line ‘LIB.EXE’ tool to generate VC6 compatible .LIB files for linking purposes.

Language Interfaces

SDL_gfx has been integrated with the following language interfaces:

  • Pascal:
  • Perl:
  • Python:
  • C#:
  • Lua:
Notes on Graphics Primitives

Care has been taken so that all routines are fully alpha-aware and can blend any primitive onto the target surface if ALPHA<255. Surface depths supported are 1,2,3 and 4 bytes per pixel. Surface locking is implemented in each routine and the library should work well with hardware accelerated surfaces. Currently, The following Anti-Aliased drawing primitives are available:

  • AA-line
  • AA-circle
  • AA-ellipse
  • AA-polygon (not filled)
Please check README in archive and .h files for up-to-date interface information.
SDL_gfx / SDL2_gfx
Tagged on:             

5 thoughts on “SDL_gfx / SDL2_gfx

  • December 25, 2016 at 2:23 pm

    Thanks for your work on SDL2_gfx ferzkopp!

    Its helping me a lot on a current project.

    I’ve noticed something in the source code of SDL2_gfxPrimitives.c:
    int roundedBoxRGBA(SDL_Renderer * renderer, Sint16 x1, Sint16 y1, Sint16 x2,
    Sint16 y2, Sint16 rad, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
    * Special case – no rounding
    if (rad <= 1) {
    return rectangleRGBA(renderer, x1, y1, x2, y2, r, g, b, a);

    maybe it shoud be:
    * Special case – no rounding
    if (rad <= 1) {
    return boxColor(renderer, x1, y1, x2, y2, r, g, b, a);
    If a roundedBoxRGBA is being asked with no radius, a boxColor probably should be delivered instead of rectangleColor.

    I've patched and rebuilt that way but figured you could use this feedback


    • December 25, 2016 at 6:49 pm

      Yes, looks like a copy-n-paste bug. Thanks for letting me know.

  • October 15, 2016 at 4:03 pm

    Can you provide steps on to how build the SDL2_gfx dll for visual studio 2015?

    • December 25, 2016 at 2:11 pm

      In you’re still looking for an answer: the SDL2_gfx downloads are available in .tar.gz and .zip: the .zip comes with vs2015 solution, (almost) ready to build. If you have the SDL2-devel-2.0.5-VC (or other version) development Libraries already the only thing you’ll need to do is set its include and library paths on the vs project and build it.


Leave a Reply

Your email address will not be published. Required fields are marked *