SDL

From RogueBasin
Jump to navigation Jump to search

From www.libsdl.org:

"Simple DirectMedia Layer is a cross-platform multimedia library designed to provide low level access to audio, keyboard, mouse, joystick, 3D hardware via OpenGL, and 2D video framebuffer. It is used by MPEG playback software, emulators, and many popular games, including the award winning Linux port of "Civilization: Call To Power."

SDL supports Linux, Windows, Windows CE, BeOS, Mac OS, Mac OS X, FreeBSD, NetBSD, OpenBSD, BSD/OS, Solaris, IRIX, and QNX. The code contains support for AmigaOS, Dreamcast, Atari, AIX, OSF/Tru64, RISC OS, SymbianOS, 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#, D, Eiffel, Erlang, Euphoria, Guile, Haskell, Java, Lisp, Lua, ML, Objective C, Pascal, Perl, PHP, Pike, Pliant, Python, Ruby, Smalltalk, and Tcl.

SDL is distributed under GNU LGPL version 2. This license allows you to use SDL freely in commercial programs as long as you link with the dynamic library."

Creating a SDL project with VC++

Starting from scratch by installing SDL.

1. Download SDL-1.2.13-win32.zip

2. Unzip

3. Create a new empty VC++ project.

4. Add a "main.c" (or whatever) file and copy a simple SDL program into it. (e.g. Hello Pixel).

5. The 'include' directory needs to be added to "Additional Include Directories".

I created a new directory "C:\p\include" and copied the contents of the SDL include directory there. (P standing for 'programming'). See "Project -> Properties -> C/C++ -> General -> Additional Include Directories."

6. The 'lib' directory needs to be added to "Additional Library Directories".

I created a new directory "C:\p\lib" and copied the contents of the SDL lib directory there. See "Project -> Properties -> Linker -> General -> Additional Library Directories".

7. SDLmain.lib and SDL.lib need to be added to the "Additional Dependencies".

See "Project -> Properites -> Linker -> Additional Dependencies".

8. msvcrt.lib clashes with SDL. You need to change from "Multi-threaded Debug DLL (/MDd)" to "Multi-threaded DLL (/MDd)"

See "Project -> Properties -> C/C++ -> Code Generation -> Run-time library".

9. You need to set the subsystem. (To either Console or Windows)

See "Project -> Properties -> Linker -> System".

10. Now compile / run your project.

(N.B. It may be advisable to use the NO_PARACHUTE flag with SDL_Init, but I have not been able to find where this was recommended again).

See also

SDL_ttf

SDL:Reviews