Frequently Asked Questions - Linux
Last updated:
Mon Oct 23
Table Of Contents
Q:
Does it work?
A:
Yes. SDL supports glibc systems with kernel version 2.0+
Q:
How do I add SDL to my project?
A:
The short answer is use the output of the command "sdl-config --cflags --libs"
For example: gcc -o test test.c `sdl-config --cflags --libs`
If you are using home-grown Makefiles for your project, you can get the
proper CFLAGS and LDFLAGS for SDL by adding the following lines to your
Makefile:
SDL_CFLAGS := $(shell sdl-config --cflags)
SDL_LDFLAGS := $(shell sdl-config --libs)
If you are using autoconf and automake for your project, you can copy
the contents of 'sdl.m4' into your acinclude.m4 file, and then add the
following to your configure.in file:
dnl Check for SDL
SDL_VERSION=1.0.0
AM_PATH_SDL($SDL_VERSION,
:,
AC_MSG_ERROR([*** SDL version $SDL_VERSION not found!])
)
CFLAGS="$CFLAGS $SDL_CFLAGS"
LIBS="$LIBS $SDL_LIBS"
Q:
I installed the SDL RPM, but can't compile SDL applications
A:
You need to install the SDL-devel RPM, available from:
http://www.libsdl.org/download.html
Q:
I installed SDL from source but can't build or run SDL applications
A:
Edit the file /etc/ld.so.conf, and make sure it contains the line:
/usr/local/lib
As root, run /sbin/ldconfig
Make sure /usr/local/bin is in your execution path:
export PATH=$PATH:/usr/local/bin/
Q:
Will svaglib, fbcon, glide, GGI, MGL, as a back-end be supported?
A:
-
SVGAlib, GGI and AAlib are supported as of SDL version 1.1.
-
fbcon is supported as of SDL version 1.0.
-
SDL 1.1 has support for OpenGL, but you can not use the SDL 2D video functions
like SDL_BlitSurface() with a display surface created for OpenGL use.
-
MGL may be supported, eventually.
-
If you want to add the backend support for a particular API, take a look at
SDL_sysvideo.h, as it contains the internal functions you need to implement.
Also take a look at the other functional back-ends to see how a working
implementation could be written. I've designed it so adding a back-end
should be relatively straight-forward, it just takes a little time.
Q:
How do I set an environment variable?
A:
How to set an environment variable depends on your login shell:
For Bourne shell derivatives: (sh, ash, ksh, zsh, bash, etc.)
VARIABLE='value'; export VARIABLE
For C shell derivatives: (csh, tcsh, etc.)
setenv VARIABLE 'value'
Q:
I get the error: "no video devices available"
A:
SDL doesn't use the X11 video driver if it can't open the X display,
and if no other drivers are available, it will report this error.
To fix this, set your display environment variable appropriately:
sh: DISPLAY=:0 ; export DISPLAY
csh: setenv DISPLAY :0
If you still have problems, try running xhost + localhost
Q:
How do I disable framebuffer console acceleration?
A:
As of SDL 1.0.3, you can
set the environment variable
SDL_FBACCEL to "0".
Q:
How do I enable DMA audio support?
A:
As of SDL 1.0.4, you can set
set the environment variable
SDL_AUDIODRIVER to "dma".
Q:
How do I turn off DGA mouse support?
A:
As of SDL 1.0.8, you can
set the environment variable
SDL_VIDEO_X11_DGAMOUSE to "0".
Q:
How do I enable X11 mouse acceleration?
A:
As of SDL 1.0.8, you can
set the environment variable
SDL_VIDEO_X11_MOUSEACCEL to "X/Y", where 'X' is the numerator
and 'Y' is the denomenator of the mouse acceleration. For example, if you
wanted to set mouse acceleration to 2, you would set the variable to "2/1".
By default SDL does not change the current X11 mouse acceleration.
Q:
How do I tell SDL to default to AALib?
A:
Building SDL: make distclean; ./configure --enable-video-aalib ; make install
Running your app:
set the environment variable
SDL_VIDEODRIVER to "aalib".
Q:
How do I tell SDL to use the DGA 2.0 video driver?
A:
You need a version of SDL that has DGA built in - this includes SDL 1.1.5
either in binary form, downloaded from the SDL website, or built on a system
that has XFree86 4.0. Then make sure that you have XFree86 4.01 or newer,
run the program as root,
set the environment variable
SDL_VIDEODRIVER to "dga", and use a card like the Voodoo 3000, Matrox G400,
or any other card with a decent DGA driver.
Q:
How do I move the SDL window in my program?
A:
Here is some code used by SMPEG's gtv to center the window:
#include "SDL_syswm.h"
static void gtv_center_window(SDL_Surface *screen)
{
SDL_SysWMinfo info;
SDL_VERSION(&info.version);
if ( SDL_GetWMInfo(&info) > 0 ) {
int x, y;
int w, h;
#ifdef unix
if ( info.subsystem == SDL_SYSWM_X11 ) {
info.info.x11.lock_func();
w = DisplayWidth(info.info.x11.display,
DefaultScreen(info.info.x11.display));
h = DisplayHeight(info.info.x11.display,
DefaultScreen(info.info.x11.display));
x = (w - screen->w)/2;
y = (h - screen->h)/2;
XMoveWindow(info.info.x11.display, info.info.x11.wmwindow, x, y);
info.info.x11.unlock_func();
}
#else
#warning Need to implement these functions for other systems
#endif // unix
}
}
Q:
I get the error: "SDL: Audio timeout - buggy audio driver? (disabled)"
A:
Some audio drivers don't properly implement select(). The Aureal cards
have this problem, but some people have had luck with the latest CVS
drivers available from:
http://sourceforge.net/projects/aureal/
I added a hack to approximate the timing using timing functions,
and you can enabled this by
setting the environment variable
SDL_DSP_NOSELECT to "1".
You can also use ESounD as a high-latency sound server.
Q:
How do I enable XFree86 XVideo acceleration?
A:
If SDL is built with XFree86 4.0 or newer, it will automatically detect
and use XVideo hardware acceleration for YUV video playback.
XFree86 versions earlier than 4.0.2 have a bug which requires you to
set the environment variable
SDL_VIDEO_X11_NODIRECTCOLOR to "1" in order to get XVideo
acceleration. Since this disables SDL gamma correction, it is recommended
that you not do this in general.
Q:
How do I disable XFree86 XVideo acceleration?
A:
You can disable all YUV hardware acceleration by
setting the environment variable
SDL_VIDEO_YUV_HWACCEL to "0".
Q:
When I specify SDL_FULLSCREEN in X11, the screen goes black and my window
is centered in the middle, instead of covering the whole screen!
A:
X needs to be able to switch to the desired resolution. For this to
work, you need to have the resolution listed in the 'Modes' line in your
XFree86Config file (and your Monitor must support it). SDL does not
currently support changing resolutions on X servers that do not support
the XVidMode extension.
The following example is taken from my config for XFree86-4.0.1, but
3.3.x is similiar. Note that if your monitor isn't capable of using
these video modes, the X server will drop these modes from the list
of available video modes.
Example:
Section "Screen"
Identifier "Screen 1"
Device "3dfx"
Monitor "Samsung LCD"
DefaultDepth 16
Subsection "Display"
Depth 8
Modes "1280x1024" "1024x768" "800x600" "640x480" "320x240"
ViewPort 0 0
EndSubsection
Subsection "Display"
Depth 16
Modes "1280x1024" "1024x768" "800x600" "640x480"
ViewPort 0 0
EndSubsection
EndSection
Note the different entries for 8 & 16 bit screendepth. I.e. the
320x240 resolution is *not* available when X is started with 16bit
depth (the default).
To test these entries, restart X after you modified XF86Config and
press ctrl-alt-plus and ctrl-alt-minus to cycle through the resolutions.
-- contributed by Andreas Umbach
Q:
I'm running SuSE 7.0 and SDL apps hang on startup!
A:
SuSE 7.0 ships broken versions of the X11 libraries. You can either use
precompiled binaries of SDL, or upgrade your X11 installation to XFree86 4.0.2
|