1/*!
2
3
4\mainpage SDL_gfx - SDL-1.2 graphics drawing primitives, rotozoom and other supporting functions
5
6
7\section contact_sec Contact and License
8
9Email aschiffler at ferzkopp dot net to contact the author or better check
10author's homepage at http://www.ferzkopp.net for the most up-to-date
11contact information.
12
13This library is licenced under the zlib License, see the file LICENSE for details.
14
15
16\section intro_sec Introduction
17
18The SDL_gfx library evolved out of the SDL_gfxPrimitives code which
19provided basic drawing routines such as lines, circles or polygons for
20SDL Surfaces and adding a couple other useful functions for zooming
21images for example and doing basic image processing on byte arrays.
22
23Note that SDL_gfx is compatible with SDL version 1.2 (not SDL2).
24
25The current components of the SDL_gfx library are:
26- Graphic Primitives (SDL_gfxPrimitives.h, SDL_gfxPrimitives.c)
27- Rotozoomer (SDL_rotozoom.h, SDL_rotozoom.c)
28- Framerate control (SDL_framerate.h, SDL_framerate.c)
29- MMX image filters (SDL_imageFilter.h, SDL_imageFilter.c)
30- Custom Blit functions (SDL_gfxBlitFunc.h, SDL_gfxBlitFunc.c)
31- Build-in 8x8 Font (SDL_gfxPrimitives_font.h)
32
33
34
35\subsection notes_gfx Notes on Graphics Primitives
36
37Care has been taken so that all routines are fully alpha-aware and can
38blend any primitive onto the target surface if ALPHA<255. Surface depths
39supported are 1,2,3 and 4 bytes per pixel. Surface locking is implemented
40in each routine and the library should work well with hardware
41accelerated surfaces.
42
43\htmlonly
44<a href="../Screenshots/SDL_gfxPrimitives.jpg" target="_blank" title="SDL_gfxPrimitives Screenshot"><img src="../Screenshots/SDL_gfxPrimitives-thumb.jpg" border="0" hspace="5"></a><br />
45\endhtmlonly
46
47Currently, The following Anti-Aliased drawing primitives are available:
48- AA-line
49- AA-polygon
50- AA-circle
51- AA-ellipse
52
53Note: All ___Color routines expect the color to be in the format 0xRRGGBBAA.
54
55\subsection notes_roto Notes on Rotozoomer
56
57The rotozoom code is not ASM-speed quality, but it should be fast enough
58even for some realtime effects if the CPU is good or bitmaps small.
59With interpolation the routines are typically used for pre-rendering stuff
60in higher quality (i.e. smoothing) - that's also the reason why the API differs
61from SDL_BlitRect() - as they create a new target surface each time rotozoom
62is called. The final rendering speed is dependent on the target surface
63size as it is beeing xy-scanned when rendering the new surface.
64
65\htmlonly
66<a href="../Screenshots/SDL_rotozoom.jpg" target="_blank" title="SDL_rotozoom Screenshot"><img src="../Screenshots/SDL_rotozoom-thumb.jpg" border="0" hspace="5"></a><br />
67\endhtmlonly
68
69Note also that the smoothing toggle is dependent on the input surface bit
70depth. 8bit surfaces will \b never be smoothed - only 32bit surfaces will.
71
72Note that surfaces of other bit depth then 8 and 32 will be converted
73on the fly to a 32bit surface using a blit into a temporary surface. This
74impacts performance somewhat.
75
76Smoothing (interpolation) flags work only on 32bit surfaces:
77\verbatim
78 #define SMOOTHING_OFF		0
79 #define SMOOTHING_ON		1
80\endverbatim
81
82\subsection notes_rate Notes on Framerate Manager
83
84The framerate functions are used to insert delays into the graphics loop
85to maintain a constant framerate.
86
87The implementation is more sophisticated that the usual
88\verbatim
89	SDL_Delay(1000/FPS);
90\endverbatim
91call since these functions keep track of the desired game time per frame
92for a linearly interpolated sequence of future timing points of each frame.
93This is done to avoid rounding errors from the inherent instability in the
94delay generation and application.
95
96\htmlonly
97<a href="../framerate.png" target="_blank" title="Framerate Diagram"><img src="../framerate-thumb.png" border="0"></a><br />
98\endhtmlonly
99
100i.e. the 100th frame of a game running at 50Hz will be accurately
1012.00sec after the 1st frame (if the machine can keep up with the drawing).
102
103The functions return 0 or 'value' for sucess and -1 for error. All functions
104use a pointer to a framerate-manager variable to operate.
105
106
107\subsection notes_filter Notes on ImageFilters
108
109The imagefilter functions are a collection of MMX optimized routines that
110operate on continuous buffers of bytes - typically greyscale images from
111framegrabbers and such - performing functions such as image addition and
112binarization. All functions (almost ... not the the convolution routines)
113have a C implementation that is automatically used on systems without MMX
114capabilities.
115
116The compiler flag -DUSE_MMX toggles the conditional compile of MMX assembly.
117An assembler must be installed (i.e. "nasm").
118
119
120\subsection notes_blitters Notes on Custom Blitters
121
122The custom blitter functions provide (limited) support for surface
123compositing - that is surfaces can be blitted together, and then
124still blitted to the screen with transparency intact.
125
126\subsection platforms Supported Platforms
127
128\subsubsection platformlinux Unix/Linux
129
130The library compiles and is tested for a Linux target (gcc compiler) via the
131the usual configure;make;make install sequence.
132
133\subsubsection platformwindows Windows
134
135A Win32 target is available (VisualC6/7/8/9, mingw32, xmingw32 cross-compiler).
136The SDL_gfx_VS2010.sln will open VS2010 (the old VS2008 .sln is also still included)
137including express versions.
138
139See "Other Builds" for additional makefiles (may be out of date).
140
141When using the cross-compiler (available on the author's homepage, very
142out of date), the build process generates .DLLs. You can use the command
143line 'LIB.EXE' tool to generate VC6 compatible .LIB files for linking
144purposes.
145
146\subsubsection platformosx Mac OSX
147
148The usual autotools build chain should be used. MacPorts or fink may
149be required (that's what the author uses).
150
151Xcode is supported via templates. See "Other Builds" folder Xcode3+.zip -
152this template only supports SDL_gfx and not the tests. For this template, the
153Deployment Target (the lowest version to run on) is set to 10.5 and expects
154the SDL.framework preinstalled in some default location
155(either /Library/Frameworks, or ~/Library/Frameworks).
156
157Older targets are also reported to work (10.3+ native and Project Builder).
158
159\subsubsection platformqnx QNX
160
161QNX was reported to build (see .diff in "Other Builds").
162
163\subsubsection platformzune Zune
164
165ZuneHD (WinCE 6 ARM) is reported to build (see OpenZDK in "Other Builds").
166Note that between rendering on the Zune's ARM CPU and constantly uploading
167textures to the GPU, SDL_gfx is going to be slow. Also, the libc math
168functions all use software FP emulation even when VFP floating point
169support is turned on in the compiler, so there's extra overhead due to that
170as well.
171
172\subsubsection platformothers Others
173
174Other platforms might work but have not been tested by the author.
175Please check the file "INSTALL" as well as the folder "Other Builds".
176
177See also section "Installation" below for more build instructions.
178
179\section install_sec Installation
180
181\subsection unix Unix/Linux
182
183To compile the library your need the SDL 1.2 installed from source or
184installed with the 'devel' RPM package. For example on Mandriva, run:
185\verbatim
186	urpmi  libSDL1.2-devel
187\endverbatim
188
189Then run
190\verbatim
191	./autogen.sh	# (optional, recommended)
192	./configure
193	make
194	make install
195	ldconfig
196\endverbatim
197
198to compile and install the library. The default location for the
199installation is /usr/local/lib and /usr/local/include. The libary
200path might need to be added to the file:
201	/etc/ld.so.conf
202
203Run the shell script 'nodebug.sh' before make, to patch the makefile
204for optimized compilation:
205\verbatim
206	./autogen.sh	# (optional, recommended)
207	./configure
208	./nodebug.sh
209	make
210	make install
211	ldconfig
212\endverbatim
213
214Check the folder "Other Builds" for alternative makefiles.
215
216\subsection prep Build Prep
217
218Run autogen.sh or manually:
219\verbatim
220	aclocal --force
221	libtoolize --force --copy
222	autoreconf -fvi
223\endverbatim
224
225\subsection nommx No-MMX
226
227To build without MMX code enabled (i.e. PPC or for AMD64 architecture
228which is missing pusha/popa):
229\verbatim
230	./configure --disable-mmx
231	make
232	make install
233\endverbatim
234i.e. to build on MacOSX 10.3+ use:
235\verbatim
236	./configure --disable-mmx && make
237\endverbatim
238
239\subsection vs9 Windows (VC9, VS2010)
240
241Open SDL_gfx_VS2010.sln solution file and review README.
242
243\subsection vs8 Windows (VC8, VS2008)
244
245Open SDL_gfx_VS2008.sln solution file and review README.
246
247
248\subsection vc6 Windows (VC6/7)
249
250See folder Other Builds.
251
252To create a Windows DLL using VisualC6:
253\verbatim
254	unzip -a VisualC6.zip
255	vcvars32.bat
256	copy VisualC/makefile
257	nmake
258\endverbatim
259or
260\verbatim
261	unzip -a VisualC7.zip
262\endverbatim
263and open the project file.
264
265
266\subsection wince WindowsCE
267
268See folder Other Builds.
269
270May need workaround for missing lrint.
271
272
273\subsection cross Cross-Compilation
274
275To build using mingw32 on Win32, check the makefile contained in mingw.zip
276
277To create a Windows DLL using the xmingw32 cross-compiler:
278\verbatim
279	cross-configure
280	cross-make
281	cross-make install
282\endverbatim
283
284Make sure the -DBUILD_DLL is used (and only then) when creating the DLLs.
285Make sure -DWIN32 is used when compiling the sources (creating or using
286the DLLs.
287
288Specify the path to your cross-compiled 'sdl-config', and invoke
289'./configure' with the '--host' and '--build' arguments. For example,
290to cross-compile a .DLL from GNU/Linux:
291\verbatim
292	SDL_CONFIG=/usr/local/cross-tools/i386-mingw32msvc/bin/sdl-config \
293		./configure --host=i586-mingw32msvc --build=i686-pc-linux-gnu
294	make
295	make install
296\endverbatim
297
298\subsection qnx QNX
299
300To build on QNX6, patch first using:
301\verbatim
302	patch -p0 <QNX.diff
303\endverbatim
304
305\subsection osx OSX
306
307Use standard unix build sequence.
308
309To build on MacOS X with Project Builder, follow these steps:
310- Update your developer tools to the lastest version.
311- Install the SDL Developers framework for Mac OS X.
312- Download the latest SDL_gfx source distribution and extract the
313	archive in a convenient location.
314- Extract the included OSX-PB.tgz archive into the
315	top directory of the SDL_gfx distribution (from step 3). This will create a
316	PB that contains the project files.
317- The project has targets for the SDL_gfx framework and the four test
318	programs. All can be built using the 'deployment' or 'development' build
319	styles.
320
321A newer version for MaxOS X is included in the OSX-PB-XCode.zip archive. The
322updated version uses relative pathnames where appropriate, and pointers to
323the standard  installation location of SDL. However, it may require XCode in
324order to be used.
325
326\section interfaces_sec Language Interfaces
327
328SDL_gfx has been integrated with the following language interfaces:
329- Pascal: http://www.freepascal-meets-sdl.net
330- Perl: http://sdl.perl.org
331- Python: http://www.pygame.org
332- C#: http://cs-sdl.sourceforge.net
333- Lua: http://www.egsl.retrogamecoding.org/
334- Oberon: http://sourceforge.net/projects/sdl-for-oberon/
335
336\section test_sec Test Programs
337
338Change to the ./Test directory and run
339\verbatim
340	./autogen.sh
341	./configure
342	make
343\endverbatim
344to create several test programs for the libraries functions. This requires
345the library to be previously compiled and installed.
346
347
348See the source code .c files for some sample code and implementation hints.
349
350
351\section contrib_sec Contributors
352
353- Fix for filledbox by Ingo van Lil, inguin at gmx.de - thanks Ingo.
354
355- Non-alpha line drawing code adapted from routine
356  by Pete Shinners, pete at shinners.org - thanks Pete.
357
358- More fixes by Karl Bartel, karlb at gmx.net - thanks Karl.
359
360- Much testing and suggestions for fixes from Danny van Bruggen,
361  danny at froukepc.dhs.org - thanks Danny.
362
363- Original AA-circle/-ellipse code idea from Stephane Magnenat,
364  nct at wg0.ysagoon.com - thanks Stephane.
365
366- Faster blending routines contributed by Anders Lindstroem,
367  cal at swipnet.se - thanks Anders.
368
369- New AA-circle/-ellipse code based on ideas from Anders Lindstroem -
370  thanks Anders.
371
372- VisualC makefile contributed by Danny van Bruggen,
373  danny at froukepc.dhs.org - thanks Danny.
374
375- VisualC7 project file contributed by James Turk,
376  jturk at conceptofzero.com - thanks James.
377
378- Project Builder package contributed by Thomas Tongue,
379  TTongue at imagiware.com - Thanks Thomas.
380
381- Fix for filledPolygon contributed by Kentaro Fukuchi
382  fukuchi at is.titech.ac.jp - Thanks Kentaro.
383
384- QNX6 patch contributed by Mike Gorchak,
385  mike at malva.ua - Thanks Mike.
386
387- Pie idea contributed by Eike Lange,
388  eike.lange at uni-essen.de - Thanks Eike.
389
390- Dynamic font setup by Todor Prokopov,
391  koprok at dir.bg - Thanks Todor.
392
393- Horizontal/Vertical flipping code by Victor (Haypo)
394  Stinner, victor.stinner at haypocalc.com - Thanks Victor.
395
396- OSX build fixes by Michael Wybrow,
397  mjwybrow at cs.mu.oz.au - Thanks Michael.
398
399- gcc3.4 build fixes by Dries Verachtert,
400  dries at ulyssis.org - Thanks Dries.
401
402- Updated OSX build by Brian Rice,
403  water451 at gmail.com - Thanks Brian.
404
405- aaellipse issues pointed out by Marco Wertz,
406  marco.wertz at gmx.de - Thanks Marco.
407
408- texturedPolygon idea and code by Kees Jongenburger,
409  kees.jongenburger at gmail.com - Thanks Kees.
410
411- Several bugfixes contributed by Sigborn Skjaeret,
412  cisc at broadpark.no - Thanks CISC.
413
414- Syntax error for C++ found by Olivier Boudeville,
415  olivier.boudeville at online.fr - Thanks Olivier.
416
417- hline/vline clipping fixes found by Daniel Roggen,
418  droggen at gmail.com and Mikael Thieme,
419  mikael.thieme at his.se - Thanks Daniel+Mikael.
420
421- rotozoom fix for big-endian machines (i.e. PPC)
422  by Julian Mayer, julianmayer at mac.com - Thanks
423  Julian.
424
425- Cross-compilation notes contributed by Sylvain
426  Beucler, beuc at beuc.net - Thanks Sylvain.
427
428- Fix duplicate pixel renders in circleColor contributed
429  by David Raber, lotharstar at gmail.com - Thanks David.
430
431- New arcColor (and arcRGBA) routine contributed
432  by David Raber, lotharstar at gmail.com - Thanks David.
433
434- Idea for polygonColorMT and texturePolygonMT routines for
435  multithreaded operation contributed by "unknown" -
436  Thank you.
437
438- Multiple patches applied and repackaged version 2.0.18
439  by Paul, sweetlilmre at gmail.com - Thanks Paul and
440  other contributors of patches.
441
442- Change to avoid gcc4 compiler warnings contributed by Thien-Thi
443  nguyen, ttn at gnuvola.org - thanks Thi.
444
445- hline 1bpp off-by-one patch contributed by Manuel Lausch
446  mail at manuellausch.de - Thanks Manuel.
447
448- pkg-config support contributed by Luca Bigliardi, shammash
449  at artha.org - thanks Luca.
450
451- Updated mingw Makefile contributed by Jan Leike, jan dot leike
452  at gmx dot net - thanks Jan.
453
454- Rotozoom debugging help by Jeff Wilges, heff at ifup dot us -
455  thanks Jeff.
456
457- Build updates provided by Barry deFreese, bdefreese at debian
458  dot org - thanks Barry.
459
460- Fix for 1-pixel postponement with 8bit scaling by Sylvain Beucler,
461  beuc at beuc dot net - thanks Sylvain.
462
463- Updates to headers and configure to allow for cross-compiling
464  to DLL (not just static .a) and fixes for compiling on Windows
465  using autotools by Sylvain Beucler, beuc at beuc dot net - thanks Sylvain.
466
467- Added Visual CE Project to Builds. Contributed by vrichomme at smartmobili
468  dot com - thanks.
469
470- Added Symbian and Windows 64bit fix with lrint function by Rene
471  Dudfield, renesd at gmail dot com - thanks Rene.
472
473- Fixes for Rotate90 0-degree case by Chris Allport, chris dot allport
474  at gmail dot com - thanks Chris.
475
476- Fixed for Win32 build support defines by tigerfishdaisy (SF) - thanks
477  Tiger Tiger.
478
479- Patch for OpenSDK contributed by itsnotabigtruck at ovi dot com - thanks
480  IsNotABigTruck.
481
482- OSX Xcode 3+ template ZIP contributed by marabus at meta dot ua - thanks
483  Vasyl.
484
485- Memory leak/error check patch for zoomSurface contributed by
486  RodolfoRG - thanks Rodolfo.
487
488- Zoom scaling factor rounding bugfix patch contributed by WanderWander
489  Lairson Costa - thanks Wander.
490
491- Suggestions for speed improvements contributed by inkyankes - thanks.
492
493- Pixel blend routine patches contributed by mitja at lxnav dot com -
494  thanks Mitja.
495
496- ImageFilter patches contributed by beuc at beuc dot net - thanks Sylvain.
497
498- Bug reports contributed by Yannick dot Guesnet at univ-rouen dot fr -
499- thanks Yannick.
500
501\section changelog_sec Change Log
502
503\verbinclude ChangeLog
504
505*/