Commit bfecb28e by wester

point cloud

parent f65acd51
Pipeline #235 passed with stage
in 19 seconds
#TargetFrameworkVersion=v4.0:PlatformToolSet=v140:EnableManagedIncrementalBuild=false:VCToolArchitecture=Native32Bit:WindowsTargetPlatformVersion=8.1
Debug|Win32|H:\Repositories\MasterArbeit\3_PointCloud\|
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ImportGroup Label="PropertySheets" />
<PropertyGroup Label="UserMacros" />
<PropertyGroup />
<ItemDefinitionGroup>
<Link>
<AdditionalDependencies>glew32.lib;freeglut.lib;opengl32.lib;glu32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemGroup />
</Project>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ImportGroup Label="PropertySheets" />
<PropertyGroup Label="UserMacros" />
<PropertyGroup />
<ItemDefinitionGroup>
<ClCompile>
<AdditionalIncludeDirectories>$(KINECTSDK20_DIR)/inc;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<AdditionalLibraryDirectories>$(KINECTSDK20_DIR)/lib/x86;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>kinect20.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemGroup />
</Project>

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "KinectTutorial3", "KinectTutorial3.vcxproj", "{AFFAABC2-707F-4CE0-87D1-CCA550249103}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{AFFAABC2-707F-4CE0-87D1-CCA550249103}.Debug|Win32.ActiveCfg = Debug|Win32
{AFFAABC2-707F-4CE0-87D1-CCA550249103}.Debug|Win32.Build.0 = Debug|Win32
{AFFAABC2-707F-4CE0-87D1-CCA550249103}.Release|Win32.ActiveCfg = Release|Win32
{AFFAABC2-707F-4CE0-87D1-CCA550249103}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<Keyword>Win32Proj</Keyword>
<ProjectName>KinectTutorial3</ProjectName>
<ProjectGuid>{AFFAABC2-707F-4CE0-87D1-CCA550249103}</ProjectGuid>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="GLUT_OpenGL.props" />
<Import Project="SDL_OpenGL.props" />
<Import Project="Kinect.props" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="GLUT_OpenGL.props" />
<Import Project="SDL_OpenGL.props" />
<Import Project="Kinect.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>glew-2.0.0-win32\glew-2.0.0\include;SDL-devel-1.2.15-VC\SDL-1.2.15\include;freeglut-MSVC-3.0.0-2.mp\freeglut\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<TargetMachine>MachineX86</TargetMachine>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Windows</SubSystem>
<EntryPointSymbol>mainCRTStartup</EntryPointSymbol>
<AdditionalLibraryDirectories>freeglut-MSVC-3.0.0-2.mp\freeglut\bin;glew-2.0.0-win32\glew-2.0.0\bin\Release\Win32;SDL-devel-1.2.15-VC\SDL-1.2.15\lib\x86;glew-2.0.0-win32\glew-2.0.0\lib\Release\Win32;freeglut-MSVC-3.0.0-2.mp\freeglut\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<AdditionalIncludeDirectories>glew-2.0.0-win32\glew-2.0.0\include;SDL-devel-1.2.15-VC\SDL-1.2.15\include;freeglut-MSVC-3.0.0-2.mp\freeglut\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<TargetMachine>MachineX86</TargetMachine>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Windows</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalLibraryDirectories>freeglut-MSVC-3.0.0-2.mp\freeglut\bin;glew-2.0.0-win32\glew-2.0.0\bin\Release\Win32;SDL-devel-1.2.15-VC\SDL-1.2.15\lib\x86;glew-2.0.0-win32\glew-2.0.0\lib\Release\Win32;freeglut-MSVC-3.0.0-2.mp\freeglut\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="glut.cpp" />
<ClCompile Include="main.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="glut.h" />
<ClInclude Include="main.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="glut.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="main.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="glut.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="main.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
</Project>
\ No newline at end of file
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.
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
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)
<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>
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>
<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
<HTML
><HEAD
><TITLE
>Initializing SDL</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="The Basics"
HREF="guidethebasics.html"><LINK
REL="PREVIOUS"
TITLE="The Basics"
HREF="guidethebasics.html"><LINK
REL="NEXT"
TITLE="Graphics and Video"
HREF="guidevideo.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="guidethebasics.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
>Chapter 1. The Basics</TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="guidevideo.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="SECT1"
><H1
CLASS="SECT1"
><A
NAME="GUIDEBASICSINIT"
></A
>Initializing SDL</H1
><P
>SDL is composed of eight subsystems - Audio, CDROM, Event Handling, File I/O, Joystick Handling, Threading, Timers and Video. Before you can use any of these subsystems they must be initialized by calling <A
HREF="sdlinit.html"
><TT
CLASS="FUNCTION"
>SDL_Init</TT
></A
> (or <A
HREF="sdlinitsubsystem.html"
><TT
CLASS="FUNCTION"
>SDL_InitSubSystem</TT
></A
>). <TT
CLASS="FUNCTION"
>SDL_Init</TT
> must be called before any other SDL function. It automatically initializes the Event Handling, File I/O and Threading subsystems and it takes a parameter specifying which other subsystems to initialize. So, to initialize the default subsystems and the Video subsystems you would call:
<PRE
CLASS="PROGRAMLISTING"
> SDL_Init ( SDL_INIT_VIDEO );</PRE
>
To initialize the default subsystems, the Video subsystem and the Timers subsystem you would call:
<PRE
CLASS="PROGRAMLISTING"
> SDL_Init ( SDL_INIT_VIDEO | SDL_INIT_TIMER );</PRE
></P
><P
><TT
CLASS="FUNCTION"
>SDL_Init</TT
> is complemented by <A
HREF="sdlquit.html"
><TT
CLASS="FUNCTION"
>SDL_Quit</TT
></A
> (and <A
HREF="sdlquitsubsystem.html"
><TT
CLASS="FUNCTION"
>SDL_QuitSubSystem</TT
></A
>). <TT
CLASS="FUNCTION"
>SDL_Quit</TT
> shuts down all subsystems, including the default ones. It should always be called before a SDL application exits.</P
><P
>With <TT
CLASS="FUNCTION"
>SDL_Init</TT
> and <TT
CLASS="FUNCTION"
>SDL_Quit</TT
> firmly embedded in your programmers toolkit you can write your first and most basic SDL application. However, we must be prepare to handle errors. Many SDL functions return a value and indicates whether the function has succeeded or failed, <TT
CLASS="FUNCTION"
>SDL_Init</TT
>, for instance, returns -1 if it could not initialize a subsystem. SDL provides a useful facility that allows you to determine exactly what the problem was, every time an error occurs within SDL an error message is stored which can be retrieved using <TT
CLASS="FUNCTION"
>SDL_GetError</TT
>. Use this often, you can never know too much about an error.</P
><DIV
CLASS="EXAMPLE"
><A
NAME="AEN60"
></A
><P
><B
>Example 1-1. Initializing SDL</B
></P
><PRE
CLASS="PROGRAMLISTING"
>#include "SDL.h" /* All SDL App's need this */
#include &#60;stdio.h&#62;
int main(int argc, char *argv[]) {
printf("Initializing SDL.\n");
/* Initialize defaults, Video and Audio */
if((SDL_Init(SDL_INIT_VIDEO|SDL_INIT_AUDIO)==-1)) {
printf("Could not initialize SDL: %s.\n", SDL_GetError());
exit(-1);
}
printf("SDL initialized.\n");
printf("Quiting SDL.\n");
/* Shutdown all subsystems */
SDL_Quit();
printf("Quiting....\n");
exit(0);
}&#13;</PRE
></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="guidethebasics.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="guidevideo.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>The Basics</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="guidethebasics.html"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>Graphics and Video</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>
\ No newline at end of file
<HTML
><HEAD
><TITLE
>CDROM 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="Audio Examples"
HREF="guideaudioexamples.html"><LINK
REL="NEXT"
TITLE="Time Examples"
HREF="guidetimeexamples.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="guideaudioexamples.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="guidetimeexamples.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="SECT1"
><H1
CLASS="SECT1"
><A
NAME="GUIDECDROMEXAMPLES"
></A
>CDROM Examples</H1
><P
></P
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="AEN393"
></A
>Listing CD-ROM drives</H2
><P
><PRE
CLASS="PROGRAMLISTING"
> #include "SDL.h"
/* Initialize SDL first */
if ( SDL_Init(SDL_INIT_CDROM) &#60; 0 ) {
fprintf(stderr, "Couldn't initialize SDL: %s\n",SDL_GetError());
exit(1);
}
atexit(SDL_Quit);
/* Find out how many CD-ROM drives are connected to the system */
printf("Drives available: %d\n", SDL_CDNumDrives());
for ( i=0; i&#60;SDL_CDNumDrives(); ++i ) {
printf("Drive %d: \"%s\"\n", i, SDL_CDName(i));
}</PRE
></P
></DIV
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="AEN397"
></A
>Opening the default drive</H2
><P
><PRE
CLASS="PROGRAMLISTING"
> SDL_CD *cdrom;
CDstatus status;
char *status_str;
cdrom = SDL_CDOpen(0);
if ( cdrom == NULL ) {
fprintf(stderr, "Couldn't open default CD-ROM drive: %s\n",
SDL_GetError());
exit(2);
}
status = SDL_CDStatus(cdrom);
switch (status) {
case CD_TRAYEMPTY:
status_str = "tray empty";
break;
case CD_STOPPED:
status_str = "stopped";
break;
case CD_PLAYING:
status_str = "playing";
break;
case CD_PAUSED:
status_str = "paused";
break;
case CD_ERROR:
status_str = "error state";
break;
}
printf("Drive status: %s\n", status_str);
if ( status &#62;= CD_PLAYING ) {
int m, s, f;
FRAMES_TO_MSF(cdrom-&#62;cur_frame, &#38;m, &#38;s, &#38;f);
printf("Currently playing track %d, %d:%2.2d\n",
cdrom-&#62;track[cdrom-&#62;cur_track].id, m, s);
}</PRE
></P
></DIV
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="AEN401"
></A
>Listing the tracks on a CD</H2
><P
><PRE
CLASS="PROGRAMLISTING"
> SDL_CD *cdrom; /* Assuming this has already been set.. */
int i;
int m, s, f;
SDL_CDStatus(cdrom);
printf("Drive tracks: %d\n", cdrom-&#62;numtracks);
for ( i=0; i&#60;cdrom-&#62;numtracks; ++i ) {
FRAMES_TO_MSF(cdrom-&#62;track[i].length, &#38;m, &#38;s, &#38;f);
if ( f &#62; 0 )
++s;
printf("\tTrack (index %d) %d: %d:%2.2d\n", i,
cdrom-&#62;track[i].id, m, s);
}</PRE
></P
></DIV
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="AEN405"
></A
>Play an entire CD</H2
><P
><PRE
CLASS="PROGRAMLISTING"
> SDL_CD *cdrom; /* Assuming this has already been set.. */
// Play entire CD:
if ( CD_INDRIVE(SDL_CDStatus(cdrom)) )
SDL_CDPlayTracks(cdrom, 0, 0, 0, 0);
// Play last track:
if ( CD_INDRIVE(SDL_CDStatus(cdrom)) ) {
SDL_CDPlayTracks(cdrom, cdrom-&#62;numtracks-1, 0, 0, 0);
}
// Play first and second track and 10 seconds of third track:
if ( CD_INDRIVE(SDL_CDStatus(cdrom)) )
SDL_CDPlayTracks(cdrom, 0, 0, 2, CD_FPS * 10);</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="guideaudioexamples.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="guidetimeexamples.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>Audio 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"
>Time Examples</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>
\ No newline at end of file
<HTML
><HEAD
><TITLE
>Credits</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="About SDLdoc"
HREF="guideaboutsdldoc.html"><LINK
REL="NEXT"
TITLE="The Basics"
HREF="guidethebasics.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="guideaboutsdldoc.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
>Preface</TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="guidethebasics.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="SECT1"
><H1
CLASS="SECT1"
><A
NAME="GUIDECREDITS"
></A
>Credits</H1
><P
><P
></P
><TABLE
BORDER="0"
><TBODY
><TR
><TD
>Sam Lantinga, slouken@libsdl.org</TD
></TR
><TR
><TD
>Martin Donlon, akawaka@skynet.ie</TD
></TR
><TR
><TD
>Mattias Engdegrd</TD
></TR
><TR
><TD
>Julian Peterson</TD
></TR
><TR
><TD
>Ken Jordan</TD
></TR
><TR
><TD
>Maxim Sobolev</TD
></TR
><TR
><TD
>Wesley Poole</TD
></TR
><TR
><TD
>Michael Vance</TD
></TR
><TR
><TD
>Andreas Umbach</TD
></TR
><TR
><TD
>Andreas Hofmeister</TD
></TR
></TBODY
></TABLE
><P
></P
></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="guideaboutsdldoc.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="guidethebasics.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>About SDLdoc</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="guidepreface.html"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>The Basics</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>
\ No newline at end of file
<HTML
><HEAD
><TITLE
>Event 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="Examples"
HREF="guideexamples.html"><LINK
REL="NEXT"
TITLE="Audio Examples"
HREF="guideaudioexamples.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="guideexamples.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="guideaudioexamples.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="SECT1"
><H1
CLASS="SECT1"
><A
NAME="GUIDEEVENTEXAMPLES"
></A
>Event Examples</H1
><P
></P
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="AEN375"
></A
>Filtering and Handling Events</H2
><P
><PRE
CLASS="PROGRAMLISTING"
>#include &#60;stdio.h&#62;
#include &#60;stdlib.h&#62;
#include "SDL.h"
/* This function may run in a separate event thread */
int FilterEvents(const SDL_Event *event) {
static int boycott = 1;
/* This quit event signals the closing of the window */
if ( (event-&#62;type == SDL_QUIT) &#38;&#38; boycott ) {
printf("Quit event filtered out -- try again.\n");
boycott = 0;
return(0);
}
if ( event-&#62;type == SDL_MOUSEMOTION ) {
printf("Mouse moved to (%d,%d)\n",
event-&#62;motion.x, event-&#62;motion.y);
return(0); /* Drop it, we've handled it */
}
return(1);
}
int main(int argc, char *argv[])
{
SDL_Event event;
/* Initialize the SDL library (starts the event loop) */
if ( SDL_Init(SDL_INIT_VIDEO) &#60; 0 ) {
fprintf(stderr,
"Couldn't initialize SDL: %s\n", SDL_GetError());
exit(1);
}
/* Clean up on exit, exit on window close and interrupt */
atexit(SDL_Quit);
/* Ignore key events */
SDL_EventState(SDL_KEYDOWN, SDL_IGNORE);
SDL_EventState(SDL_KEYUP, SDL_IGNORE);
/* Filter quit and mouse motion events */
SDL_SetEventFilter(FilterEvents);
/* The mouse isn't much use unless we have a display for reference */
if ( SDL_SetVideoMode(640, 480, 8, 0) == NULL ) {
fprintf(stderr, "Couldn't set 640x480x8 video mode: %s\n",
SDL_GetError());
exit(1);
}
/* Loop waiting for ESC+Mouse_Button */
while ( SDL_WaitEvent(&#38;event) &#62;= 0 ) {
switch (event.type) {
case SDL_ACTIVEEVENT: {
if ( event.active.state &#38; SDL_APPACTIVE ) {
if ( event.active.gain ) {
printf("App activated\n");
} else {
printf("App iconified\n");
}
}
}
break;
case SDL_MOUSEBUTTONDOWN: {
Uint8 *keys;
keys = SDL_GetKeyState(NULL);
if ( keys[SDLK_ESCAPE] == SDL_PRESSED ) {
printf("Bye bye...\n");
exit(0);
}
printf("Mouse button pressed\n");
}
break;
case SDL_QUIT: {
printf("Quit requested, quitting.\n");
exit(0);
}
break;
}
}
/* This should never happen */
printf("SDL_WaitEvent error: %s\n", SDL_GetError());
exit(1);
}</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="guideexamples.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="guideaudioexamples.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>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"
>Audio Examples</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>
\ No newline at end of file
<HTML
><HEAD
><TITLE
>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="SDL Guide"
HREF="guide.html"><LINK
REL="PREVIOUS"
TITLE="Handling the Keyboard"
HREF="guideinputkeyboard.html"><LINK
REL="NEXT"
TITLE="Event Examples"
HREF="guideeventexamples.html"></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="guideinputkeyboard.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="guideeventexamples.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="CHAPTER"
><H1
><A
NAME="GUIDEEXAMPLES"
></A
>Chapter 4. Examples</H1
><DIV
CLASS="TOC"
><DL
><DT
><B
>Table of Contents</B
></DT
><DT
><A
HREF="guideexamples.html#AEN369"
>Introduction</A
></DT
><DT
><A
HREF="guideeventexamples.html"
>Event Examples</A
></DT
><DT
><A
HREF="guideaudioexamples.html"
>Audio Examples</A
></DT
><DT
><A
HREF="guidecdromexamples.html"
>CDROM Examples</A
></DT
><DT
><A
HREF="guidetimeexamples.html"
>Time Examples</A
></DT
></DL
></DIV
><DIV
CLASS="SECT1"
><H1
CLASS="SECT1"
><A
NAME="AEN369"
></A
>Introduction</H1
><P
>For the moment these examples are taken directly from the old SDL documentation. By the 1.2 release these examples should hopefully deal with most common SDL programming problems.</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="guideinputkeyboard.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="guideeventexamples.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>Handling the Keyboard</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="guide.html"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>Event Examples</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>
\ No newline at end of file
<HTML
><HEAD
><TITLE
>Preface</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 Guide"
HREF="guide.html"><LINK
REL="PREVIOUS"
TITLE="SDL Guide"
HREF="guide.html"><LINK
REL="NEXT"
TITLE="About SDLdoc"
HREF="guideaboutsdldoc.html"></HEAD
><BODY
CLASS="PREFACE"
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="guide.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="guideaboutsdldoc.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="PREFACE"
><H1
><A
NAME="GUIDEPREFACE"
></A
>Preface</H1
><DIV
CLASS="TOC"
><DL
><DT
><B
>Table of Contents</B
></DT
><DT
><A
HREF="guidepreface.html#GUIDEABOUTSDL"
>About SDL</A
></DT
><DT
><A
HREF="guideaboutsdldoc.html"
>About SDLdoc</A
></DT
><DT
><A
HREF="guidecredits.html"
>Credits</A
></DT
></DL
></DIV
><DIV
CLASS="SECT1"
><H1
CLASS="SECT1"
><A
NAME="GUIDEABOUTSDL"
></A
>About SDL</H1
><P
>The SDL library is designed to make it easy to write games that run on Linux, *BSD, MacOS, Win32 and BeOS using the various native high-performance media interfaces, (for video, audio, etc) and presenting a single source-code level API to your application. SDL is a fairly low level API, but using it, completely portable applications can be written with a great deal of flexibility.</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="guide.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="guideaboutsdldoc.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>SDL Guide</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="guide.html"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>About SDLdoc</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>
\ No newline at end of file
<HTML
><HEAD
><TITLE
>The Basics</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 Guide"
HREF="guide.html"><LINK
REL="PREVIOUS"
TITLE="Credits"
HREF="guidecredits.html"><LINK
REL="NEXT"
TITLE="Initializing SDL"
HREF="guidebasicsinit.html"></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="guidecredits.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="guidebasicsinit.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="CHAPTER"
><H1
><A
NAME="GUIDETHEBASICS"
></A
>Chapter 1. The Basics</H1
><DIV
CLASS="TOC"
><DL
><DT
><B
>Table of Contents</B
></DT
><DT
><A
HREF="guidethebasics.html#GUIDEINTRODUCTION"
>Introduction</A
></DT
><DT
><A
HREF="guidebasicsinit.html"
>Initializing SDL</A
></DT
></DL
></DIV
><DIV
CLASS="SECT1"
><H1
CLASS="SECT1"
><A
NAME="GUIDEINTRODUCTION"
></A
>Introduction</H1
><P
>The SDL Guide section is pretty incomplete. If you feel you have anything to add mail akawaka@skynet.ie or visit http://akawaka.csn.ul.ie/tne/.</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="guidecredits.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="guidebasicsinit.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>Credits</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="guide.html"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>Initializing SDL</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>
\ No newline at end of file
<HTML
><HEAD
><TITLE
>Time 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="CDROM Examples"
HREF="guidecdromexamples.html"><LINK
REL="NEXT"
TITLE="SDL Reference"
HREF="reference.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="guidecdromexamples.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="reference.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="SECT1"
><H1
CLASS="SECT1"
><A
NAME="GUIDETIMEEXAMPLES"
></A
>Time Examples</H1
><P
></P
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="AEN412"
></A
>Time based game loop</H2
><P
><PRE
CLASS="PROGRAMLISTING"
>#define TICK_INTERVAL 30
static Uint32 next_time;
Uint32 time_left(void)
{
Uint32 now;
now = SDL_GetTicks();
if(next_time &#60;= now)
return 0;
else
return next_time - now;
}
/* main game loop */
next_time = SDL_GetTicks() + TICK_INTERVAL;
while ( game_running ) {
update_game_state();
SDL_Delay(time_left());
next_time += TICK_INTERVAL;
}&#13;</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="guidecdromexamples.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="reference.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>CDROM 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"
>SDL Reference</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>
\ No newline at end of file
<HTML
><HEAD
><TITLE
>Graphics and Video</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 Guide"
HREF="guide.html"><LINK
REL="PREVIOUS"
TITLE="Initializing SDL"
HREF="guidebasicsinit.html"><LINK
REL="NEXT"
TITLE="Using OpenGL With SDL"
HREF="guidevideoopengl.html"></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="guidebasicsinit.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="guidevideoopengl.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="CHAPTER"
><H1
><A
NAME="GUIDEVIDEO"
></A
>Chapter 2. Graphics and Video</H1
><DIV
CLASS="TOC"
><DL
><DT
><B
>Table of Contents</B
></DT
><DT
><A
HREF="guidevideo.html#GUIDEVIDEOINTRO"
>Introduction to SDL Video</A
></DT
><DT
><A
HREF="guidevideoopengl.html"
>Using OpenGL With SDL</A
></DT
></DL
></DIV
><DIV
CLASS="SECT1"
><H1
CLASS="SECT1"
><A
NAME="GUIDEVIDEOINTRO"
></A
>Introduction to SDL Video</H1
><P
>Video is probably the most common thing that SDL is used for, and
so it has the most complete subsystem. Here are a few
examples to demonstrate the basics.</P
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="AEN68"
></A
>Initializing the Video Display</H2
><P
>This is what almost all SDL programs have to do in one way or
another.</P
><DIV
CLASS="EXAMPLE"
><A
NAME="AEN71"
></A
><P
><B
>Example 2-1. Initializing the Video Display</B
></P
><PRE
CLASS="PROGRAMLISTING"
> SDL_Surface *screen;
/* Initialize the SDL library */
if( SDL_Init(SDL_INIT_VIDEO) &#60; 0 ) {
fprintf(stderr,
"Couldn't initialize SDL: %s\n", SDL_GetError());
exit(1);
}
/* Clean up on exit */
atexit(SDL_Quit);
/*
* Initialize the display in a 640x480 8-bit palettized mode,
* requesting a software surface
*/
screen = SDL_SetVideoMode(640, 480, 8, SDL_SWSURFACE);
if ( screen == NULL ) {
fprintf(stderr, "Couldn't set 640x480x8 video mode: %s\n",
SDL_GetError());
exit(1);
}</PRE
></DIV
></DIV
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="AEN74"
></A
>Initializing the Best Video Mode</H2
><P
>If you have a preference for a certain pixel depth but will accept any
other, use SDL_SetVideoMode with SDL_ANYFORMAT as below. You can also
use SDL_VideoModeOK() to find the native video mode that is closest to
the mode you request.</P
><DIV
CLASS="EXAMPLE"
><A
NAME="AEN77"
></A
><P
><B
>Example 2-2. Initializing the Best Video Mode</B
></P
><PRE
CLASS="PROGRAMLISTING"
> /* Have a preference for 8-bit, but accept any depth */
screen = SDL_SetVideoMode(640, 480, 8, SDL_SWSURFACE|SDL_ANYFORMAT);
if ( screen == NULL ) {
fprintf(stderr, "Couldn't set 640x480x8 video mode: %s\n",
SDL_GetError());
exit(1);
}
printf("Set 640x480 at %d bits-per-pixel mode\n",
screen-&#62;format-&#62;BitsPerPixel);</PRE
></DIV
></DIV
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="AEN80"
></A
>Loading and Displaying a BMP File</H2
><P
>The following function loads and displays a BMP file given as
argument, once SDL is initialised and a video mode has been set.</P
><DIV
CLASS="EXAMPLE"
><A
NAME="AEN83"
></A
><P
><B
>Example 2-3. Loading and Displaying a BMP File</B
></P
><PRE
CLASS="PROGRAMLISTING"
>void display_bmp(char *file_name)
{
SDL_Surface *image;
/* Load the BMP file into a surface */
image = SDL_LoadBMP(file_name);
if (image == NULL) {
fprintf(stderr, "Couldn't load %s: %s\n", file_name, SDL_GetError());
return;
}
/*
* Palettized screen modes will have a default palette (a standard
* 8*8*4 colour cube), but if the image is palettized as well we can
* use that palette for a nicer colour matching
*/
if (image-&#62;format-&#62;palette &#38;&#38; screen-&#62;format-&#62;palette) {
SDL_SetColors(screen, image-&#62;format-&#62;palette-&#62;colors, 0,
image-&#62;format-&#62;palette-&#62;ncolors);
}
/* Blit onto the screen surface */
if(SDL_BlitSurface(image, NULL, screen, NULL) &#60; 0)
fprintf(stderr, "BlitSurface error: %s\n", SDL_GetError());
SDL_UpdateRect(screen, 0, 0, image-&#62;w, image-&#62;h);
/* Free the allocated BMP surface */
SDL_FreeSurface(image);
}</PRE
></DIV
></DIV
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="AEN86"
></A
>Drawing Directly to the Display</H2
><P
>The following two functions can be used to get and set single
pixels of a surface. They are carefully written to work with any depth
currently supported by SDL. Remember to lock the surface before
calling them, and to unlock it before calling any other SDL
functions.</P
><P
>To convert between pixel values and their red, green, blue
components, use SDL_GetRGB() and SDL_MapRGB().</P
><DIV
CLASS="EXAMPLE"
><A
NAME="AEN90"
></A
><P
><B
>Example 2-4. getpixel()</B
></P
><PRE
CLASS="PROGRAMLISTING"
>/*
* Return the pixel value at (x, y)
* NOTE: The surface must be locked before calling this!
*/
Uint32 getpixel(SDL_Surface *surface, int x, int y)
{
int bpp = surface-&#62;format-&#62;BytesPerPixel;
/* Here p is the address to the pixel we want to retrieve */
Uint8 *p = (Uint8 *)surface-&#62;pixels + y * surface-&#62;pitch + x * bpp;
switch(bpp) {
case 1:
return *p;
case 2:
return *(Uint16 *)p;
case 3:
if(SDL_BYTEORDER == SDL_BIG_ENDIAN)
return p[0] &#60;&#60; 16 | p[1] &#60;&#60; 8 | p[2];
else
return p[0] | p[1] &#60;&#60; 8 | p[2] &#60;&#60; 16;
case 4:
return *(Uint32 *)p;
default:
return 0; /* shouldn't happen, but avoids warnings */
}
}</PRE
></DIV
><DIV
CLASS="EXAMPLE"
><A
NAME="AEN93"
></A
><P
><B
>Example 2-5. putpixel()</B
></P
><PRE
CLASS="PROGRAMLISTING"
>/*
* Set the pixel at (x, y) to the given value
* NOTE: The surface must be locked before calling this!
*/
void putpixel(SDL_Surface *surface, int x, int y, Uint32 pixel)
{
int bpp = surface-&#62;format-&#62;BytesPerPixel;
/* Here p is the address to the pixel we want to set */
Uint8 *p = (Uint8 *)surface-&#62;pixels + y * surface-&#62;pitch + x * bpp;
switch(bpp) {
case 1:
*p = pixel;
break;
case 2:
*(Uint16 *)p = pixel;
break;
case 3:
if(SDL_BYTEORDER == SDL_BIG_ENDIAN) {
p[0] = (pixel &#62;&#62; 16) &#38; 0xff;
p[1] = (pixel &#62;&#62; 8) &#38; 0xff;
p[2] = pixel &#38; 0xff;
} else {
p[0] = pixel &#38; 0xff;
p[1] = (pixel &#62;&#62; 8) &#38; 0xff;
p[2] = (pixel &#62;&#62; 16) &#38; 0xff;
}
break;
case 4:
*(Uint32 *)p = pixel;
break;
}
}</PRE
></DIV
><P
>The following code uses the putpixel() function above to set a
yellow pixel in the middle of the screen.</P
><DIV
CLASS="EXAMPLE"
><A
NAME="AEN97"
></A
><P
><B
>Example 2-6. Using putpixel()</B
></P
><PRE
CLASS="PROGRAMLISTING"
>&#13; /* Code to set a yellow pixel at the center of the screen */
int x, y;
Uint32 yellow;
/* Map the color yellow to this display (R=0xff, G=0xFF, B=0x00)
Note: If the display is palettized, you must set the palette first.
*/
yellow = SDL_MapRGB(screen-&#62;format, 0xff, 0xff, 0x00);
x = screen-&#62;w / 2;
y = screen-&#62;h / 2;
/* Lock the screen for direct access to the pixels */
if ( SDL_MUSTLOCK(screen) ) {
if ( SDL_LockSurface(screen) &#60; 0 ) {
fprintf(stderr, "Can't lock screen: %s\n", SDL_GetError());
return;
}
}
putpixel(screen, x, y, yellow);
if ( SDL_MUSTLOCK(screen) ) {
SDL_UnlockSurface(screen);
}
/* Update just the part of the display that we've changed */
SDL_UpdateRect(screen, x, y, 1, 1);
return;&#13;</PRE
></DIV
></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="guidebasicsinit.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="guidevideoopengl.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>Initializing SDL</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="guide.html"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>Using OpenGL With SDL</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>
\ No newline at end of file
<HTML
><HEAD
><TITLE
>Joystick</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_JoystickEventState"
HREF="sdljoystickeventstate.html"><LINK
REL="NEXT"
TITLE="SDL_NumJoysticks"
HREF="sdlnumjoysticks.html"><META
NAME="KEYWORD"
CONTENT="joystick"><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="sdljoystickeventstate.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="sdlnumjoysticks.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="CHAPTER"
><H1
><A
NAME="JOYSTICK"
></A
>Chapter 9. Joystick</H1
><DIV
CLASS="TOC"
><DL
><DT
><B
>Table of Contents</B
></DT
><DT
><A
HREF="sdlnumjoysticks.html"
>SDL_NumJoysticks</A
>&nbsp;--&nbsp;Count available joysticks.</DT
><DT
><A
HREF="sdljoystickname.html"
>SDL_JoystickName</A
>&nbsp;--&nbsp;Get joystick name.</DT
><DT
><A
HREF="sdljoystickopen.html"
>SDL_JoystickOpen</A
>&nbsp;--&nbsp;Opens a joystick for use.</DT
><DT
><A
HREF="sdljoystickopened.html"
>SDL_JoystickOpened</A
>&nbsp;--&nbsp;Determine if a joystick has been opened</DT
><DT
><A
HREF="sdljoystickindex.html"
>SDL_JoystickIndex</A
>&nbsp;--&nbsp;Get the index of an SDL_Joystick.</DT
><DT
><A
HREF="sdljoysticknumaxes.html"
>SDL_JoystickNumAxes</A
>&nbsp;--&nbsp;Get the number of joystick axes</DT
><DT
><A
HREF="sdljoysticknumballs.html"
>SDL_JoystickNumBalls</A
>&nbsp;--&nbsp;Get the number of joystick trackballs</DT
><DT
><A
HREF="sdljoysticknumhats.html"
>SDL_JoystickNumHats</A
>&nbsp;--&nbsp;Get the number of joystick hats</DT
><DT
><A
HREF="sdljoysticknumbuttons.html"
>SDL_JoystickNumButtons</A
>&nbsp;--&nbsp;Get the number of joysitck buttons</DT
><DT
><A
HREF="sdljoystickupdate.html"
>SDL_JoystickUpdate</A
>&nbsp;--&nbsp;Updates the state of all joysticks</DT
><DT
><A
HREF="sdljoystickgetaxis.html"
>SDL_JoystickGetAxis</A
>&nbsp;--&nbsp;Get the current state of an axis</DT
><DT
><A
HREF="sdljoystickgethat.html"
>SDL_JoystickGetHat</A
>&nbsp;--&nbsp;Get the current state of a joystick hat</DT
><DT
><A
HREF="sdljoystickgetbutton.html"
>SDL_JoystickGetButton</A
>&nbsp;--&nbsp;Get the current state of a given button on a given joystick</DT
><DT
><A
HREF="sdljoystickgetball.html"
>SDL_JoystickGetBall</A
>&nbsp;--&nbsp;Get relative trackball motion</DT
><DT
><A
HREF="sdljoystickclose.html"
>SDL_JoystickClose</A
>&nbsp;--&nbsp;Closes a previously opened joystick</DT
></DL
></DIV
><P
>Joysticks, and other similar input devices, have a very strong role in game playing and SDL provides comprehensive support for them. Axes, Buttons, POV Hats and trackballs are all supported.</P
><P
>Joystick support is initialized by passed the <TT
CLASS="LITERAL"
>SDL_INIT_JOYSTICK</TT
> flag to <A
HREF="sdlinit.html"
><TT
CLASS="FUNCTION"
>SDL_Init</TT
></A
>. Once initilized joysticks must be opened using <A
HREF="sdljoystickopen.html"
><TT
CLASS="FUNCTION"
>SDL_JoystickOpen</TT
></A
>.</P
><P
>While using the functions describe in this secton may seem like the best way to access and read from joysticks, in most cases they aren't. Ideally joysticks should be read using the <A
HREF="event.html"
>event</A
> system. To enable this, you must set the joystick event processing state with <A
HREF="sdljoystickeventstate.html"
><TT
CLASS="FUNCTION"
>SDL_JoystickEventState</TT
></A
>. Joysticks must be <A
HREF="sdljoystickopen.html"
>opened</A
> before they can be used of course.</P
><DIV
CLASS="NOTE"
><BLOCKQUOTE
CLASS="NOTE"
><P
><B
>Note: </B
>If you are <SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
>not</I
></SPAN
> handling the joystick via the event queue then you must explicitly request a joystick update by calling <A
HREF="sdljoystickupdate.html"
><TT
CLASS="FUNCTION"
>SDL_JoystickUpdate</TT
></A
>.</P
></BLOCKQUOTE
></DIV
><DIV
CLASS="NOTE"
><BLOCKQUOTE
CLASS="NOTE"
><P
><B
>Note: </B
>Force Feedback is not yet support. Sam (slouken@libsdl.org) is soliciting suggestions from people with force-feedback experience on the best wat to desgin the API.</P
></BLOCKQUOTE
></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="sdljoystickeventstate.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="sdlnumjoysticks.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>SDL_JoystickEventState</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_NumJoysticks</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
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