Wiki Page Content

Differences between revisions 19 and 20
Revision 19 as of 2013-02-11 17:50:26
Size: 1733
Comment: Removed reference to SDL 1.3
Revision 20 as of 2013-06-29 21:09:43
Size: 2254
Editor: Pantheon
Comment: Added a note about the role of SDL_SetMainReady() in callig SDL_Init() and general changes for clarity
Deletions are marked like this. Additions are marked like this.
Line 5: Line 5:
Line 7: Line 6:
Line 13: Line 11:

F
unctions in this category are used to set up SDL for use and generally have global effects in your program.
The functions in this category are used to set up SDL for use and generally have global effects in your program.
Line 17: Line 14:
To begin using SDL in your program [[SDL_Init]]() must be called before most other SDL functions. The role of [[SDL_Init]]() is to properly initialize the SDL library and start each of the various subsystems requested as part of the call.
Line 18: Line 16:
To begin using SDL in your program [[SDL_Init]]() must be called to initialize subsystems and enable use of other SDL functions.
{i} The [[CategoryEvents|Event Handling]], [[CategoryIO|File I/O]], and [[CategoryThread|Threading]] subsystems are initialized by default. To initialize other subsystems you must specifically call them. Multiple subsystems may be OR'd together. 
 . {i} The [[CategoryEvents|Event Handling]], [[CategoryIO|File I/O]], and [[CategoryThread|Threading]] subsystems are initialized by default. To initialize other subsystems you must specifically call them. Multiple subsystems may be OR'd together.
Line 24: Line 21:
  . Initializes the 3 default subsystems plus the [[CategoryVideo|Video]] and [[CategoryAudio|Audio]] subsystems.   . This initializes the 3 default subsystems plus the [[CategoryVideo|Video]] and [[CategoryAudio|Audio]] subsystems.
  .

It should be noted that on some operating systems, [[SDL_Init]]() will fail if [[SDL_main]]() has not been defined as the entry point for the program. Calling [[SDL_SetMainReady]]() prior to [[SDL_Init]]() will circumvent this faliure condition, however, users should be careful when calling [[SDL_|SDL_SetMainReady]]() as improper initalization may cause crashes and hard to diagnose problems.
Line 27: Line 27:
[[SDL_Quit]]() should be called before an SDL application exits to safely shut down all subsystems, including the default ones.
Line 28: Line 29:
[[SDL_Quit]]() should be called before an SDL application exits to shut down all subsystems, including the default ones.
* It is not necessary to specify individual subsystems when using [[SDL_Quit]](). It will automatically shut down all active subsystems. 
 * It is not necessary to specify individual subsystems when using [[SDL_Quit]]() as it will automatically shut down all active subsystems.
Line 34: Line 34:
Line 37: Line 36:

Initialization and Shutdown

Include File(s): SDL.h

Introduction

The functions in this category are used to set up SDL for use and generally have global effects in your program.

Introduction to Initialization

To begin using SDL in your program SDL_Init() must be called before most other SDL functions. The role of SDL_Init() is to properly initialize the SDL library and start each of the various subsystems requested as part of the call.

  • {i} The Event Handling, File I/O, and Threading subsystems are initialized by default. To initialize other subsystems you must specifically call them. Multiple subsystems may be OR'd together.

  • Example:

    • SDL_Init(SDL_INIT_VIDEO|SDL_INIT_AUDIO);
    • This initializes the 3 default subsystems plus the Video and Audio subsystems.

It should be noted that on some operating systems, SDL_Init() will fail if SDL_main() has not been defined as the entry point for the program. Calling SDL_SetMainReady() prior to SDL_Init() will circumvent this faliure condition, however, users should be careful when calling SDL_SetMainReady() as improper initalization may cause crashes and hard to diagnose problems.

Introduction to Shut Down

SDL_Quit() should be called before an SDL application exits to safely shut down all subsystems, including the default ones.

  • It is not necessary to specify individual subsystems when using SDL_Quit() as it will automatically shut down all active subsystems.

Functions


CategoryCategory

None: CategoryInit (last edited 2016-03-27 21:42:54 by PhilippWiesemann)

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