Skip to content
Proyek

Tentang

SDL_gfx code: Library containing 20+ graphics primitives (line, box, circle, polygon,...) for SDL 1.2.

Desain dan media

Cara angka ini diukur

Pertumbuhan bintang terukur

dalam 24 jam
0
dalam 7 hari
0
dalam 15 hari
+1
dalam 1 bulan
Mengumpulkan riwayat

Perubahan bersih pada periode yang tumpang tindih, bukan total harian. Pengukuran yang belum tersedia dibiarkan kosong. Bintang menunjukkan perhatian, bukan kualitas.

README.md

Asli

SDL_gfx

Graphics primitives, rotozoomer, framerate control, image filters and custom blitters for SDL 1.2 surfaces.

Graphics primitives Rotozoom

SDL_gfx works with SDL 1.2 — classic SDL-1.2 or sdl12-compat. For SDL2 use SDL2_gfx, for SDL3 use SDL3_gfx.

Components

Component Files Description
Graphics primitives SDL_gfxPrimitives.h/.c Pixels, lines (plain, anti-aliased, thick), rectangles, rounded boxes, circles, arcs, ellipses, pies, triangles, polygons (filled, anti-aliased, textured), Bézier curves and text with a built-in or custom bitmap font
Built-in font SDL_gfxPrimitives_font.h 8x8 bitmap font; more fonts in Fonts/ (load with gfxPrimitivesSetFont)
Rotozoomer SDL_rotozoom.h/.c Rotate, zoom, shrink and flip surfaces (with optional smoothing)
Framerate control SDL_framerate.h/.c Frame-rate limiter (FPSmanager)
Image filters SDL_imageFilter.h/.c Arithmetic and filter functions on byte buffers (add, mean, multiply, shift, binarize, convolution, ...)
Custom blitters SDL_gfxBlitFunc.h/.c RGBA-to-RGBA blitting that keeps the alpha channel (surface compositing)

Quick start

Build with CMake against an installed SDL 1.2 (see docs/BUILDING.md for the full Windows/Linux setup, presets and VS Code integration):

cmake -S . -B build -DCMAKE_PREFIX_PATH=/path/to/SDL-1.2
cmake --build build
ctest --test-dir build
cmake --install build --prefix /path/to/install

Use it from CMake (find_package(SDL_gfx), target SDL_gfx::SDL_gfx) or pkg-config (SDL_gfx.pc):

#include "SDL.h"
#include "SDL_gfxPrimitives.h"

/* ... after SDL_SetVideoMode(): */
filledCircleRGBA(screen, 160, 120, 50, 255, 128, 0, 255);
aalineRGBA(screen, 0, 0, 319, 239, 255, 255, 255, 255);
stringRGBA(screen, 10, 10, "Hello SDL_gfx", 255, 255, 255, 255);
SDL_Flip(screen);

Notes

Graphics primitives

All routines are alpha-aware and blend the primitive onto the target surface if alpha < 255. Surface depths of 1, 2, 3 and 4 bytes per pixel are supported. Surface locking is handled by each routine. All ...Color functions expect the color as 0xRRGGBBAA. Anti-aliased variants exist for lines, polygons, circles and ellipses. Drawing functions return 0 on success and -1 on error.

Rotozoomer

The rotozoomer creates a new target surface on each call (unlike SDL_BlitSurface), so it is typically used for pre-rendering, or for real-time effects on small surfaces. Smoothing (interpolation, SMOOTHING_ON) is applied to 32-bit surfaces only; 8-bit surfaces are never smoothed. Surfaces of other depths are converted to 32 bit on the fly.

Framerate manager

The framerate functions insert delays into the graphics loop to keep a constant frame rate. Instead of the usual SDL_Delay(1000/FPS), they track the desired time for a linearly interpolated sequence of future frames, avoiding accumulated rounding errors: the 100th frame at 50 Hz occurs 2.00 s after the first frame (if the machine keeps up).

Framerate diagram

Image filters

Functions operating on contiguous byte buffers (typically grayscale images), e.g. image addition and binarization. Most functions have a portable C implementation; the legacy MMX assembly path is only available in 32-bit x86 builds with USE_MMX. The convolution/Sobel functions currently exist only as MMX code: in other builds (e.g. x64) they do not compute anything — portable C versions are planned.

Custom blitters

The custom blitter functions provide (limited) support for surface compositing: surfaces can be blitted together and then blitted to the screen with transparency intact.

Demos and tests

  • demo/ contains interactive programs (TestGfxPrimitives, TestRotozoom, TestFonts, ...).
  • test/ contains the automated CTest suites.

Documentation

API documentation is in the public headers and source files (Doxygen comments); generate the HTML reference with cmake --build --preset win-release --target docs. Build instructions: docs/BUILDING.md. Release history: CHANGELOG.md. Code review findings and fixes: docs/CODE_REVIEW.md.

Language interfaces

SDL_gfx has been integrated with the following language interfaces:

Contributing

Bug reports and pull requests are welcome on GitHub. Release history: CHANGELOG.md.

