Commit 6d91ce03 authored by pixhawk's avatar pixhawk

Fixed QMapControl, added SDL

parent 1e004938
......@@ -98,8 +98,8 @@ namespace qmapcontrol
z= min_zoom - z;
}
if (x<0 || x>pow(2,z)-1 ||
y<0 || y>pow(2,z)-1)
if (x<0 || x>pow(2.0,z)-1 ||
y<0 || y>pow(2.0,z)-1)
{
return false;
}
......@@ -108,7 +108,7 @@ namespace qmapcontrol
}
int EmptyMapAdapter::tilesonzoomlevel(int zoomlevel) const
{
return int(pow(2, zoomlevel));
return int(pow(2.0, zoomlevel));
}
int EmptyMapAdapter::xoffset(int x) const
{
......
......@@ -157,7 +157,7 @@ namespace qmapcontrol
{
if (currentZoom() >= 0 && distanceList.size() > currentZoom())
{
line = distanceList.at( currentZoom() ) / pow(2, 18-currentZoom() ) / 0.597164;
line = distanceList.at( currentZoom() ) / pow(2.0, 18-currentZoom() ) / 0.597164;
// draw the scale
painter.setPen(Qt::black);
......@@ -210,7 +210,7 @@ namespace qmapcontrol
// Draw the Lat and Lon if needed
if (cursorPosVisible) {
line = distanceList.at( currentZoom() ) / pow(2, 18-currentZoom() ) / 0.597164;
line = distanceList.at( currentZoom() ) / pow(2.0, 18-currentZoom() ) / 0.597164;
QString str;
str = QString(tr(" Lat: %1")).arg(currentWorldCoordinate.y());
......
......@@ -144,8 +144,8 @@ namespace qmapcontrol
int diffzoom = homelevel-currentzoom;
int viewheight = size.height();
int viewwidth = size.width();
viewheight = int(viewheight / pow(2, diffzoom));
viewwidth = int(viewwidth / pow(2, diffzoom));
viewheight = int(viewheight / pow(2.0, diffzoom));
viewwidth = int(viewwidth / pow(2.0, diffzoom));
if (minsize.height()!= -1 && viewheight < minsize.height())
viewheight = minsize.height();
......
......@@ -162,8 +162,8 @@ namespace qmapcontrol
z= min_zoom - z;
}
if (x<0 || x>pow(2,z)-1 ||
y<0 || y>pow(2,z)-1)
if (x<0 || x>pow(2.0,z)-1 ||
y<0 || y>pow(2.0,z)-1)
{
return false;
}
......@@ -172,7 +172,7 @@ namespace qmapcontrol
}
int TileMapAdapter::tilesonzoomlevel(int zoomlevel) const
{
return int(pow(2, zoomlevel));
return int(pow(2.0, zoomlevel));
}
int TileMapAdapter::xoffset(int x) const
{
......
......@@ -47,7 +47,7 @@ namespace qmapcontrol
this->serverPath.append("&WIDTH=").append(loc.toString(tilesize))
.append("&HEIGHT=").append(loc.toString(tilesize))
.append("&BBOX=");
numberOfTiles = pow(2, current_zoom);
numberOfTiles = pow(2.0, current_zoom);
coord_per_x_tile = 360. / numberOfTiles;
coord_per_y_tile = 180. / numberOfTiles;
}
......@@ -72,14 +72,14 @@ namespace qmapcontrol
void WMSMapAdapter::zoom_in()
{
current_zoom+=1;
numberOfTiles = pow(2, current_zoom);
numberOfTiles = pow(2.0, current_zoom);
coord_per_x_tile = 360. / numberOfTiles;
coord_per_y_tile = 180. / numberOfTiles;
}
void WMSMapAdapter::zoom_out()
{
current_zoom-=1;
numberOfTiles = pow(2, current_zoom);
numberOfTiles = pow(2.0, current_zoom);
coord_per_x_tile = 360. / numberOfTiles;
coord_per_y_tile = 180. / numberOfTiles;
}
......
......@@ -30,13 +30,13 @@ namespace qmapcontrol
: TileMapAdapter("png.maps.yimg.com", "/png?v=3.1.0&x=%2&y=%3&z=%1", 256, 17,0)
{
int zoom = max_zoom < min_zoom ? min_zoom - current_zoom : current_zoom;
numberOfTiles = pow(2, zoom+1);
numberOfTiles = pow(2.0, zoom+1);
}
YahooMapAdapter::YahooMapAdapter(QString host, QString url)
: TileMapAdapter(host, url, 256, 17,0)
{
int zoom = max_zoom < min_zoom ? min_zoom - current_zoom : current_zoom;
numberOfTiles = pow(2, zoom+1);
numberOfTiles = pow(2.0, zoom+1);
}
YahooMapAdapter::~YahooMapAdapter()
{
......@@ -49,14 +49,14 @@ namespace qmapcontrol
int YahooMapAdapter::tilesonzoomlevel(int zoomlevel) const
{
return int(pow(2, zoomlevel+1));
return int(pow(2.0, zoomlevel+1));
}
int YahooMapAdapter::yoffset(int y) const
{
int zoom = max_zoom < min_zoom ? min_zoom - current_zoom : current_zoom;
int tiles = int(pow(2, zoom));
int tiles = int(pow(2.0, zoom));
y = y*(-1)+tiles-1;
return int(y);
}
......
// ISO C9x compliant inttypes.h for Microsoft Visual Studio
// Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124
//
// Copyright (c) 2006 Alexander Chemeris
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. The name of the author may be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
// EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
///////////////////////////////////////////////////////////////////////////////
#ifndef _MSC_VER // [
#error "Use this header only with Microsoft Visual C++ compilers!"
#endif // _MSC_VER ]
#ifndef _MSC_INTTYPES_H_ // [
#define _MSC_INTTYPES_H_
#if _MSC_VER > 1000
#pragma once
#endif
#include "stdint.h"
// 7.8 Format conversion of integer types
typedef struct {
intmax_t quot;
intmax_t rem;
} imaxdiv_t;
// 7.8.1 Macros for format specifiers
#if !defined(__cplusplus) || defined(__STDC_FORMAT_MACROS) // [ See footnote 185 at page 198
// The fprintf macros for signed integers are:
#define PRId8 "d"
#define PRIi8 "i"
#define PRIdLEAST8 "d"
#define PRIiLEAST8 "i"
#define PRIdFAST8 "d"
#define PRIiFAST8 "i"
#define PRId16 "hd"
#define PRIi16 "hi"
#define PRIdLEAST16 "hd"
#define PRIiLEAST16 "hi"
#define PRIdFAST16 "hd"
#define PRIiFAST16 "hi"
#define PRId32 "I32d"
#define PRIi32 "I32i"
#define PRIdLEAST32 "I32d"
#define PRIiLEAST32 "I32i"
#define PRIdFAST32 "I32d"
#define PRIiFAST32 "I32i"
#define PRId64 "I64d"
#define PRIi64 "I64i"
#define PRIdLEAST64 "I64d"
#define PRIiLEAST64 "I64i"
#define PRIdFAST64 "I64d"
#define PRIiFAST64 "I64i"
#define PRIdMAX "I64d"
#define PRIiMAX "I64i"
#define PRIdPTR "Id"
#define PRIiPTR "Ii"
// The fprintf macros for unsigned integers are:
#define PRIo8 "o"
#define PRIu8 "u"
#define PRIx8 "x"
#define PRIX8 "X"
#define PRIoLEAST8 "o"
#define PRIuLEAST8 "u"
#define PRIxLEAST8 "x"
#define PRIXLEAST8 "X"
#define PRIoFAST8 "o"
#define PRIuFAST8 "u"
#define PRIxFAST8 "x"
#define PRIXFAST8 "X"
#define PRIo16 "ho"
#define PRIu16 "hu"
#define PRIx16 "hx"
#define PRIX16 "hX"
#define PRIoLEAST16 "ho"
#define PRIuLEAST16 "hu"
#define PRIxLEAST16 "hx"
#define PRIXLEAST16 "hX"
#define PRIoFAST16 "ho"
#define PRIuFAST16 "hu"
#define PRIxFAST16 "hx"
#define PRIXFAST16 "hX"
#define PRIo32 "I32o"
#define PRIu32 "I32u"
#define PRIx32 "I32x"
#define PRIX32 "I32X"
#define PRIoLEAST32 "I32o"
#define PRIuLEAST32 "I32u"
#define PRIxLEAST32 "I32x"
#define PRIXLEAST32 "I32X"
#define PRIoFAST32 "I32o"
#define PRIuFAST32 "I32u"
#define PRIxFAST32 "I32x"
#define PRIXFAST32 "I32X"
#define PRIo64 "I64o"
#define PRIu64 "I64u"
#define PRIx64 "I64x"
#define PRIX64 "I64X"
#define PRIoLEAST64 "I64o"
#define PRIuLEAST64 "I64u"
#define PRIxLEAST64 "I64x"
#define PRIXLEAST64 "I64X"
#define PRIoFAST64 "I64o"
#define PRIuFAST64 "I64u"
#define PRIxFAST64 "I64x"
#define PRIXFAST64 "I64X"
#define PRIoMAX "I64o"
#define PRIuMAX "I64u"
#define PRIxMAX "I64x"
#define PRIXMAX "I64X"
#define PRIoPTR "Io"
#define PRIuPTR "Iu"
#define PRIxPTR "Ix"
#define PRIXPTR "IX"
// The fscanf macros for signed integers are:
#define SCNd8 "d"
#define SCNi8 "i"
#define SCNdLEAST8 "d"
#define SCNiLEAST8 "i"
#define SCNdFAST8 "d"
#define SCNiFAST8 "i"
#define SCNd16 "hd"
#define SCNi16 "hi"
#define SCNdLEAST16 "hd"
#define SCNiLEAST16 "hi"
#define SCNdFAST16 "hd"
#define SCNiFAST16 "hi"
#define SCNd32 "ld"
#define SCNi32 "li"
#define SCNdLEAST32 "ld"
#define SCNiLEAST32 "li"
#define SCNdFAST32 "ld"
#define SCNiFAST32 "li"
#define SCNd64 "I64d"
#define SCNi64 "I64i"
#define SCNdLEAST64 "I64d"
#define SCNiLEAST64 "I64i"
#define SCNdFAST64 "I64d"
#define SCNiFAST64 "I64i"
#define SCNdMAX "I64d"
#define SCNiMAX "I64i"
#ifdef _WIN64 // [
# define SCNdPTR "I64d"
# define SCNiPTR "I64i"
#else // _WIN64 ][
# define SCNdPTR "ld"
# define SCNiPTR "li"
#endif // _WIN64 ]
// The fscanf macros for unsigned integers are:
#define SCNo8 "o"
#define SCNu8 "u"
#define SCNx8 "x"
#define SCNX8 "X"
#define SCNoLEAST8 "o"
#define SCNuLEAST8 "u"
#define SCNxLEAST8 "x"
#define SCNXLEAST8 "X"
#define SCNoFAST8 "o"
#define SCNuFAST8 "u"
#define SCNxFAST8 "x"
#define SCNXFAST8 "X"
#define SCNo16 "ho"
#define SCNu16 "hu"
#define SCNx16 "hx"
#define SCNX16 "hX"
#define SCNoLEAST16 "ho"
#define SCNuLEAST16 "hu"
#define SCNxLEAST16 "hx"
#define SCNXLEAST16 "hX"
#define SCNoFAST16 "ho"
#define SCNuFAST16 "hu"
#define SCNxFAST16 "hx"
#define SCNXFAST16 "hX"
#define SCNo32 "lo"
#define SCNu32 "lu"
#define SCNx32 "lx"
#define SCNX32 "lX"
#define SCNoLEAST32 "lo"
#define SCNuLEAST32 "lu"
#define SCNxLEAST32 "lx"
#define SCNXLEAST32 "lX"
#define SCNoFAST32 "lo"
#define SCNuFAST32 "lu"
#define SCNxFAST32 "lx"
#define SCNXFAST32 "lX"
#define SCNo64 "I64o"
#define SCNu64 "I64u"
#define SCNx64 "I64x"
#define SCNX64 "I64X"
#define SCNoLEAST64 "I64o"
#define SCNuLEAST64 "I64u"
#define SCNxLEAST64 "I64x"
#define SCNXLEAST64 "I64X"
#define SCNoFAST64 "I64o"
#define SCNuFAST64 "I64u"
#define SCNxFAST64 "I64x"
#define SCNXFAST64 "I64X"
#define SCNoMAX "I64o"
#define SCNuMAX "I64u"
#define SCNxMAX "I64x"
#define SCNXMAX "I64X"
#ifdef _WIN64 // [
# define SCNoPTR "I64o"
# define SCNuPTR "I64u"
# define SCNxPTR "I64x"
# define SCNXPTR "I64X"
#else // _WIN64 ][
# define SCNoPTR "lo"
# define SCNuPTR "lu"
# define SCNxPTR "lx"
# define SCNXPTR "lX"
#endif // _WIN64 ]
#endif // __STDC_FORMAT_MACROS ]
// 7.8.2 Functions for greatest-width integer types
// 7.8.2.1 The imaxabs function
#define imaxabs _abs64
// 7.8.2.2 The imaxdiv function
// This is modified version of div() function from Microsoft's div.c found
// in %MSVC.NET%\crt\src\div.c
#ifdef STATIC_IMAXDIV // [
static
#else // STATIC_IMAXDIV ][
_inline
#endif // STATIC_IMAXDIV ]
imaxdiv_t __cdecl imaxdiv(intmax_t numer, intmax_t denom)
{
imaxdiv_t result;
result.quot = numer / denom;
result.rem = numer % denom;
if (numer < 0 && result.rem > 0) {
// did division wrong; must fix up
++result.quot;
result.rem -= denom;
}
return result;
}
// 7.8.2.3 The strtoimax and strtoumax functions
#define strtoimax _strtoi64
#define strtoumax _strtoui64
// 7.8.2.4 The wcstoimax and wcstoumax functions
#define wcstoimax _wcstoi64
#define wcstoumax _wcstoui64
#endif // _MSC_INTTYPES_H_ ]
// ISO C9x compliant stdint.h for Microsoft Visual Studio
// Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124
//
// Copyright (c) 2006-2008 Alexander Chemeris
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. The name of the author may be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
// EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
///////////////////////////////////////////////////////////////////////////////
#ifndef _MSC_VER // [
#error "Use this header only with Microsoft Visual C++ compilers!"
#endif // _MSC_VER ]
#ifndef _MSC_STDINT_H_ // [
#define _MSC_STDINT_H_
#if _MSC_VER > 1000
#pragma once
#endif
#include <limits.h>
// For Visual Studio 6 in C++ mode and for many Visual Studio versions when
// compiling for ARM we should wrap <wchar.h> include with 'extern "C++" {}'
// or compiler give many errors like this:
// error C2733: second C linkage of overloaded function 'wmemchr' not allowed
#ifdef __cplusplus
extern "C" {
#endif
# include <wchar.h>
#ifdef __cplusplus
}
#endif
// Define _W64 macros to mark types changing their size, like intptr_t.
#ifndef _W64
# if !defined(__midl) && (defined(_X86_) || defined(_M_IX86)) && _MSC_VER >= 1300
# define _W64 __w64
# else
# define _W64
# endif
#endif
// 7.18.1 Integer types
// 7.18.1.1 Exact-width integer types
// Visual Studio 6 and Embedded Visual C++ 4 doesn't
// realize that, e.g. char has the same size as __int8
// so we give up on __intX for them.
#if (_MSC_VER < 1300)
typedef signed char int8_t;
typedef signed short int16_t;
typedef signed int int32_t;
typedef unsigned char uint8_t;
typedef unsigned short uint16_t;
typedef unsigned int uint32_t;
#else
typedef signed __int8 int8_t;
typedef signed __int16 int16_t;
typedef signed __int32 int32_t;
typedef unsigned __int8 uint8_t;
typedef unsigned __int16 uint16_t;
typedef unsigned __int32 uint32_t;
#endif
typedef signed __int64 int64_t;
typedef unsigned __int64 uint64_t;
// 7.18.1.2 Minimum-width integer types
typedef int8_t int_least8_t;
typedef int16_t int_least16_t;
typedef int32_t int_least32_t;
typedef int64_t int_least64_t;
typedef uint8_t uint_least8_t;
typedef uint16_t uint_least16_t;
typedef uint32_t uint_least32_t;
typedef uint64_t uint_least64_t;
// 7.18.1.3 Fastest minimum-width integer types
typedef int8_t int_fast8_t;
typedef int16_t int_fast16_t;
typedef int32_t int_fast32_t;
typedef int64_t int_fast64_t;
typedef uint8_t uint_fast8_t;
typedef uint16_t uint_fast16_t;
typedef uint32_t uint_fast32_t;
typedef uint64_t uint_fast64_t;
// 7.18.1.4 Integer types capable of holding object pointers
#ifdef _WIN64 // [
typedef signed __int64 intptr_t;
typedef unsigned __int64 uintptr_t;
#else // _WIN64 ][
typedef _W64 signed int intptr_t;
typedef _W64 unsigned int uintptr_t;
#endif // _WIN64 ]
// 7.18.1.5 Greatest-width integer types
typedef int64_t intmax_t;
typedef uint64_t uintmax_t;
// 7.18.2 Limits of specified-width integer types
#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) // [ See footnote 220 at page 257 and footnote 221 at page 259
// 7.18.2.1 Limits of exact-width integer types
#define INT8_MIN ((int8_t)_I8_MIN)
#define INT8_MAX _I8_MAX
#define INT16_MIN ((int16_t)_I16_MIN)
#define INT16_MAX _I16_MAX
#define INT32_MIN ((int32_t)_I32_MIN)
#define INT32_MAX _I32_MAX
#define INT64_MIN ((int64_t)_I64_MIN)
#define INT64_MAX _I64_MAX
#define UINT8_MAX _UI8_MAX
#define UINT16_MAX _UI16_MAX
#define UINT32_MAX _UI32_MAX
#define UINT64_MAX _UI64_MAX
// 7.18.2.2 Limits of minimum-width integer types
#define INT_LEAST8_MIN INT8_MIN
#define INT_LEAST8_MAX INT8_MAX
#define INT_LEAST16_MIN INT16_MIN
#define INT_LEAST16_MAX INT16_MAX
#define INT_LEAST32_MIN INT32_MIN
#define INT_LEAST32_MAX INT32_MAX
#define INT_LEAST64_MIN INT64_MIN
#define INT_LEAST64_MAX INT64_MAX
#define UINT_LEAST8_MAX UINT8_MAX
#define UINT_LEAST16_MAX UINT16_MAX
#define UINT_LEAST32_MAX UINT32_MAX
#define UINT_LEAST64_MAX UINT64_MAX
// 7.18.2.3 Limits of fastest minimum-width integer types
#define INT_FAST8_MIN INT8_MIN
#define INT_FAST8_MAX INT8_MAX
#define INT_FAST16_MIN INT16_MIN
#define INT_FAST16_MAX INT16_MAX
#define INT_FAST32_MIN INT32_MIN
#define INT_FAST32_MAX INT32_MAX
#define INT_FAST64_MIN INT64_MIN
#define INT_FAST64_MAX INT64_MAX
#define UINT_FAST8_MAX UINT8_MAX
#define UINT_FAST16_MAX UINT16_MAX
#define UINT_FAST32_MAX UINT32_MAX
#define UINT_FAST64_MAX UINT64_MAX
// 7.18.2.4 Limits of integer types capable of holding object pointers
#ifdef _WIN64 // [
# define INTPTR_MIN INT64_MIN
# define INTPTR_MAX INT64_MAX
# define UINTPTR_MAX UINT64_MAX
#else // _WIN64 ][
# define INTPTR_MIN INT32_MIN
# define INTPTR_MAX INT32_MAX
# define UINTPTR_MAX UINT32_MAX
#endif // _WIN64 ]
// 7.18.2.5 Limits of greatest-width integer types
#define INTMAX_MIN INT64_MIN
#define INTMAX_MAX INT64_MAX
#define UINTMAX_MAX UINT64_MAX
// 7.18.3 Limits of other integer types
#ifdef _WIN64 // [
# define PTRDIFF_MIN _I64_MIN
# define PTRDIFF_MAX _I64_MAX
#else // _WIN64 ][
# define PTRDIFF_MIN _I32_MIN
# define PTRDIFF_MAX _I32_MAX
#endif // _WIN64 ]
#define SIG_ATOMIC_MIN INT_MIN
#define SIG_ATOMIC_MAX INT_MAX
#ifndef SIZE_MAX // [
# ifdef _WIN64 // [
# define SIZE_MAX _UI64_MAX
# else // _WIN64 ][
# define SIZE_MAX _UI32_MAX
# endif // _WIN64 ]
#endif // SIZE_MAX ]
// WCHAR_MIN and WCHAR_MAX are also defined in <wchar.h>
#ifndef WCHAR_MIN // [
# define WCHAR_MIN 0
#endif // WCHAR_MIN ]
#ifndef WCHAR_MAX // [
# define WCHAR_MAX _UI16_MAX
#endif // WCHAR_MAX ]
#define WINT_MIN 0
#define WINT_MAX _UI16_MAX
#endif // __STDC_LIMIT_MACROS ]
// 7.18.4 Limits of other integer types
#if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) // [ See footnote 224 at page 260
// 7.18.4.1 Macros for minimum-width integer constants
#define INT8_C(val) val##i8
#define INT16_C(val) val##i16
#define INT32_C(val) val##i32
#define INT64_C(val) val##i64
#define UINT8_C(val) val##ui8
#define UINT16_C(val) val##ui16
#define UINT32_C(val) val##ui32
#define UINT64_C(val) val##ui64
// 7.18.4.2 Macros for greatest-width integer constants
#define INTMAX_C INT64_C
#define UINTMAX_C UINT64_C
#endif // __STDC_CONSTANT_MACROS ]
#endif // _MSC_STDINT_H_ ]
Bugs are now managed in the SDL bug tracker, here:
http://bugzilla.libsdl.org/
You may report bugs there, and search to see if a given issue has already
been reported, discussed, and maybe even fixed.
You may also find help at the SDL mailing list. Subscription information:
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Bug reports are welcome here, but we really appreciate if you use Bugzilla, as
bugs discussed on the mailing list may be forgotten or missed.
This diff is collapsed.
Simple DirectMedia Layer
(SDL)
Version 1.2
---
http://www.libsdl.org/
This is the Simple DirectMedia Layer, a general API that provides low
level access to audio, keyboard, mouse, joystick, 3D hardware via OpenGL,
and 2D framebuffer across multiple platforms.
The current version supports Linux, Windows CE/95/98/ME/XP/Vista, BeOS,
MacOS Classic, Mac OS X, FreeBSD, NetBSD, OpenBSD, BSD/OS, Solaris, IRIX,
and QNX. The code contains support for Dreamcast, Atari, AIX, OSF/Tru64,
RISC OS, SymbianOS, Nintendo DS, and OS/2, but these are not officially
supported.
SDL is written in C, but works with C++ natively, and has bindings to
several other languages, including Ada, C#, Eiffel, Erlang, Euphoria,
Guile, Haskell, Java, Lisp, Lua, ML, Objective C, Pascal, Perl, PHP,
Pike, Pliant, Python, Ruby, and Smalltalk.
This library is distributed under GNU LGPL version 2, which can be
found in the file "COPYING". This license allows you to use SDL
freely in commercial programs as long as you link with the dynamic
library.
The best way to learn how to use SDL is to check out the header files in
the "include" subdirectory and the programs in the "test" subdirectory.
The header files and test programs are well commented and always up to date.
More documentation is available in HTML format in "docs/index.html", and
a documentation wiki is available online at:
http://www.libsdl.org/cgi/docwiki.cgi
The test programs in the "test" subdirectory are in the public domain.
Frequently asked questions are answered online:
http://www.libsdl.org/faq.php
If you need help with the library, or just want to discuss SDL related
issues, you can join the developers mailing list:
http://www.libsdl.org/mailing-list.php
Enjoy!
Sam Lantinga (slouken@libsdl.org)
Please distribute this file with the SDL runtime environment:
The Simple DirectMedia Layer (SDL for short) is a cross-platfrom library
designed to make it easy to write multi-media software, such as games and
emulators.
The Simple DirectMedia Layer library source code is available from:
http://www.libsdl.org/
This library is distributed under the terms of the GNU LGPL license:
http://www.gnu.org/copyleft/lesser.html
<HTML>
<HEAD>
<TITLE>Using SDL with Microsoft Visual C++</TITLE>
</HEAD>
<BODY>
<H1>
Using SDL with Microsoft Visual C++ 5,6&nbsp;and 7
</H1>
<H3>
by <A HREF="mailto:snowlion@sprynet.com">Lion Kimbro </A>and additions by <A HREF="mailto:james@conceptofzero.net">
James Turk</A>
</H3>
<p>
You can either use the precompiled libraries from <A HREF="http://www.libsdl.org/download.php">
the SDL Download web site </A>, or you can build SDL yourself.
</p>
<H3>
Building SDL
</H3>
<P>
Unzip the <CODE>VisualC.zip</CODE> file into the directory that contains this
file (<CODE>VisualC.html</CODE>).
</P>
<P>
Be certain that you unzip the zip file for your compiler into <strong>this</strong>
directory and not any other directory. If you are using WinZip, be careful to
make sure that it extracts to <strong>this</strong> folder, because it's
convenient feature of unzipping to a folder with the name of the file currently
being unzipped will get you in trouble if you use it right now. And that's all
I have to say about that.
</P>
<P>
Now that it's unzipped, go into the VisualC
directory that is created, and double-click on the VC++ file "<CODE>SDL.dsw</CODE>"<STRONG><FONT color="#009900">
("<CODE>SDL.sln</CODE>").</FONT></STRONG> This should open up the IDE.
</P>
<P>
You may be prompted at this point to upgrade the workspace, should you be using
a more recent version of Visual C++. If so, allow the workspace to be upgraded.
</P>
<P>
Build the <CODE>.dll</CODE> and <CODE>.lib</CODE> files.
</P>
<P>
This is done by right clicking on each project in turn (Projects are listed in
the Workspace panel in the FileView tab), and selecting "Build".
</P>
<P>
If you get an error about SDL_config.h being missing, you should
copy include/SDL_config.h.default to include/SDL_config.h and try again.
</P>
<P>
You may get a few warnings, but you should not get any errors. You do have to
have at least the DirectX 5 SDK installed, however. The latest
version of DirectX can be downloaded or purchased on a cheap CD (my
recommendation) from <A HREF="http://www.microsoft.com">Microsoft </A>.
</P>
<P>
Later, we will refer to the following .lib and .dll files that have just been
generated:
</P>
<ul>
<li> SDL.dll</li>
<li> SDL.lib</li>
<li> SDLmain.lib</li>
</ul>
<P>
Search for these using the Windows Find (Windows-F) utility, if you don't
already know where they should be. For those of you with a clue, look inside
the Debug or Release directories of the subdirectories of the Project folder.
(It might be easier to just use Windows Find if this sounds confusing. And
don't worry about needing a clue; we all need visits from the clue fairy
frequently.)
</P>
<H3>
Creating a Project with SDL
</H3>
<P>
Create a project as a Win32 Application.
</P>
<P>
Create a C++ file for your project.
</P>
<P>
Set the C runtime to "Multi-threaded DLL" in the menu: <CODE>Project|Settings|C/C++
tab|Code Generation|Runtime Library </CODE>.
</P>
<P>
Add the SDL <CODE>include</CODE> directory to your list of includes in the
menu: <CODE>Project|Settings|C/C++ tab|Preprocessor|Additional include directories </CODE>
.
<br>
<STRONG><FONT color="#009900">VC7 Specific: Instead of doing this I find it easier to
add the include and library directories to the list that VC7 keeps. Do this by
selecting Tools|Options|Projects|VC++ Directories and under the "Show
Directories For:" dropbox select "Include Files", and click the "New Directory
Icon" and add the [SDLROOT]\include directory (ex. If you installed to
c:\SDL-1.2.5\ add c:\SDL-1.2.5\include).&nbsp;Proceed to&nbsp;change the
dropbox selection to "Library Files" and add [SDLROOT]\lib.</FONT></STRONG>
</P>
<P>
The "include directory" I am referring to is the <CODE>include</CODE> folder
within the main SDL directory (the one that this HTML file located within).
</P>
<P>
Now we're going to use the files that we had created earlier in the Build SDL
step.
</P>
<P>
Copy the following files into your Project directory:
</P>
<ul>
<li> SDL.dll</li>
</ul>
<P>
Add the following files to your project (It is not necessary to copy them to
your project directory):
</P>
<ul>
<li> SDL.lib </li>
<li> SDLmain.lib</li>
</ul>
<P>
(To add them to your project, right click on your project, and select "Add
files to project")
</P>
<P><STRONG><FONT color="#009900">Instead of adding the files to your project it is more
desireable to add them to the linker options: Project|Properties|Linker|Command
Line and type the names of the libraries to link with in the "Additional
Options:" box.&nbsp; Note: This must be done&nbsp;for&nbsp;each&nbsp;build
configuration (eg. Release,Debug).</FONT></STRONG></P>
<H3>
SDL 101, First Day of Class
</H3>
<P>
Now create the basic body of your project. The body of your program should take
the following form: <CODE>
<PRE>
#include "SDL.h"
int main( int argc, char* argv[] )
{
// Body of the program goes here.
return 0;
}
</PRE>
</CODE>
<P></P>
<H3>
That's it!
</H3>
<P>
I hope that this document has helped you get through the most difficult part of
using the SDL: installing it. Suggestions for improvements to this document
should be sent to the writers of this document.
</P>
<P>
Thanks to Paulus Esterhazy (pesterhazy@gmx.net), for the work on VC++ port.
</P>
<P>
This document was originally called "VisualC.txt", and was written by <A HREF="mailto:slouken@libsdl.org">
Sam Lantinga</A>.
</P>
<P>
Later, it was converted to HTML and expanded into the document that you see
today by <A HREF="mailto:snowlion@sprynet.com">Lion Kimbro</A>.
</P>
<P>Minor Fixes and Visual C++ 7 Information (In Green) was added by <A HREF="mailto:james@conceptofzero.net">James Turk</A>
</P>
</BODY>
</HTML>
This diff is collapsed.
This diff is collapsed.
<HTML
><HEAD
><TITLE
>Audio</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+
"><LINK
REL="HOME"
TITLE="SDL Library Documentation"
HREF="index.html"><LINK
REL="UP"
TITLE="SDL Reference"
HREF="reference.html"><LINK
REL="PREVIOUS"
TITLE="SDL_JoystickClose"
HREF="sdljoystickclose.html"><LINK
REL="NEXT"
TITLE="SDL_AudioSpec"
HREF="sdlaudiospec.html"><META
NAME="KEYWORD"
CONTENT="audio"><META
NAME="KEYWORD"
CONTENT="function"></HEAD
><BODY
CLASS="CHAPTER"
BGCOLOR="#FFF8DC"
TEXT="#000000"
LINK="#0000ee"
VLINK="#551a8b"
ALINK="#ff0000"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>SDL Library Documentation</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="sdljoystickclose.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="sdlaudiospec.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="CHAPTER"
><H1
><A
NAME="AUDIO"
></A
>Chapter 10. Audio</H1
><DIV
CLASS="TOC"
><DL
><DT
><B
>Table of Contents</B
></DT
><DT
><A
HREF="sdlaudiospec.html"
>SDL_AudioSpec</A
>&nbsp;--&nbsp;Audio Specification Structure</DT
><DT
><A
HREF="sdlopenaudio.html"
>SDL_OpenAudio</A
>&nbsp;--&nbsp;Opens the audio device with the desired parameters.</DT
><DT
><A
HREF="sdlpauseaudio.html"
>SDL_PauseAudio</A
>&nbsp;--&nbsp;Pauses and unpauses the audio callback processing</DT
><DT
><A
HREF="sdlgetaudiostatus.html"
>SDL_GetAudioStatus</A
>&nbsp;--&nbsp;Get the current audio state</DT
><DT
><A
HREF="sdlloadwav.html"
>SDL_LoadWAV</A
>&nbsp;--&nbsp;Load a WAVE file</DT
><DT
><A
HREF="sdlfreewav.html"
>SDL_FreeWAV</A
>&nbsp;--&nbsp;Frees previously opened WAV data</DT
><DT
><A
HREF="sdlaudiocvt.html"
>SDL_AudioCVT</A
>&nbsp;--&nbsp;Audio Conversion Structure</DT
><DT
><A
HREF="sdlbuildaudiocvt.html"
>SDL_BuildAudioCVT</A
>&nbsp;--&nbsp;Initializes a SDL_AudioCVT structure for conversion</DT
><DT
><A
HREF="sdlconvertaudio.html"
>SDL_ConvertAudio</A
>&nbsp;--&nbsp;Convert audio data to a desired audio format.</DT
><DT
><A
HREF="sdlmixaudio.html"
>SDL_MixAudio</A
>&nbsp;--&nbsp;Mix audio data</DT
><DT
><A
HREF="sdllockaudio.html"
>SDL_LockAudio</A
>&nbsp;--&nbsp;Lock out the callback function</DT
><DT
><A
HREF="sdlunlockaudio.html"
>SDL_UnlockAudio</A
>&nbsp;--&nbsp;Unlock the callback function</DT
><DT
><A
HREF="sdlcloseaudio.html"
>SDL_CloseAudio</A
>&nbsp;--&nbsp;Shuts down audio processing and closes the audio device.</DT
></DL
></DIV
><P
>Sound on the computer is translated from waves that you hear into a series of
values, or samples, each representing the amplitude of the wave. When these
samples are sent in a stream to a sound card, an approximation of the original
wave can be recreated. The more bits used to represent the amplitude, and the
greater frequency these samples are gathered, the closer the approximated
sound is to the original, and the better the quality of sound.</P
><P
>This library supports both 8 and 16 bit signed and unsigned sound samples,
at frequencies ranging from 11025 Hz to 44100 Hz, depending on the
underlying hardware. If the hardware doesn't support the desired audio
format or frequency, it can be emulated if desired (See
<A
HREF="sdlopenaudio.html"
><TT
CLASS="FUNCTION"
>SDL_OpenAudio()</TT
></A
>)</P
><P
>A commonly supported audio format is 16 bits per sample at 22050 Hz.</P
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="sdljoystickclose.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="sdlaudiospec.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>SDL_JoystickClose</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="reference.html"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>SDL_AudioSpec</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>
\ No newline at end of file
<HTML
><HEAD
><TITLE
>CD-ROM</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+
"><LINK
REL="HOME"
TITLE="SDL Library Documentation"
HREF="index.html"><LINK
REL="UP"
TITLE="SDL Reference"
HREF="reference.html"><LINK
REL="PREVIOUS"
TITLE="SDL_CloseAudio"
HREF="sdlcloseaudio.html"><LINK
REL="NEXT"
TITLE="SDL_CDNumDrives"
HREF="sdlcdnumdrives.html"><META
NAME="KEYWORD"
CONTENT="cdrom"><META
NAME="KEYWORD"
CONTENT="function"></HEAD
><BODY
CLASS="CHAPTER"
BGCOLOR="#FFF8DC"
TEXT="#000000"
LINK="#0000ee"
VLINK="#551a8b"
ALINK="#ff0000"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>SDL Library Documentation</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="sdlcloseaudio.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="sdlcdnumdrives.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="CHAPTER"
><H1
><A
NAME="CDROM"
></A
>Chapter 11. CD-ROM</H1
><DIV
CLASS="TOC"
><DL
><DT
><B
>Table of Contents</B
></DT
><DT
><A
HREF="sdlcdnumdrives.html"
>SDL_CDNumDrives</A
>&nbsp;--&nbsp;Returns the number of CD-ROM drives on the system.</DT
><DT
><A
HREF="sdlcdname.html"
>SDL_CDName</A
>&nbsp;--&nbsp;Returns a human-readable, system-dependent identifier for the CD-ROM.</DT
><DT
><A
HREF="sdlcdopen.html"
>SDL_CDOpen</A
>&nbsp;--&nbsp;Opens a CD-ROM drive for access.</DT
><DT
><A
HREF="sdlcdstatus.html"
>SDL_CDStatus</A
>&nbsp;--&nbsp;Returns the current status of the given drive.</DT
><DT
><A
HREF="sdlcdplay.html"
>SDL_CDPlay</A
>&nbsp;--&nbsp;Play a CD</DT
><DT
><A
HREF="sdlcdplaytracks.html"
>SDL_CDPlayTracks</A
>&nbsp;--&nbsp;Play the given CD track(s)</DT
><DT
><A
HREF="sdlcdpause.html"
>SDL_CDPause</A
>&nbsp;--&nbsp;Pauses a CDROM</DT
><DT
><A
HREF="sdlcdresume.html"
>SDL_CDResume</A
>&nbsp;--&nbsp;Resumes a CDROM</DT
><DT
><A
HREF="sdlcdstop.html"
>SDL_CDStop</A
>&nbsp;--&nbsp;Stops a CDROM</DT
><DT
><A
HREF="sdlcdeject.html"
>SDL_CDEject</A
>&nbsp;--&nbsp;Ejects a CDROM</DT
><DT
><A
HREF="sdlcdclose.html"
>SDL_CDClose</A
>&nbsp;--&nbsp;Closes a SDL_CD handle</DT
><DT
><A
HREF="sdlcd.html"
>SDL_CD</A
>&nbsp;--&nbsp;CDROM Drive Information</DT
><DT
><A
HREF="sdlcdtrack.html"
>SDL_CDtrack</A
>&nbsp;--&nbsp;CD Track Information Structure</DT
></DL
></DIV
><P
>SDL supports audio control of up to 32 local CD-ROM drives at once.</P
><P
>You use this API to perform all the basic functions of a CD player,
including listing the tracks, playing, stopping, and ejecting the CD-ROM.
(Currently, multi-changer CD drives are not supported.)</P
><P
>Before you call any of the SDL CD-ROM functions, you must first call
"<TT
CLASS="FUNCTION"
>SDL_Init(SDL_INIT_CDROM)</TT
>", which scans the system for
CD-ROM drives, and sets the program up for audio control. Check the
return code, which should be <SPAN
CLASS="RETURNVALUE"
>0</SPAN
>, to see if there
were any errors in starting up.</P
><P
>After you have initialized the library, you can find out how many drives
are available using the <TT
CLASS="FUNCTION"
>SDL_CDNumDrives()</TT
> function.
The first drive listed is the system default CD-ROM drive. After you have
chosen a drive, and have opened it with <TT
CLASS="FUNCTION"
>SDL_CDOpen()</TT
>,
you can check the status and start playing if there's a CD in the drive.</P
><P
>A CD-ROM is organized into one or more tracks, each consisting of a certain
number of "frames". Each frame is ~2K in size, and at normal playing speed,
a CD plays 75 frames per second. SDL works with the number of frames on a
CD, but this can easily be converted to the more familiar minutes/seconds
format by using the <TT
CLASS="FUNCTION"
>FRAMES_TO_MSF()</TT
> macro.</P
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="sdlcloseaudio.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="sdlcdnumdrives.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>SDL_CloseAudio</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="reference.html"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>SDL_CDNumDrives</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>
\ No newline at end of file
<HTML
><HEAD
><TITLE
>Events</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+
"><LINK
REL="HOME"
TITLE="SDL Library Documentation"
HREF="index.html"><LINK
REL="UP"
TITLE="SDL Reference"
HREF="reference.html"><LINK
REL="PREVIOUS"
TITLE="SDL_WM_GrabInput"
HREF="sdlwmgrabinput.html"><LINK
REL="NEXT"
TITLE="SDL Event Structures."
HREF="eventstructures.html"><META
NAME="KEYWORD"
CONTENT="events"><META
NAME="KEYWORD"
CONTENT="function"></HEAD
><BODY
CLASS="CHAPTER"
BGCOLOR="#FFF8DC"
TEXT="#000000"
LINK="#0000ee"
VLINK="#551a8b"
ALINK="#ff0000"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>SDL Library Documentation</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="sdlwmgrabinput.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="eventstructures.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="CHAPTER"
><H1
><A
NAME="EVENT"
></A
>Chapter 8. Events</H1
><DIV
CLASS="TOC"
><DL
><DT
><B
>Table of Contents</B
></DT
><DT
><A
HREF="event.html#AEN3691"
>Introduction</A
></DT
><DT
><A
HREF="eventstructures.html"
>SDL Event Structures.</A
></DT
><DT
><A
HREF="eventfunctions.html"
>Event Functions.</A
></DT
></DL
></DIV
><DIV
CLASS="SECT1"
><H1
CLASS="SECT1"
><A
NAME="AEN3691"
></A
>Introduction</H1
><P
>Event handling allows your application to receive input from the user. Event handling is initalised (along with video) with a call to:
<PRE
CLASS="PROGRAMLISTING"
>SDL_Init(SDL_INIT_VIDEO);</PRE
>
Internally, SDL stores all the events waiting to be handled in an event queue. Using functions like <A
HREF="sdlpollevent.html"
><TT
CLASS="FUNCTION"
>SDL_PollEvent</TT
></A
> and <A
HREF="sdlpeepevents.html"
><TT
CLASS="FUNCTION"
>SDL_PeepEvents</TT
></A
> you can observe and handle waiting input events.</P
><P
>The key to event handling in SDL is the <A
HREF="sdlevent.html"
><SPAN
CLASS="STRUCTNAME"
>SDL_Event</SPAN
></A
> union. The event queue itself is composed of a series of <SPAN
CLASS="STRUCTNAME"
>SDL_Event</SPAN
> unions, one for each waiting event. <SPAN
CLASS="STRUCTNAME"
>SDL_Event</SPAN
> unions are read from the queue with the <TT
CLASS="FUNCTION"
>SDL_PollEvent</TT
> function and it is then up to the application to process the information stored with them.</P
></DIV
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="sdlwmgrabinput.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="eventstructures.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>SDL_WM_GrabInput</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="reference.html"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>SDL Event Structures.</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>
\ No newline at end of file
<HTML
><HEAD
><TITLE
>Event Functions.</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+
"><LINK
REL="HOME"
TITLE="SDL Library Documentation"
HREF="index.html"><LINK
REL="UP"
TITLE="Events"
HREF="event.html"><LINK
REL="PREVIOUS"
TITLE="SDLKey"
HREF="sdlkey.html"><LINK
REL="NEXT"
TITLE="SDL_PumpEvents"
HREF="sdlpumpevents.html"></HEAD
><BODY
CLASS="SECT1"
BGCOLOR="#FFF8DC"
TEXT="#000000"
LINK="#0000ee"
VLINK="#551a8b"
ALINK="#ff0000"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>SDL Library Documentation</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="sdlkey.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
>Chapter 8. Events</TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="sdlpumpevents.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="SECT1"
><H1
CLASS="SECT1"
><A
NAME="EVENTFUNCTIONS"
></A
>Event Functions.</H1
><DIV
CLASS="TOC"
><DL
><DT
><B
>Table of Contents</B
></DT
><DT
><A
HREF="sdlpumpevents.html"
>SDL_PumpEvents</A
>&nbsp;--&nbsp;Pumps the event loop, gathering events from the input devices.</DT
><DT
><A
HREF="sdlpeepevents.html"
>SDL_PeepEvents</A
>&nbsp;--&nbsp;Checks the event queue for messages and optionally returns them.</DT
><DT
><A
HREF="sdlpollevent.html"
>SDL_PollEvent</A
>&nbsp;--&nbsp;Polls for currently pending events.</DT
><DT
><A
HREF="sdlwaitevent.html"
>SDL_WaitEvent</A
>&nbsp;--&nbsp;Waits indefinitely for the next available event.</DT
><DT
><A
HREF="sdlpushevent.html"
>SDL_PushEvent</A
>&nbsp;--&nbsp;Pushes an event onto the event queue</DT
><DT
><A
HREF="sdlseteventfilter.html"
>SDL_SetEventFilter</A
>&nbsp;--&nbsp;Sets up a filter to process all events before they are posted
to the event queue.</DT
><DT
><A
HREF="sdlgeteventfilter.html"
>SDL_GetEventFilter</A
>&nbsp;--&nbsp;Retrieves a pointer to he event filter</DT
><DT
><A
HREF="sdleventstate.html"
>SDL_EventState</A
>&nbsp;--&nbsp;This function allows you to set the state of processing certain events.</DT
><DT
><A
HREF="sdlgetkeystate.html"
>SDL_GetKeyState</A
>&nbsp;--&nbsp;Get a snapshot of the current keyboard state</DT
><DT
><A
HREF="sdlgetmodstate.html"
>SDL_GetModState</A
>&nbsp;--&nbsp;Get the state of modifier keys.</DT
><DT
><A
HREF="sdlsetmodstate.html"
>SDL_SetModState</A
>&nbsp;--&nbsp;Set the current key modifier state</DT
><DT
><A
HREF="sdlgetkeyname.html"
>SDL_GetKeyName</A
>&nbsp;--&nbsp;Get the name of an SDL virtual keysym</DT
><DT
><A
HREF="sdlenableunicode.html"
>SDL_EnableUNICODE</A
>&nbsp;--&nbsp;Enable UNICODE translation</DT
><DT
><A
HREF="sdlenablekeyrepeat.html"
>SDL_EnableKeyRepeat</A
>&nbsp;--&nbsp;Set keyboard repeat rate.</DT
><DT
><A
HREF="sdlgetmousestate.html"
>SDL_GetMouseState</A
>&nbsp;--&nbsp;Retrieve the current state of the mouse</DT
><DT
><A
HREF="sdlgetrelativemousestate.html"
>SDL_GetRelativeMouseState</A
>&nbsp;--&nbsp;Retrieve the current state of the mouse</DT
><DT
><A
HREF="sdlgetappstate.html"
>SDL_GetAppState</A
>&nbsp;--&nbsp;Get the state of the application</DT
><DT
><A
HREF="sdljoystickeventstate.html"
>SDL_JoystickEventState</A
>&nbsp;--&nbsp;Enable/disable joystick event polling</DT
></DL
></DIV
><DIV
CLASS="INFORMALTABLE"
><A
NAME="AEN5312"
></A
><P
></P
><TABLE
BORDER="0"
CLASS="CALSTABLE"
><TBODY
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
><A
HREF="sdlpumpevents.html"
>SDL_PumpEvents</A
></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
>Pumps the event loop, gathering events from the input devices</TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
><A
HREF="sdlpeepevents.html"
>SDL_PeepEvents</A
></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
>Checks the event queue for messages and optionally returns them</TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
><A
HREF="sdlpollevent.html"
>SDL_PollEvent</A
></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
>Polls for currently pending events</TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
><A
HREF="sdlwaitevent.html"
>SDL_WaitEvent</A
></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
>Waits indefinitely for the next available event</TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
><A
HREF="sdlpushevent.html"
>SDL_PushEvent</A
></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
>Pushes an event onto the event queue</TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
><A
HREF="sdlseteventfilter.html"
>SDL_SetEventFilter</A
></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
>Sets up a filter to process all events</TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
><A
HREF="sdleventstate.html"
>SDL_EventState</A
></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
>Allows you to set the state of processing certain events</TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
><A
HREF="sdlgetkeystate.html"
>SDL_GetKeyState</A
></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
>Get a snapshot of the current keyboard state</TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
><A
HREF="sdlgetmodstate.html"
>SDL_GetModState</A
></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
>Get the state of modifier keys</TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
><A
HREF="sdlsetmodstate.html"
>SDL_SetModState</A
></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
>Set the state of modifier keys</TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
><A
HREF="sdlgetkeyname.html"
>SDL_GetKeyName</A
></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
>Get the name of an SDL virtual keysym</TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
><A
HREF="sdlenableunicode.html"
>SDL_EnableUNICODE</A
></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
>Enable UNICODE translation</TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
><A
HREF="sdlenablekeyrepeat.html"
>SDL_EnableKeyRepeat</A
></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
>Set keyboard repeat rate</TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
><A
HREF="sdlgetmousestate.html"
>SDL_GetMouseState</A
></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
>Retrieve the current state of the mouse</TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
><A
HREF="sdlgetrelativemousestate.html"
>SDL_GetRelativeMouseState</A
></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
>Retrieve the current state of the mouse</TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
><A
HREF="sdlgetappstate.html"
>SDL_GetAppState</A
></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
>Get the state of the application</TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
><A
HREF="sdljoystickeventstate.html"
>SDL_JoystickEventState</A
></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
>Enable/disable joystick event polling</TD
></TR
></TBODY
></TABLE
><P
></P
></DIV
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="sdlkey.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="sdlpumpevents.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>SDLKey</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="event.html"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>SDL_PumpEvents</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>
\ No newline at end of file
<HTML
><HEAD
><TITLE
>SDL Event Structures.</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+
"><LINK
REL="HOME"
TITLE="SDL Library Documentation"
HREF="index.html"><LINK
REL="UP"
TITLE="Events"
HREF="event.html"><LINK
REL="PREVIOUS"
TITLE="Events"
HREF="event.html"><LINK
REL="NEXT"
TITLE="SDL_Event"
HREF="sdlevent.html"></HEAD
><BODY
CLASS="SECT1"
BGCOLOR="#FFF8DC"
TEXT="#000000"
LINK="#0000ee"
VLINK="#551a8b"
ALINK="#ff0000"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>SDL Library Documentation</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="event.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
>Chapter 8. Events</TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="sdlevent.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="SECT1"
><H1
CLASS="SECT1"
><A
NAME="EVENTSTRUCTURES"
></A
>SDL Event Structures.</H1
><DIV
CLASS="TOC"
><DL
><DT
><B
>Table of Contents</B
></DT
><DT
><A
HREF="sdlevent.html"
>SDL_Event</A
>&nbsp;--&nbsp;General event structure</DT
><DT
><A
HREF="sdlactiveevent.html"
>SDL_ActiveEvent</A
>&nbsp;--&nbsp;Application visibility event structure</DT
><DT
><A
HREF="sdlkeyboardevent.html"
>SDL_KeyboardEvent</A
>&nbsp;--&nbsp;Keyboard event structure</DT
><DT
><A
HREF="sdlmousemotionevent.html"
>SDL_MouseMotionEvent</A
>&nbsp;--&nbsp;Mouse motion event structure</DT
><DT
><A
HREF="sdlmousebuttonevent.html"
>SDL_MouseButtonEvent</A
>&nbsp;--&nbsp;Mouse button event structure</DT
><DT
><A
HREF="sdljoyaxisevent.html"
>SDL_JoyAxisEvent</A
>&nbsp;--&nbsp;Joystick axis motion event structure</DT
><DT
><A
HREF="sdljoybuttonevent.html"
>SDL_JoyButtonEvent</A
>&nbsp;--&nbsp;Joystick button event structure</DT
><DT
><A
HREF="sdljoyhatevent.html"
>SDL_JoyHatEvent</A
>&nbsp;--&nbsp;Joystick hat position change event structure</DT
><DT
><A
HREF="sdljoyballevent.html"
>SDL_JoyBallEvent</A
>&nbsp;--&nbsp;Joystick trackball motion event structure</DT
><DT
><A
HREF="sdlresizeevent.html"
>SDL_ResizeEvent</A
>&nbsp;--&nbsp;Window resize event structure</DT
><DT
><A
HREF="sdlexposeevent.html"
>SDL_ExposeEvent</A
>&nbsp;--&nbsp;Quit requested event</DT
><DT
><A
HREF="sdlsyswmevent.html"
>SDL_SysWMEvent</A
>&nbsp;--&nbsp;Platform-dependent window manager event.</DT
><DT
><A
HREF="sdluserevent.html"
>SDL_UserEvent</A
>&nbsp;--&nbsp;A user-defined event type</DT
><DT
><A
HREF="sdlquitevent.html"
>SDL_QuitEvent</A
>&nbsp;--&nbsp;Quit requested event</DT
><DT
><A
HREF="sdlkeysym.html"
>SDL_keysym</A
>&nbsp;--&nbsp;Keysym structure</DT
><DT
><A
HREF="sdlkey.html"
>SDLKey</A
>&nbsp;--&nbsp;Keysym definitions.</DT
></DL
></DIV
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="event.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="sdlevent.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>Events</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="event.html"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>SDL_Event</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>
\ No newline at end of file
<HTML
><HEAD
><TITLE
>General</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+
"><LINK
REL="HOME"
TITLE="SDL Library Documentation"
HREF="index.html"><LINK
REL="UP"
TITLE="SDL Reference"
HREF="reference.html"><LINK
REL="PREVIOUS"
TITLE="SDL Reference"
HREF="reference.html"><LINK
REL="NEXT"
TITLE="SDL_Init"
HREF="sdlinit.html"><META
NAME="KEYWORD"
CONTENT="general"><META
NAME="KEYWORD"
CONTENT="function"></HEAD
><BODY
CLASS="CHAPTER"
BGCOLOR="#FFF8DC"
TEXT="#000000"
LINK="#0000ee"
VLINK="#551a8b"
ALINK="#ff0000"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>SDL Library Documentation</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="reference.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="sdlinit.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="CHAPTER"
><H1
><A
NAME="GENERAL"
></A
>Chapter 5. General</H1
><DIV
CLASS="TOC"
><DL
><DT
><B
>Table of Contents</B
></DT
><DT
><A
HREF="sdlinit.html"
>SDL_Init</A
>&nbsp;--&nbsp;Initializes SDL</DT
><DT
><A
HREF="sdlinitsubsystem.html"
>SDL_InitSubSystem</A
>&nbsp;--&nbsp;Initialize subsystems</DT
><DT
><A
HREF="sdlquitsubsystem.html"
>SDL_QuitSubSystem</A
>&nbsp;--&nbsp;Shut down a subsystem</DT
><DT
><A
HREF="sdlquit.html"
>SDL_Quit</A
>&nbsp;--&nbsp;Shut down SDL</DT
><DT
><A
HREF="sdlwasinit.html"
>SDL_WasInit</A
>&nbsp;--&nbsp;Check which subsystems are initialized</DT
><DT
><A
HREF="sdlgeterror.html"
>SDL_GetError</A
>&nbsp;--&nbsp;Get SDL error string</DT
><DT
><A
HREF="sdlenvvars.html"
>SDL_envvars</A
>&nbsp;--&nbsp;SDL environment variables</DT
></DL
></DIV
><P
>Before SDL can be used in a program it must be initialized with <A
HREF="sdlinit.html"
><TT
CLASS="FUNCTION"
>SDL_Init</TT
></A
>. <TT
CLASS="FUNCTION"
>SDL_Init</TT
> initializes all the subsystems that the user requests (video, audio, joystick, timers and/or cdrom). Once SDL is initialized with <TT
CLASS="FUNCTION"
>SDL_Init</TT
> subsystems can be shut down and initialized as needed using <A
HREF="sdlinitsubsystem.html"
><TT
CLASS="FUNCTION"
>SDL_InitSubSystem</TT
></A
> and <A
HREF="sdlquitsubsystem.html"
><TT
CLASS="FUNCTION"
>SDL_QuitSubSystem</TT
></A
>.</P
><P
>SDL must also be shut down before the program exits to make sure it cleans up correctly. Calling <A
HREF="sdlquit.html"
><TT
CLASS="FUNCTION"
>SDL_Quit</TT
></A
> shuts down all subsystems and frees any resources allocated to SDL.</P
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="reference.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="sdlinit.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>SDL Reference</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="reference.html"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>SDL_Init</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>
\ No newline at end of file
<HTML
><HEAD
><TITLE
>SDL Guide</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+
"><LINK
REL="HOME"
TITLE="SDL Library Documentation"
HREF="index.html"><LINK
REL="PREVIOUS"
TITLE="SDL Library Documentation"
HREF="index.html"><LINK
REL="NEXT"
TITLE="Preface"
HREF="guidepreface.html"></HEAD
><BODY
CLASS="PART"
BGCOLOR="#FFF8DC"
TEXT="#000000"
LINK="#0000ee"
VLINK="#551a8b"
ALINK="#ff0000"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>SDL Library Documentation</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="index.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="guidepreface.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="PART"
><A
NAME="GUIDE"
></A
><DIV
CLASS="TITLEPAGE"
><H1
CLASS="TITLE"
>I. SDL Guide</H1
><DIV
CLASS="TOC"
><DL
><DT
><B
>Table of Contents</B
></DT
><DT
><A
HREF="guidepreface.html"
>Preface</A
></DT
><DT
>1. <A
HREF="guidethebasics.html"
>The Basics</A
></DT
><DT
>2. <A
HREF="guidevideo.html"
>Graphics and Video</A
></DT
><DT
>3. <A
HREF="guideinput.html"
>Input handling</A
></DT
><DT
>4. <A
HREF="guideexamples.html"
>Examples</A
></DT
></DL
></DIV
></DIV
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="guidepreface.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>SDL Library Documentation</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
>&nbsp;</TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>Preface</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>
\ No newline at end of file
<HTML
><HEAD
><TITLE
>About SDLdoc</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+
"><LINK
REL="HOME"
TITLE="SDL Library Documentation"
HREF="index.html"><LINK
REL="UP"
TITLE="Preface"
HREF="guidepreface.html"><LINK
REL="PREVIOUS"
TITLE="Preface"
HREF="guidepreface.html"><LINK
REL="NEXT"
TITLE="Credits"
HREF="guidecredits.html"></HEAD
><BODY
CLASS="SECT1"
BGCOLOR="#FFF8DC"
TEXT="#000000"
LINK="#0000ee"
VLINK="#551a8b"
ALINK="#ff0000"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>SDL Library Documentation</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="guidepreface.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
>Preface</TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="guidecredits.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="SECT1"
><H1
CLASS="SECT1"
><A
NAME="GUIDEABOUTSDLDOC"
></A
>About SDLdoc</H1
><P
>SDLdoc (The SDL Documentation Project) was formed to completely rewrite the SDL documentation and to keep it continually up to date. The team consists completely of volunteers ranging from people working with SDL in their spare time to people who use SDL in their everyday working lives.</P
><P
>The latest version of this documentation can always be found here: http://sdldoc.csn.ul.ie Downloadable PS, man pages and html tarballs are available at http://sdldoc.csn.ul.ie/pub/</P
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="guidepreface.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="guidecredits.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>Preface</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="guidepreface.html"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>Credits</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>
\ No newline at end of file
<HTML
><HEAD
><TITLE
>Audio Examples</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+
"><LINK
REL="HOME"
TITLE="SDL Library Documentation"
HREF="index.html"><LINK
REL="UP"
TITLE="Examples"
HREF="guideexamples.html"><LINK
REL="PREVIOUS"
TITLE="Event Examples"
HREF="guideeventexamples.html"><LINK
REL="NEXT"
TITLE="CDROM Examples"
HREF="guidecdromexamples.html"></HEAD
><BODY
CLASS="SECT1"
BGCOLOR="#FFF8DC"
TEXT="#000000"
LINK="#0000ee"
VLINK="#551a8b"
ALINK="#ff0000"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>SDL Library Documentation</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="guideeventexamples.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
>Chapter 4. Examples</TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="guidecdromexamples.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="SECT1"
><H1
CLASS="SECT1"
><A
NAME="GUIDEAUDIOEXAMPLES"
></A
>Audio Examples</H1
><P
></P
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="AEN382"
></A
>Opening the audio device</H2
><P
><PRE
CLASS="PROGRAMLISTING"
> SDL_AudioSpec wanted;
extern void fill_audio(void *udata, Uint8 *stream, int len);
/* Set the audio format */
wanted.freq = 22050;
wanted.format = AUDIO_S16;
wanted.channels = 2; /* 1 = mono, 2 = stereo */
wanted.samples = 1024; /* Good low-latency value for callback */
wanted.callback = fill_audio;
wanted.userdata = NULL;
/* Open the audio device, forcing the desired format */
if ( SDL_OpenAudio(&#38;wanted, NULL) &#60; 0 ) {
fprintf(stderr, "Couldn't open audio: %s\n", SDL_GetError());
return(-1);
}
return(0);</PRE
></P
></DIV
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="AEN386"
></A
>Playing audio</H2
><P
><PRE
CLASS="PROGRAMLISTING"
> static Uint8 *audio_chunk;
static Uint32 audio_len;
static Uint8 *audio_pos;
/* The audio function callback takes the following parameters:
stream: A pointer to the audio buffer to be filled
len: The length (in bytes) of the audio buffer
*/
void fill_audio(void *udata, Uint8 *stream, int len)
{
/* Only play if we have data left */
if ( audio_len == 0 )
return;
/* Mix as much data as possible */
len = ( len &#62; audio_len ? audio_len : len );
SDL_MixAudio(stream, audio_pos, len, SDL_MIX_MAXVOLUME);
audio_pos += len;
audio_len -= len;
}
/* Load the audio data ... */
;;;;;
audio_pos = audio_chunk;
/* Let the callback function play the audio chunk */
SDL_PauseAudio(0);
/* Do some processing */
;;;;;
/* Wait for sound to complete */
while ( audio_len &#62; 0 ) {
SDL_Delay(100); /* Sleep 1/10 second */
}
SDL_CloseAudio();</PRE
></P
></DIV
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="guideeventexamples.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="guidecdromexamples.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>Event Examples</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="guideexamples.html"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>CDROM Examples</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment