Table Of Contents
Q:
What is it?
A:
Very simply, SDL is a library that allows you portable low level access
to a video framebuffer, audio output, mouse, and keyboard.
Q:
What is the latest version?
A:
SDL has been split into two versions:
The latest stable version, which should be used for release code, is
1.0
The latest development version, which is experimental and
not available yet.
You can always get the very latest bleeding edge CVS release, which may
be broken at any given time, from the
CVS page.
Q:
Where can I get it?
A:
http://www.libsdl.org/
Q:
What is the different between SDL 1.0 and 1.2?
A:
SDL 1.2 is the latest stable version of SDL.
SDL 1.2 has support for joysticks and for OpenGL, as well as official support
for MacOS. SDL 1.2 is mostly source compatible, but not binary compatible
with SDL 1.0 - this means that if you recompile your SDL 1.0 application
with SDL 1.2, it will probably work.
Q:
What's up with SDL 1.3? Can I help?
A:
SDL 1.3 will be a near full rewrite of the SDL functionality, based on what
we've learned over the past four years. The architecture design is partially
done, and we'll start prototyping the design soon. As soon as there's a
working framework, we'll make it publicly available for comment and
contributions. This new framework has about a year or a year and a half
before we anticipate it being ready for stable release. We anticipate
this framework being the next generation SDL 2.0 API.
In the meantime, enjoy the current stable release: SDL 1.2
Q:
Can I use SDL in a commercial application?
A:
The simple answer is "Yes", just dynamically link with SDL and you're fine.
Full details are available at:
http://www.libsdl.org/license.html
Q:
Can I use code from the test directory? From the examples?
A:
Yes, code from the test directory and from the examples in the documentation
is placed in the public domain. Anyone can use it for any purpose.
Q:
Can I use code from the demos in my applications?
A:
Each of the demos has it's own licensing restrictions. See the
"COPYING" file in the demo source directory for more
information on a particular demo.
Q:
How do I choose a specific audio driver?
A:
You can set the environment variable "SDL_AUDIODRIVER" to the name of the
driver you want to use. The drivers available depend on the platform and
SDL compile-time options:
- Linux:
- dsp - (default) Use the OSS API by opening /dev/dsp
- dma - Use the OSS API to perform DMA access on /dev/dsp
- esd - Connect to the ESound audio daemon
- Win32:
- dsound - (default) Use the DirectSound API
- waveout - Use the Win32 MultiMedia API
Q:
How do I choose a specific video driver?
A:
You can set the environment variable "SDL_VIDEODRIVER" to the name of the
driver you want to use. The drivers available depend on the platform and
SDL compile-time options:
- Linux:
- x11 - (default) Use the X11 windowing system
- fbcon - Use the framebuffer console
- svgalib - Use the SVGAlib API
- ggi - Use the General Graphics Interface API
- aalib - Use the Ascii Art library
- Win32:
- directx - (default) Use the DirectDraw API
- windib - Use the standard Win32 GDI
Q:
Is SDL multi-threaded?
A:
SDL provides simple cross-platform functions for the creation of threads
and synchronization using mutexes. These are used internally by SDL for
some implementations of the audio subsystem and input handling.
Q:
Does SDL support 3D acceleration?
A:
Yes, as of version 1.1.0, SDL has full support for the OpenGL API.
Q:
Does SDL support joysticks?
A:
Yes, as of version 1.1.0, SDL has full support for joysticks.
Q:
Does SDL support networking?
A:
Networking is outside of the scope of SDL, but due to popular demand
I wrote a simple cross-platform sockets wrapper which is available at
the SDL
libraries page. A simple chat client/server is included which
makes use of an example GUI library as well.
Q:
Does SDL support JPG, PNG, etc...
A:
The BMP and WAV file loaders included with SDL are simple examples
demonstrating how to load an image and sound format. You should be
able to write your own reader for any format. The main library is
suppose to be fast and small, and so does not include any additional
loaders.
A sample image loader library is available from the
SDL
libraries page which supports loading BMP, PCX, GIF, JPG, and
PNG images to SDL surfaces.
Q:
Does SDL have text drawing support?
A:
Games and operating systems vary widely in the type and availability
of text drawing facilities. Instead of trying to deal with this in the
core SDL library, there are several text drawing libraries designed for
use with SDL on the SDL libraries page. Common tecniques include using bitmap fonts,
truetype fonts, and custom images for text.
Q:
What kind of GUI's are there for SDL?
A:
There are several GUI libraries available from the
SDL
libraries page.
There is also a demo on the
SDL demos page
of using GTk natively with SDL, which works really well for graphics output.
Also on the
demos page
is a hack written by Kent Mein using Tcl/Tk with SDL.
You may also be able to get other GUI's to work with SDL. Many of them
have documentation on how to get the toolkits to work with other
applications.
Q:
What is video surface "pitch"?
A:
Pitch refers to the number of bytes in a row of pixels. This can differ
from the width in pixels times the number of bytes per pixel, because of
various alignment restrictions. Here is a common method of copying pixels
between surfaces of the same size:
void CopyPixels(SDL_Surface *src, SDL_Surface *dst)
{
Uint8 *srcp, *dstp;
int w, h;
if ( (src->w != dst->w) || (src->h != dst->h) ||
(src->format->BytesPerPixel != dst->format->BytesPerPixel) ) {
/* Different sized surfaces... */
return;
}
srcp = (Uint8 *)src->pixels;
dstp = (Uint8 *)dst->pixels;
h = src->h;
w = src->w*src->format->BytesPerPixel; /* Width in bytes */
while ( h-- ) {
memcpy(dstp, srcp, w);
srcp += src->pitch; /* Not necessarily 'w' */
dstp += dst->pitch; /* Not necessarily src->pitch */
}
}
Note in particular that even though the surfaces are the same width height
and depth, they may have differing pitches, and you should not write into
a scanline past (width*bytesperpixel) bytes.
Q:
Do I #include <SDL.h> or <SDL/SDL.h>?
A:
The most portable way to include SDL headers is to use quotes around the
header name:
#include "SDL.h"
Q:
I have an accelerated video card, but SDL tells me that that I have
zero video memory and no acceleration!
A:
Not all display targets can make use of hardware acceleration.
In particular, this is the case for the X11 target which always
presents you with a software framebuffer. Your video memory will always
be reported to be zero if no acceleration is available.