Graphics drawing primitives and other support functions wrapped up in an add-on, 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 graphics drawing primitives and other support functions
Latest Version (Ver 1.0.4 – 11 Feb 2018)
Sources and archives also on https://sourceforge.net/projects/sdl2gfx/
Changes: - version rev to 1.0.4 - fix int overflow in ellipseRGBA for large radii (thanks for reporting David) - fix aaline wrong direction hline bug (thanks Andre) - fix off-by-1 error in rotateSurface90Degrees (thanks Austin)
(C) A. Schiffler, aschiffler [at] ferzkopp.net 2012-2018, licensed under the zlib license
Extensions / External Versions
The following external versions have been made of SDL2_gfx:
- Richard Russell’s https://github.com/rtrussell/BBCSDL/blob/master/src/SDL2_gfxPrimitives.c adds the following routines:
- thickEllipseRGBA() – Draw thick outline ellipse with blending.
- thickArcRGBA() – Draw thick circular arc with blending.
- thickCircleRGBA() – Draw thick outline circle with blending.
- aaFilledEllipseRGBA() – Draw anti-aliased filled ellipse with blending.
- aaFilledPolygonRGBA() – Draw anti-aliased filled polygon with blending.
- aaFilledPieRGBA() – Draw anti-aliased filled pie or chord with blending.
- aaArcRGBA() – Draw anti-aliased elliptical arc with blending.
- aaBezierRGBA() – Draw anti-aliased Bézier curve with blending.
- aaFilledPolyBezierRGBA() – Fill a region bounded by cubic Bézier curves.
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] ferzkopp.net 1999-2018, licensed under the zlib license
Latest Version (Ver 2.0.26 – Mon Feb 20 2017)
Current Development Version via SVN
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.
SDL_gfx has been integrated with the following language interfaces:
- Pascal: http://www.freepascal-meets-sdl.net
- Perl: http://sdl.perl.org
- Python: http://www.pygame.org
- C#: http://cs-sdl.sourceforge.net
- Lua: http://www.egsl.retrogamecoding.org
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-polygon (not filled)
Please check README in archive and .h files for up-to-date interface information.