/*!
\mainpage SDL_gfx - SDL-1.2 graphics drawing primitives, rotozoom and other supporting functions
\section contact_sec Contact and License
Email aschiffler at ferzkopp dot net to contact the author or better check
author's homepage at http://www.ferzkopp.net for the most up-to-date
contact information.
This library is licenced under the zlib License, see the file LICENSE for details.
\section intro_sec Introduction
The SDL_gfx library evolved out of the SDL_gfxPrimitives code which
provided basic drawing routines such as lines, circles or polygons for
SDL Surfaces and adding a couple other useful functions for zooming
images for example and doing basic image processing on byte arrays.
Note that SDL_gfx is compatible with SDL version 1.2 (not SDL2).
The current components of the SDL_gfx library are:
- Graphic Primitives (SDL_gfxPrimitives.h, SDL_gfxPrimitives.c)
- Rotozoomer (SDL_rotozoom.h, SDL_rotozoom.c)
- Framerate control (SDL_framerate.h, SDL_framerate.c)
- MMX image filters (SDL_imageFilter.h, SDL_imageFilter.c)
- Custom Blit functions (SDL_gfxBlitFunc.h, SDL_gfxBlitFunc.c)
- Build-in 8x8 Font (SDL_gfxPrimitives_font.h)
\subsection notes_gfx 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.
\htmlonly
\endhtmlonly
Currently, The following Anti-Aliased drawing primitives are available:
- AA-line
- AA-polygon
- AA-circle
- AA-ellipse
Note: All ___Color routines expect the color to be in the format 0xRRGGBBAA.
\subsection notes_roto Notes on Rotozoomer
The rotozoom code is not ASM-speed quality, but it should be fast enough
even for some realtime effects if the CPU is good or bitmaps small.
With interpolation the routines are typically used for pre-rendering stuff
in higher quality (i.e. smoothing) - that's also the reason why the API differs
from SDL_BlitRect() - as they create a new target surface each time rotozoom
is called. The final rendering speed is dependent on the target surface
size as it is beeing xy-scanned when rendering the new surface.
\htmlonly
\endhtmlonly
Note also that the smoothing toggle is dependent on the input surface bit
depth. 8bit surfaces will \b never be smoothed - only 32bit surfaces will.
Note that surfaces of other bit depth then 8 and 32 will be converted
on the fly to a 32bit surface using a blit into a temporary surface. This
impacts performance somewhat.
Smoothing (interpolation) flags work only on 32bit surfaces:
\verbatim
#define SMOOTHING_OFF 0
#define SMOOTHING_ON 1
\endverbatim
\subsection notes_rate Notes on Framerate Manager
The framerate functions are used to insert delays into the graphics loop
to maintain a constant framerate.
The implementation is more sophisticated that the usual
\verbatim
SDL_Delay(1000/FPS);
\endverbatim
call since these functions keep track of the desired game time per frame
for a linearly interpolated sequence of future timing points of each frame.
This is done to avoid rounding errors from the inherent instability in the
delay generation and application.
\htmlonly
\endhtmlonly
i.e. the 100th frame of a game running at 50Hz will be accurately
2.00sec after the 1st frame (if the machine can keep up with the drawing).
The functions return 0 or 'value' for sucess and -1 for error. All functions
use a pointer to a framerate-manager variable to operate.
\subsection notes_filter Notes on ImageFilters
The imagefilter functions are a collection of MMX optimized routines that
operate on continuous buffers of bytes - typically greyscale images from
framegrabbers and such - performing functions such as image addition and
binarization. All functions (almost ... not the the convolution routines)
have a C implementation that is automatically used on systems without MMX
capabilities.
The compiler flag -DUSE_MMX toggles the conditional compile of MMX assembly.
An assembler must be installed (i.e. "nasm").
\subsection notes_blitters Notes on Custom Blitters
The custom blitter functions provide (limited) support for surface
compositing - that is surfaces can be blitted together, and then
still blitted to the screen with transparency intact.
\subsection platforms Supported Platforms
\subsubsection platformlinux Unix/Linux
The library compiles and is tested for a Linux target (gcc compiler) via the
the usual configure;make;make install sequence.
\subsubsection platformwindows Windows
A Win32 target is available (VisualC6/7/8/9, mingw32, xmingw32 cross-compiler).
The SDL_gfx_VS2010.sln will open VS2010 (the old VS2008 .sln is also still included)
including express versions.
See "Other Builds" for additional makefiles (may be out of date).
When using the cross-compiler (available on the author's homepage, very
out of date), the build process generates .DLLs. You can use the command
line 'LIB.EXE' tool to generate VC6 compatible .LIB files for linking
purposes.
\subsubsection platformosx Mac OSX
The usual autotools build chain should be used. MacPorts or fink may
be required (that's what the author uses).
Xcode is supported via templates. See "Other Builds" folder Xcode3+.zip -
this template only supports SDL_gfx and not the tests. For this template, the
Deployment Target (the lowest version to run on) is set to 10.5 and expects
the SDL.framework preinstalled in some default location
(either /Library/Frameworks, or ~/Library/Frameworks).
Older targets are also reported to work (10.3+ native and Project Builder).
\subsubsection platformqnx QNX
QNX was reported to build (see .diff in "Other Builds").
\subsubsection platformzune Zune
ZuneHD (WinCE 6 ARM) is reported to build (see OpenZDK in "Other Builds").
Note that between rendering on the Zune's ARM CPU and constantly uploading
textures to the GPU, SDL_gfx is going to be slow. Also, the libc math
functions all use software FP emulation even when VFP floating point
support is turned on in the compiler, so there's extra overhead due to that
as well.
\subsubsection platformothers Others
Other platforms might work but have not been tested by the author.
Please check the file "INSTALL" as well as the folder "Other Builds".
See also section "Installation" below for more build instructions.
\section install_sec Installation
\subsection unix Unix/Linux
To compile the library your need the SDL 1.2 installed from source or
installed with the 'devel' RPM package. For example on Mandriva, run:
\verbatim
urpmi libSDL1.2-devel
\endverbatim
Then run
\verbatim
./autogen.sh # (optional, recommended)
./configure
make
make install
ldconfig
\endverbatim
to compile and install the library. The default location for the
installation is /usr/local/lib and /usr/local/include. The libary
path might need to be added to the file:
/etc/ld.so.conf
Run the shell script 'nodebug.sh' before make, to patch the makefile
for optimized compilation:
\verbatim
./autogen.sh # (optional, recommended)
./configure
./nodebug.sh
make
make install
ldconfig
\endverbatim
Check the folder "Other Builds" for alternative makefiles.
\subsection prep Build Prep
Run autogen.sh or manually:
\verbatim
aclocal --force
libtoolize --force --copy
autoreconf -fvi
\endverbatim
\subsection nommx No-MMX
To build without MMX code enabled (i.e. PPC or for AMD64 architecture
which is missing pusha/popa):
\verbatim
./configure --disable-mmx
make
make install
\endverbatim
i.e. to build on MacOSX 10.3+ use:
\verbatim
./configure --disable-mmx && make
\endverbatim
\subsection vs9 Windows (VC9, VS2010)
Open SDL_gfx_VS2010.sln solution file and review README.
\subsection vs8 Windows (VC8, VS2008)
Open SDL_gfx_VS2008.sln solution file and review README.
\subsection vc6 Windows (VC6/7)
See folder Other Builds.
To create a Windows DLL using VisualC6:
\verbatim
unzip -a VisualC6.zip
vcvars32.bat
copy VisualC/makefile
nmake
\endverbatim
or
\verbatim
unzip -a VisualC7.zip
\endverbatim
and open the project file.
\subsection wince WindowsCE
See folder Other Builds.
May need workaround for missing lrint.
\subsection cross Cross-Compilation
To build using mingw32 on Win32, check the makefile contained in mingw.zip
To create a Windows DLL using the xmingw32 cross-compiler:
\verbatim
cross-configure
cross-make
cross-make install
\endverbatim
Make sure the -DBUILD_DLL is used (and only then) when creating the DLLs.
Make sure -DWIN32 is used when compiling the sources (creating or using
the DLLs.
Specify the path to your cross-compiled 'sdl-config', and invoke
'./configure' with the '--host' and '--build' arguments. For example,
to cross-compile a .DLL from GNU/Linux:
\verbatim
SDL_CONFIG=/usr/local/cross-tools/i386-mingw32msvc/bin/sdl-config \
./configure --host=i586-mingw32msvc --build=i686-pc-linux-gnu
make
make install
\endverbatim
\subsection qnx QNX
To build on QNX6, patch first using:
\verbatim
patch -p0