SDL_Init function

SDL_Init -- Initializes SDL

Syntax

int SDL_Init(Uint32 flags);

Description

The SDL_Init function initializes the Simple Directmedia Library and the subsystems specified by flags. It should be called before all other SDL functions.

Note: Unless the SDL_INIT_NOPARACHUTE flag is set, it will install cleanup signal handlers for some commonly ignored fatal signals (like SIGSEGV).

Parameter

flags [in]

List of SDL initialization flags

SDL_INIT_TIMER

The timer subsystem

SDL_INIT_AUDIO

The audio subsystem

SDL_INIT_VIDEO

The video subsystem

SDL_INIT_CDROM

The cdrom subsystem

SDL_INIT_JOYSTICK

The joystick subsystem

SDL_INIT_EVERYTHING

All of the above

SDL_INIT_NOPARACHUTE

Prevents SDL from catching fatal signals

SDL_INIT_EVENTTHREAD

Runs the event manager in a separate thread

Return value

-1

0

You can get extended error message by calling SDL_GetError. Typical cause of this error is using a particular display without having according subsystem support, such as missing mouse driver when using with framebuffer device. In this case you can either compile SDL without mouse device, or set "SDL_NOMOUSE=1" environment variable before running your application.

See also

SDL_Quit, SDL_InitSubSystem, SDL_GetError, Environment_variables

Example

   1 // Initializes the video subsystem
   2 if (SDL_Init(SDL_INIT_VIDEO) < 0) {
   3     fprintf(stderr, "Unable to init SDL: %s\n", SDL_GetError());
   4     exit(1);
   5 }

Requirements

Header

SDL.h

Version

1.2.13

Shared object

libSDL.so

DLL

SDL.dll


CategorySDLGeneral

SDL_Init (last edited 2010-05-27 06:22:37 by 209)