Contributors

  • Fix for filledbox by Ingo van Lil, inguin at gmx.de - thanks Ingo.

  • Non-alpha line drawing code adapted from routine by Pete Shinners, pete at shinners.org - thanks Pete.

  • More fixes by Karl Bartel, karlb at gmx.net - thanks Karl.

  • Much testing and suggestions for fixes from Danny van Bruggen, danny at froukepc.dhs.org - thanks Danny.

  • Original AA-circle/-ellipse code idea from Stephane Magnenat, nct at wg0.ysagoon.com - thanks Stephane.

  • Faster blending routines contributed by Anders Lindstroem, cal at swipnet.se - thanks Anders.

  • New AA-circle/-ellipse code based on ideas from Anders Lindstroem - thanks Anders.

  • VisualC makefile contributed by Danny van Bruggen, danny at froukepc.dhs.org - thanks Danny.

  • VisualC7 project file contributed by James Turk, jturk at conceptofzero.com - thanks James.

  • Project Builder package contributed by Thomas Tongue, TTongue at imagiware.com - Thanks Thomas.

  • Fix for filledPolygon contributed by Kentaro Fukuchi fukuchi at is.titech.ac.jp - Thanks Kentaro.

  • QNX6 patch contributed by Mike Gorchak, mike at malva.ua - Thanks Mike.

  • Pie idea contributed by Eike Lange, eike.lange at uni-essen.de - Thanks Eike.

  • Dynamic font setup by Todor Prokopov, koprok at dir.bg - Thanks Todor.

  • Horizontal/Vertical flipping code by Victor (Haypo) Stinner, victor.stinner at haypocalc.com - Thanks Victor.

  • OSX build fixes by Michael Wybrow, mjwybrow at cs.mu.oz.au - Thanks Michael.

  • gcc3.4 build fixes by Dries Verachtert, dries at ulyssis.org - Thanks Dries.

  • Updated OSX build by Brian Rice, water451 at gmail.com - Thanks Brian.

  • aaellipse issues pointed out by Marco Wertz, marco.wertz at gmx.de - Thanks Marco.

  • texturedPolygon idea and code by Kees Jongenburger, kees.jongenburger at gmail.com - Thanks Kees.

  • Several bugfixes contributed by Sigborn Skjaeret, cisc at broadpark.no - Thanks CISC.

  • Syntax error for C++ found by Olivier Boudeville, olivier.boudeville at online.fr - Thanks Olivier.

  • hline/vline clipping fixes found by Daniel Roggen, droggen at gmail.com and Mikael Thieme, mikael.thieme at his.se - Thanks Daniel+Mikael.

  • rotozoom fix for big-endian machines (i.e. PPC) by Julian Mayer, julianmayer at mac.com - Thanks Julian.

  • Cross-compilation notes contributed by Sylvain Beucler, beuc at beuc.net - Thanks Sylvain.

  • Fix duplicate pixel renders in circleColor contributed by David Raber, lotharstar at gmail.com - Thanks David.

  • New arcColor (and arcRGBA) routine contributed by David Raber, lotharstar at gmail.com - Thanks David.

  • Idea for polygonColorMT and texturePolygonMT routines for multithreaded operation contributed by "unknown" - Thank you.

  • Multiple patches applied and repackaged version 2.0.18 by Paul, sweetlilmre at gmail.com - Thanks Paul and other contributors of patches.

  • Change to avoid gcc4 compiler warnings contributed by Thien-Thi nguyen, ttn at gnuvola.org - thanks Thi.

  • hline 1bpp off-by-one patch contributed by Manuel Lausch mail at manuellausch.de - Thanks Manuel.

  • pkg-config support contributed by Luca Bigliardi, shammash at artha.org - thanks Luca.

  • Updated mingw Makefile contributed by Jan Leike, jan dot leike at gmx dot net - thanks Jan.

  • Rotozoom debugging help by Jeff Wilges, heff at ifup dot us - thanks Jeff.

  • Build updates provided by Barry deFreese, bdefreese at debian dot org - thanks Barry.

  • Fix for 1-pixel postponement with 8bit scaling by Sylvain Beucler, beuc at beuc dot net - thanks Sylvain.

  • Updates to headers and configure to allow for cross-compiling to DLL (not just static .a) and fixes for compiling on Windows using autotools by Sylvain Beucler, beuc at beuc dot net - thanks Sylvain.

  • Added Visual CE Project to Builds. Contributed by vrichomme at smartmobili dot com - thanks.

  • Added Symbian and Windows 64bit fix with lrint function by Rene Dudfield, renesd at gmail dot com - thanks Rene.

  • Fixes for Rotate90 0-degree case by Chris Allport, chris dot allport at gmail dot com - thanks Chris.

  • Fixed for Win32 build support defines by tigerfishdaisy (SF) - thanks Tiger Tiger.

  • Patch for OpenSDK contributed by itsnotabigtruck at ovi dot com - thanks IsNotABigTruck.

  • OSX Xcode 3+ template ZIP contributed by marabus at meta dot ua - thanks Vasyl.

  • Memory leak/error check patch for zoomSurface contributed by RodolfoRG - thanks Rodolfo.

  • Zoom scaling factor rounding bugfix patch contributed by WanderWander Lairson Costa - thanks Wander.

  • Suggestions for speed improvements contributed by inkyankes - thanks.

  • Pixel blend routine patches contributed by mitja at lxnav dot com - thanks Mitja.

  • ImageFilter patches contributed by beuc at beuc dot net - thanks Sylvain.

  • Bug reports contributed by Yannick dot Guesnet at univ-rouen dot fr - thanks Yannick.

License

zlib license — see LICENSE.

Andreas Schiffler — aschiffler at ferzkopp dot net — https://www.ferzkopp.net

Jelajahi proyek terkait

Memuat…