Wiki Page Content

Differences between revisions 1 and 6 (spanning 5 versions)
Revision 1 as of 2010-05-09 06:22:14
Size: 915
Editor: SheenaSmith
Comment: create page, add content (Wed Mar 10 ver; changeset 4428)
Revision 6 as of 2010-08-03 21:50:07
Size: 1625
Editor: SheenaSmith
Comment: temp repair of include (waiting for final SDL_Init)
Deletions are marked like this. Additions are marked like this.
Line 3: Line 3:
||<tablewidth="100%" style="color: #FF0000;" :> DRAFT||
Line 6: Line 5:
Use this function to ,,clean up,, ^quit^ specific SDL subsystems. Use this function to shut down specific SDL subsystems.
Line 12: Line 11:
void SDL_QuitSubSystem(Uint32 flags); void SDL_QuitSubSystem(Uint32 flags)
Line 20: Line 19:
You can add your code example here #include "SDL.h"

/* ... */

int main(int argc, char **argv) {
    int sdl_initialized = 0;
    sdl_initialized = !SDL_Init(0);

    /* ... console stuff ... */

    if (sdl_initialized && SDL_InitSubSystem(SDL_INIT_VIDEO)) {
        display_graph();
        SDL_QuitSubSystem(SDL_INIT_VIDEO);
    }

    /* ... more console stuff ... */

    if (sdl_initialized) SDL_Quit();
    return 0;
}
Line 25: Line 43:
<<Include(SDL_Init, , , from="OR'd together.", to="== Return Value ==")>> <<Include(SDL_Init, , , from="initiate multiple subsystems.", to="This function loads")>>
Line 27: Line 45:
''You can add useful comments here'' If you start a subsystem using a call to that subsystem's init function (for example [[SDL_VideoInit]]()) instead of [[SDL_Init]]() or [[SDL_InitSubSystem]](), [[SDL_QuitSubSystem]]() and [[SDL_WasInit]]() will not work. You will need to use that subsystem's quit function ([[SDL_VideoQuit]]()) directly instead.

You still need to call [[SDL_Quit]]() even if you close all open subsystems with [[SDL_QuitSubSystem]]().

SDL_QuitSubSystem

Use this function to shut down specific SDL subsystems.

Syntax

void SDL_QuitSubSystem(Uint32 flags)

Function Parameters

flags

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

Code Examples

#include "SDL.h"

/* ... */

int main(int argc, char **argv) {
    int sdl_initialized = 0;
    sdl_initialized = !SDL_Init(0);

    /* ... console stuff ... */

    if (sdl_initialized && SDL_InitSubSystem(SDL_INIT_VIDEO)) {
        display_graph();
        SDL_QuitSubSystem(SDL_INIT_VIDEO);
    }

    /* ... more console stuff ... */

    if (sdl_initialized) SDL_Quit();
    return 0;
}

Remarks

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

Include: Nothing found for "initiate multiple subsystems."!

Include: Nothing found for "This function loads"!

SDL_Init

Use this function to initialize the SDL library. This must be called before using most other SDL functions.

Syntax

int SDL_Init(Uint32 flags)

Function Parameters

flags

subsystem initialization flags; 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

#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 file I/O and threading subsystems are initialized by default. You must specifically initialize other subsystems if you use them in your application.

Logging works without initialization, too.

flags may be any of the following OR'd together:

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

If you start a subsystem using a call to that subsystem's init function (for example SDL_VideoInit()) instead of SDL_Init() or SDL_InitSubSystem(), SDL_QuitSubSystem() and SDL_WasInit() will not work. You will need to use that subsystem's quit function (SDL_VideoQuit()) directly instead.

You still need to call SDL_Quit() even if you close all open subsystems with SDL_QuitSubSystem().


CategoryAPI, CategoryInit

None: SDL_QuitSubSystem (last edited 2016-06-10 20:00:41 by PhilippWiesemann)

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