SDL  2.0
SDL.h File Reference
#include "SDL_main.h"
#include "SDL_stdinc.h"
#include "SDL_assert.h"
#include "SDL_atomic.h"
#include "SDL_audio.h"
#include "SDL_clipboard.h"
#include "SDL_cpuinfo.h"
#include "SDL_endian.h"
#include "SDL_error.h"
#include "SDL_events.h"
#include "SDL_filesystem.h"
#include "SDL_gamecontroller.h"
#include "SDL_haptic.h"
#include "SDL_hints.h"
#include "SDL_joystick.h"
#include "SDL_loadso.h"
#include "SDL_log.h"
#include "SDL_messagebox.h"
#include "SDL_mutex.h"
#include "SDL_power.h"
#include "SDL_render.h"
#include "SDL_rwops.h"
#include "SDL_sensor.h"
#include "SDL_shape.h"
#include "SDL_system.h"
#include "SDL_thread.h"
#include "SDL_timer.h"
#include "SDL_version.h"
#include "SDL_video.h"
#include "begin_code.h"
#include "close_code.h"
+ Include dependency graph for SDL.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

SDL_INIT_*

These are the flags which may be passed to SDL_Init(). You should specify the subsystems which you will be using in your application.

#define SDL_INIT_TIMER   0x00000001u
#define SDL_INIT_AUDIO   0x00000010u
#define SDL_INIT_VIDEO   0x00000020u
#define SDL_INIT_JOYSTICK   0x00000200u
#define SDL_INIT_HAPTIC   0x00001000u
#define SDL_INIT_GAMECONTROLLER   0x00002000u
#define SDL_INIT_EVENTS   0x00004000u
#define SDL_INIT_SENSOR   0x00008000u
#define SDL_INIT_NOPARACHUTE   0x00100000u
#define SDL_INIT_EVERYTHING

Functions

int SDL_Init (Uint32 flags)
int SDL_InitSubSystem (Uint32 flags)
void SDL_QuitSubSystem (Uint32 flags)
Uint32 SDL_WasInit (Uint32 flags)
void SDL_Quit (void)

Detailed Description

Main include header for the SDL library

Definition in file SDL.h.

Macro Definition Documentation

#define SDL_INIT_EVENTS   0x00004000u
#define SDL_INIT_EVERYTHING
Value:

Definition at line 86 of file SDL.h.

Referenced by platform_testDefaultInit(), SDL_Quit(), and SDL_WasInit().

#define SDL_INIT_GAMECONTROLLER   0x00002000u

SDL_INIT_GAMECONTROLLER implies SDL_INIT_JOYSTICK

Definition at line 82 of file SDL.h.

Referenced by main(), main_testImpliedJoystickInit(), main_testImpliedJoystickQuit(), main_testInitQuitSubSystem(), SDL_InitSubSystem(), and SDL_QuitSubSystem().

#define SDL_INIT_HAPTIC   0x00001000u
#define SDL_INIT_JOYSTICK   0x00000200u

SDL_INIT_JOYSTICK implies SDL_INIT_EVENTS

Definition at line 80 of file SDL.h.

Referenced by main(), main_testImpliedJoystickQuit(), main_testInitQuitJoystickHaptic(), main_testInitQuitSubSystem(), SDL_InitSubSystem(), and SDL_QuitSubSystem().

#define SDL_INIT_NOPARACHUTE   0x00100000u

compatibility; this flag is ignored.

Definition at line 85 of file SDL.h.

#define SDL_INIT_SENSOR   0x00008000u

Definition at line 84 of file SDL.h.

Referenced by main(), SDL_InitSubSystem(), and SDL_QuitSubSystem().

#define SDL_INIT_TIMER   0x00000001u

Definition at line 77 of file SDL.h.

Referenced by _timerSetUp(), main(), SDL_InitSubSystem(), SDL_QuitSubSystem(), and SDLTest_SetTestTimeout().

#define SDL_INIT_VIDEO   0x00000020u

SDL_INIT_VIDEO implies SDL_INIT_EVENTS

Definition at line 79 of file SDL.h.

