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.
No, most graphics back ends are not thread-safe, so you should only call SDL video functions from the main thread of your application.
Yes, SDL supports 3D acceleration:
- You can use the OpenGL API or the Direct3D API in combination with SDL, for 2D and 3D graphics.
- Alternatively, you can use SDL's 2D accelerated render API using SDL_Texture for pure 2D graphics which itself uses either OpenGL or Direct3D for acceleration (but it is easier to use than OpenGL/Direct3D directly and you get support for both for free).
Networking is outside of the scope of SDL, but due to popular demand a simple cross-platform sockets wrapper called "SDL_net" is available at the SDL libraries page. A simple chat client/server is included which makes use of an example GUI library as well.
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 supposed to be fast and small, and so does not include any additional loaders. A sample image loader library called "SDL_image" is available from the SDL libraries page which supports loading BMP, PCX, GIF, JPG, PNG and TGA images to SDL surfaces.
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 supposed to be fast and small, and so does not include any additional loaders. A sample sound library called "SDL_sound" is available from the SDL libraries page which supports loading many different audio formats.
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 techniques include using bitmap fonts, truetype fonts, and custom images for text.
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 GUIs to work with SDL. Many of them have documentation on how to get the toolkits to work with other applications.
The most portable way to include SDL headers is to use quotes around the header name:
<syntaxhighlight lang="c">
- include "SDL.h"
You need to turn on the "enums as ints" option for your compiler:
- For the free Borland compiler, add this command line option: -b
- For Watcom C/C++, add this command line option: -ei
- For Apple's MPW environment, add this command line option: -enum int
- For CodeWarrior, go to the C/C++ Language settings menu for your project and check the "Enums Always Int" box.
I have an accelerated video card, but SDL tells me that I have zero video memory and no acceleration!
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. Note that this has nothing to do with 3D acceleration, just 2D hardware acceleration support in the underlying operating system video drivers.
If you want hardware acceleration on Linux, you can use the DGA driver (fullscreen-only, under X11) or the framebuffer console driver (fullscreen-only, under the console). See the Linux FAQ for more information on using these drivers.
If you want hardware acceleration on Windows, make sure SDL is built with DirectX support and run your program in fullscreen mode.
An excellent article by Bob Pendleton covering SDL hardware surfaces is available at the O'Reilly Network
If you are in windowed mode, you need to run in fullscreen mode. If you are in fullscreen mode, the system drivers probably do not support synchronizing with the vertical retrace. If you are using OpenGL with the NVidia drivers, you can enable retrace synchronized flipping using an external control panel or environment variable.
An excellent article by Bob Pendleton covering SDL hardware surfaces is available at the O'Reilly Network
This happens because you're directly accessing the video memory, and the video driver doesn't support hardware cursor overlays. Simply create the cursor as a sprite and blit it onto the screen where the mouse cursor coordinates are.