#pragma section-numbers off #pragma camelcase off = SDL_Init = Use this function to initialize the SDL library. This must be called before using most other SDL functions. <> == Syntax == {{{#!highlight cpp int SDL_Init(Uint32 flags) }}} == Function Parameters == ||'''flags'''||subsystem initialization flags; see [[#Remarks|Remarks]] for details|| == Return Value == Returns 0 on success or a negative error code on failure; call [[SDL_GetError]]() for more information. == Code Examples == {{{#!highlight cpp #include "SDL.h" int main(int argc, char* argv[]) { if (SDL_Init(SDL_INIT_VIDEO|SDL_INIT_AUDIO) != 0) { SDL_Log("Unable to initialize SDL: %s", SDL_GetError()); return 1; } /* ... */ SDL_Quit(); return 0; } }}} == Remarks == [[SDL_Init]]() simply forwards to calling [[SDL_InitSubSystem]](). Therefore, the two may be used interchangeably. Though for readability of your code [[SDL_InitSubSystem]]() might be preferred. The [[CategoryIO|file I/O]] and [[CategoryThread|threading]] subsystems are initialized by default. You must specifically initialize other subsystems if you use them in your application. [[CategoryLog|Logging]] works without initialization, too. '''flags''' may be any of the following OR'd together: ##The following content is included on `SDL_InitSubSystem`. Any changes between these comments will be reflected there as well. Please use caution when editing. Start Include here. ||'''SDL_INIT_TIMER'''||timer subsystem|| ||'''SDL_INIT_AUDIO'''||audio subsystem|| ||'''SDL_INIT_VIDEO'''||video subsystem; automatically initializes the events subsystem|| ||'''SDL_INIT_JOYSTICK'''||joystick subsystem; automatically initializes the events subsystem|| ||'''SDL_INIT_HAPTIC'''||haptic (force feedback) subsystem|| ||'''SDL_INIT_GAMECONTROLLER'''||controller subsystem; automatically initializes the joystick subsystem|| ||'''SDL_INIT_EVENTS'''||events subsystem|| ||'''SDL_INIT_EVERYTHING'''||all of the above subsystems|| ||'''SDL_INIT_NOPARACHUTE'''||compatibility; this flag is ignored|| ##End Include here. If you want to initialize subsystems separately you would call [[SDL_Init]](0) followed by [[SDL_InitSubSystem]]() with the desired subsystem flag. == Related Functions == .[[SDL_InitSubSystem]] .[[SDL_Quit]] .[[SDL_SetMainReady]] .[[SDL_WasInit]] ---- [[CategoryAPI]], [[CategoryInit]]