Referenced by main(), SDL_InitSubSystem(), SDL_QuitSubSystem(), SDL_WinRTInitXAMLApp(), SDLTest_CommonInit(), SDLTest_CommonQuit(), and SDLTest_CommonUsage().

Function Documentation

int SDL_Init ( Uint32  flags)

This function initializes the subsystems specified by flags

Definition at line 254 of file SDL.c.

References SDL_InitSubSystem.

{
}
int SDL_InitSubSystem ( Uint32  flags)

This function initializes specific SDL subsystems

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.

Definition at line 106 of file SDL.c.

References NULL, SDL_AudioInit, SDL_ClearError, SDL_GameControllerInit(), SDL_HapticInit(), SDL_INIT_AUDIO, SDL_INIT_EVENTS, SDL_INIT_GAMECONTROLLER, SDL_INIT_HAPTIC, SDL_INIT_JOYSTICK, SDL_INIT_SENSOR, SDL_INIT_TIMER, SDL_INIT_VIDEO, SDL_JoystickInit(), SDL_MainIsReady, SDL_PrivateShouldInitSubsystem(), SDL_PrivateSubsystemRefCountIncr(), SDL_QuitInit(), SDL_SensorInit(), SDL_SetError, SDL_StartEventLoop(), SDL_TicksInit(), SDL_TimerInit(), and SDL_VideoInit.

{
SDL_SetError("Application didn't initialize properly, did you include SDL_main.h in the file containing your main() function?");
return -1;
}
/* Clear the error message */
/* game controller implies joystick */
}
/* video or joystick implies events */
}
#if SDL_VIDEO_DRIVER_WINDOWS
if (SDL_HelperWindowCreate() < 0) {
return -1;
}
}
#endif
#if !SDL_TIMERS_DISABLED
#endif
/* Initialize the event subsystem */
#if !SDL_EVENTS_DISABLED
if (SDL_PrivateShouldInitSubsystem(SDL_INIT_EVENTS)) {
if (SDL_StartEventLoop() < 0) {
return (-1);
}
}
#else
return SDL_SetError("SDL not built with events support");
#endif
}
/* Initialize the timer subsystem */
#if !SDL_TIMERS_DISABLED
if (SDL_PrivateShouldInitSubsystem(SDL_INIT_TIMER)) {
if (SDL_TimerInit() < 0) {
return (-1);
}
}
#else
return SDL_SetError("SDL not built with timer support");
#endif
}
/* Initialize the video subsystem */
#if !SDL_VIDEO_DISABLED
if (SDL_PrivateShouldInitSubsystem(SDL_INIT_VIDEO)) {
if (SDL_VideoInit(NULL) < 0) {
return (-1);
}
}
#else
return SDL_SetError("SDL not built with video support");
#endif
}
/* Initialize the audio subsystem */
#if !SDL_AUDIO_DISABLED
if (SDL_PrivateShouldInitSubsystem(SDL_INIT_AUDIO)) {
if (SDL_AudioInit(NULL) < 0) {
return (-1);
}
}
#else
return SDL_SetError("SDL not built with audio support");
#endif
}
/* Initialize the joystick subsystem */
#if !SDL_JOYSTICK_DISABLED
if (SDL_PrivateShouldInitSubsystem(SDL_INIT_JOYSTICK)) {
if (SDL_JoystickInit() < 0) {
return (-1);
}
}
#else
return SDL_SetError("SDL not built with joystick support");
#endif
}
if ((flags & SDL_INIT_GAMECONTROLLER)){
#if !SDL_JOYSTICK_DISABLED
if (SDL_PrivateShouldInitSubsystem(SDL_INIT_GAMECONTROLLER)) {
return (-1);
}
}
SDL_PrivateSubsystemRefCountIncr(SDL_INIT_GAMECONTROLLER);
#else
return SDL_SetError("SDL not built with joystick support");
#endif
}
/* Initialize the haptic subsystem */
#if !SDL_HAPTIC_DISABLED
if (SDL_PrivateShouldInitSubsystem(SDL_INIT_HAPTIC)) {
if (SDL_HapticInit() < 0) {
return (-1);
}
}
#else
return SDL_SetError("SDL not built with haptic (force feedback) support");
#endif
}
/* Initialize the sensor subsystem */
#if !SDL_SENSOR_DISABLED
if (SDL_PrivateShouldInitSubsystem(SDL_INIT_SENSOR)) {
if (SDL_SensorInit() < 0) {
return (-1);
}
}
#else
return SDL_SetError("SDL not built with sensor support");
#endif
}
return (0);
}
void SDL_Quit ( void  )

