Wiki Page Content

Differences between revisions 11 and 12
Revision 11 as of 2013-08-10 19:35:16
Size: 1719
Comment: Removed dots in example.
Revision 12 as of 2014-07-04 12:51:17
Size: 2004
Comment: Added content from SDL.h header.
Deletions are marked like this. Additions are marked like this.
Line 25: Line 25:
SDL_Window* window = SDL_CreateWindow("A Window",  SDL_Window* window = SDL_CreateWindow("A Window",
Line 44: Line 44:
<<Anchor(flags)>>These are the flags which may be passed to [[SDL_InitSubSystem]]() and may be OR'd together to initialize multiple subsystems simultaneously.  <<Anchor(flags)>>These are the flags which may be passed to [[SDL_InitSubSystem]]() and may be OR'd together to initialize multiple subsystems simultaneously.
Line 48: Line 48:

Subsystem initialization is ref-counted, you must call [[SDL_QuitSubSystem]]() for each SDL_!InitSubSystem() to correctly shutdown a subsystem manually (or call [[SDL_Quit]]() to force shutdown). If a subsystem is already loaded then this call will increase the ref-count and return.

SDL_InitSubSystem

Use this function to initialize specific SDL subsystems.

Syntax

int SDL_InitSubSystem(Uint32 flags)

Function Parameters

flags

any of the flags used by SDL_Init(); see Remarks for details

Return Value

Returns 0 on success or a negative error code on failure; call SDL_GetError() for more information.

Code Examples

/* Separating Joystick and Video initialization. */
SDL_Init(SDL_INIT_VIDEO);

SDL_Window* window = SDL_CreateWindow("A Window",
    SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 640, 480,
    SDL_WINDOW_FULLSCREEN);
SDL_Renderer* renderer = SDL_CreateRenderer(window, -1, 0);

/* Do Some Video stuff */

/* Initialize the joystick subsystem */
SDL_InitSubSystem(SDL_INIT_JOYSTICK);

/* Do some stuff with video and joystick */

/* Shut them both down */
SDL_Quit();

Remarks

After SDL has been initialized with SDL_Init() you may initialize uninitialized subsystems with SDL_InitSubSystem().

These are the flags which may be passed to SDL_InitSubSystem() and may be OR'd together to initialize multiple subsystems simultaneously.

Include: Nothing found for "Unless the"!

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

If you want to initialize subsystems separately you would call SDL_Init(0) followed by SDL_InitSubSystem() with the desired subsystem flag.

Related Functions


CategoryAPI, CategoryInit

SDL_Init() initializes assertions and crash protection and then calls SDL_InitSubSystem(). If you want to bypass those protections you can call SDL_InitSubSystem() directly.

Subsystem initialization is ref-counted, you must call SDL_QuitSubSystem() for each SDL_InitSubSystem() to correctly shutdown a subsystem manually (or call SDL_Quit() to force shutdown). If a subsystem is already loaded then this call will increase the ref-count and return.


CategoryAPI, CategoryInit

None: SDL_InitSubSystem (last edited 2015-01-02 21:29:27 by PhilippWiesemann)

(Page Info.)
Feedback
Please include your contact information if you'd like to receive a reply.
Submit