This function cleans up all initialized subsystems. You should call it upon all exit conditions.

Definition at line 370 of file SDL.c.

References SDL_AssertionsQuit(), SDL_bInMainQuit, SDL_ClearHints, SDL_FALSE, SDL_INIT_EVERYTHING, SDL_LogResetPriorities, SDL_memset, SDL_QuitSubSystem, SDL_SubsystemRefCount, SDL_TicksQuit(), and SDL_TRUE.

{
/* Quit all subsystems */
#if SDL_VIDEO_DRIVER_WINDOWS
SDL_HelperWindowDestroy();
#endif
#if !SDL_TIMERS_DISABLED
#endif
/* Now that every subsystem has been quit, we reset the subsystem refcount
* and the list of initialized subsystems.
*/
}
void SDL_QuitSubSystem ( Uint32  flags)

This function cleans up specific SDL subsystems

Definition at line 260 of file SDL.c.

References SDL_AudioQuit, SDL_GameControllerQuit(), SDL_HapticQuit(), SDL_INIT_AUDIO, SDL_INIT_EVENTS, SDL_INIT_GAMECONTROLLER, SDL_INIT_HAPTIC, SDL_INIT_JOYSTICK, SDL_INIT_SENSOR, SDL_INIT_TIMER, SDL_INIT_VIDEO, SDL_JoystickQuit(), SDL_PrivateShouldQuitSubsystem(), SDL_PrivateSubsystemRefCountDecr(), SDL_QuitQuit(), SDL_SensorQuit(), SDL_StopEventLoop(), SDL_TimerQuit(), and SDL_VideoQuit.

{
/* Shut down requested initialized subsystems */
#if !SDL_SENSOR_DISABLED
if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_SENSOR)) {
}
}
#endif
#if !SDL_JOYSTICK_DISABLED
/* game controller implies joystick */
if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_GAMECONTROLLER)) {
}
SDL_PrivateSubsystemRefCountDecr(SDL_INIT_GAMECONTROLLER);
}
/* joystick implies events */
if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_JOYSTICK)) {
}
}
#endif
#if !SDL_HAPTIC_DISABLED
if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_HAPTIC)) {
}
}
#endif
#if !SDL_AUDIO_DISABLED
if ((flags & SDL_INIT_AUDIO)) {
if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_AUDIO)) {
}
}
#endif
#if !SDL_VIDEO_DISABLED
if ((flags & SDL_INIT_VIDEO)) {
/* video implies events */
if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_VIDEO)) {
}
}
#endif
#if !SDL_TIMERS_DISABLED
if ((flags & SDL_INIT_TIMER)) {
if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_TIMER)) {
}
}
#endif
#if !SDL_EVENTS_DISABLED
if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_EVENTS)) {
}
}
#endif
}
Uint32 SDL_WasInit ( Uint32  flags)

This function returns a mask of the specified subsystems which have previously been initialized.

If flags is 0, it returns a mask of all initialized subsystems.

Definition at line 345 of file SDL.c.

References i, SDL_arraysize, SDL_INIT_EVERYTHING, SDL_min, SDL_MostSignificantBitIndex32(), and SDL_SubsystemRefCount.

{
int i;
int num_subsystems = SDL_arraysize(SDL_SubsystemRefCount);
Uint32 initialized = 0;
if (!flags) {
}
num_subsystems = SDL_min(num_subsystems, SDL_MostSignificantBitIndex32(flags) + 1);
/* Iterate over each bit in flags, and check the matching subsystem. */
for (i = 0; i < num_subsystems; ++i) {
if ((flags & 1) && SDL_SubsystemRefCount[i] > 0) {
initialized |= (1 << i);
}
flags >>= 1;
}
return initialized;
}