SDL  2.0
SDL.c File Reference
#include "./SDL_internal.h"
#include "SDL.h"
#include "SDL_bits.h"
#include "SDL_revision.h"
#include "SDL_assert_c.h"
#include "events/SDL_events_c.h"
#include "haptic/SDL_haptic_c.h"
#include "joystick/SDL_joystick_c.h"
#include "sensor/SDL_sensor_c.h"
#include "timer/SDL_timer_c.h"
+ Include dependency graph for SDL.c:

Go to the source code of this file.

Functions

static void SDL_PrivateSubsystemRefCountIncr (Uint32 subsystem)
 
static void SDL_PrivateSubsystemRefCountDecr (Uint32 subsystem)
 
static SDL_bool SDL_PrivateShouldInitSubsystem (Uint32 subsystem)
 
static SDL_bool SDL_PrivateShouldQuitSubsystem (Uint32 subsystem)
 
void SDL_SetMainReady (void)
 
int SDL_InitSubSystem (Uint32 flags)
 
int SDL_Init (Uint32 flags)
 
void SDL_QuitSubSystem (Uint32 flags)
 
Uint32 SDL_WasInit (Uint32 flags)
 
void SDL_Quit (void)
 
void SDL_GetVersion (SDL_version *ver)
 Get the version of SDL that is linked against your program. More...
 
const char * SDL_GetRevision (void)
 Get the code revision of SDL that is linked against your program. More...
 
int SDL_GetRevisionNumber (void)
 Get the revision number of SDL that is linked against your program. More...
 
const char * SDL_GetPlatform ()
 Gets the name of the platform. More...
 
SDL_bool SDL_IsTablet ()
 Return true if the current device is a tablet. More...
 

Variables

static SDL_bool SDL_MainIsReady = SDL_TRUE
 
static SDL_bool SDL_bInMainQuit = SDL_FALSE
 
static Uint8 SDL_SubsystemRefCount [32]
 

Function Documentation

§ SDL_GetPlatform()

const char* SDL_GetPlatform ( void  )

Gets the name of the platform.

Definition at line 419 of file SDL.c.

420 {
421 #if __AIX__
422  return "AIX";
423 #elif __ANDROID__
424  return "Android";
425 #elif __BSDI__
426  return "BSDI";
427 #elif __DREAMCAST__
428  return "Dreamcast";
429 #elif __EMSCRIPTEN__
430  return "Emscripten";
431 #elif __FREEBSD__
432  return "FreeBSD";
433 #elif __HAIKU__
434  return "Haiku";
435 #elif __HPUX__
436  return "HP-UX";
437 #elif __IRIX__
438  return "Irix";
439 #elif __LINUX__
440  return "Linux";
441 #elif __MINT__
442  return "Atari MiNT";
443 #elif __MACOS__
444  return "MacOS Classic";
445 #elif __MACOSX__
446  return "Mac OS X";
447 #elif __NACL__
448  return "NaCl";
449 #elif __NETBSD__
450  return "NetBSD";
451 #elif __OPENBSD__
452  return "OpenBSD";
453 #elif __OS2__
454  return "OS/2";
455 #elif __OSF__
456  return "OSF/1";
457 #elif __QNXNTO__
458  return "QNX Neutrino";
459 #elif __RISCOS__
460  return "RISC OS";
461 #elif __SOLARIS__
462  return "Solaris";
463 #elif __WIN32__
464  return "Windows";
465 #elif __WINRT__
466  return "WinRT";
467 #elif __TVOS__
468  return "tvOS";
469 #elif __IPHONEOS__
470  return "iOS";
471 #elif __PSP__
472  return "PlayStation Portable";
473 #else
474  return "Unknown (see SDL_platform.h)";
475 #endif
476 }

§ SDL_GetRevision()

const char* SDL_GetRevision ( void  )

Get the code revision of SDL that is linked against your program.

Returns an arbitrary string (a hash value) uniquely identifying the exact revision of the SDL library in use, and is only useful in comparing against other revisions. It is NOT an incrementing number.

Definition at line 405 of file SDL.c.

References SDL_REVISION.

406 {
407  return SDL_REVISION;
408 }
#define SDL_REVISION
Definition: SDL_revision.h:1

§ SDL_GetRevisionNumber()

int SDL_GetRevisionNumber ( void  )

Get the revision number of SDL that is linked against your program.

Returns a number uniquely identifying the exact revision of the SDL library in use. It is an incrementing number based on commits to hg.libsdl.org.

Definition at line 412 of file SDL.c.

References SDL_REVISION_NUMBER.

413 {
414  return SDL_REVISION_NUMBER;
415 }
#define SDL_REVISION_NUMBER
Definition: SDL_revision.h:2

§ SDL_GetVersion()

void SDL_GetVersion ( SDL_version ver)

Get the version of SDL that is linked against your program.

If you are linking to SDL dynamically, then it is possible that the current version will be different than the version you compiled against. This function returns the current version, while SDL_VERSION() is a macro that tells you what version you compiled with.

SDL_version compiled;
SDL_version linked;
SDL_VERSION(&compiled);
SDL_GetVersion(&linked);
printf("We compiled against SDL version %d.%d.%d ...\n",
compiled.major, compiled.minor, compiled.patch);
printf("But we linked against SDL version %d.%d.%d.\n",
linked.major, linked.minor, linked.patch);

This function may be called safely at any time, even before SDL_Init().

See also
SDL_VERSION

Definition at line 398 of file SDL.c.

References SDL_VERSION.

399 {
400  SDL_VERSION(ver);
401 }
#define SDL_VERSION(x)
Macro to determine SDL version program was compiled against.
Definition: SDL_version.h:79

§ SDL_Init()

int SDL_Init ( Uint32  flags)

This function initializes the subsystems specified by flags

Definition at line 254 of file SDL.c.

References SDL_InitSubSystem().

255 {
256  return SDL_InitSubSystem(flags);
257 }
GLbitfield flags
int SDL_InitSubSystem(Uint32 flags)
Definition: SDL.c:106

§ 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.

Referenced by SDL_Init().

107 {
108  if (!SDL_MainIsReady) {
109  SDL_SetError("Application didn't initialize properly, did you include SDL_main.h in the file containing your main() function?");
110  return -1;
111  }
112 
113  /* Clear the error message */
114  SDL_ClearError();
115 
116  if ((flags & SDL_INIT_GAMECONTROLLER)) {
117  /* game controller implies joystick */
119  }
120 
122  /* video or joystick implies events */
124  }
125 
126 #if SDL_VIDEO_DRIVER_WINDOWS
128  if (SDL_HelperWindowCreate() < 0) {
129  return -1;
130  }
131  }
132 #endif
133 
134 #if !SDL_TIMERS_DISABLED
135  SDL_TicksInit();
136 #endif
137 
138  /* Initialize the event subsystem */
139  if ((flags & SDL_INIT_EVENTS)) {
140 #if !SDL_EVENTS_DISABLED
141  if (SDL_PrivateShouldInitSubsystem(SDL_INIT_EVENTS)) {
142  if (SDL_StartEventLoop() < 0) {
143  return (-1);
144  }
145  SDL_QuitInit();
146  }
147  SDL_PrivateSubsystemRefCountIncr(SDL_INIT_EVENTS);
148 #else
149  return SDL_SetError("SDL not built with events support");
150 #endif
151  }
152 
153  /* Initialize the timer subsystem */
154  if ((flags & SDL_INIT_TIMER)){
155 #if !SDL_TIMERS_DISABLED
156  if (SDL_PrivateShouldInitSubsystem(SDL_INIT_TIMER)) {
157  if (SDL_TimerInit() < 0) {
158  return (-1);
159  }
160  }
161  SDL_PrivateSubsystemRefCountIncr(SDL_INIT_TIMER);
162 #else
163  return SDL_SetError("SDL not built with timer support");
164 #endif
165  }
166 
167  /* Initialize the video subsystem */
168  if ((flags & SDL_INIT_VIDEO)){
169 #if !SDL_VIDEO_DISABLED
170  if (SDL_PrivateShouldInitSubsystem(SDL_INIT_VIDEO)) {
171  if (SDL_VideoInit(NULL) < 0) {
172  return (-1);
173  }
174  }
175  SDL_PrivateSubsystemRefCountIncr(SDL_INIT_VIDEO);
176 #else
177  return SDL_SetError("SDL not built with video support");
178 #endif
179  }
180 
181  /* Initialize the audio subsystem */
182  if ((flags & SDL_INIT_AUDIO)){
183 #if !SDL_AUDIO_DISABLED
184  if (SDL_PrivateShouldInitSubsystem(SDL_INIT_AUDIO)) {
185  if (SDL_AudioInit(NULL) < 0) {
186  return (-1);
187  }
188  }
189  SDL_PrivateSubsystemRefCountIncr(SDL_INIT_AUDIO);
190 #else
191  return SDL_SetError("SDL not built with audio support");
192 #endif
193  }
194 
195  /* Initialize the joystick subsystem */
196  if ((flags & SDL_INIT_JOYSTICK)){
197 #if !SDL_JOYSTICK_DISABLED
198  if (SDL_PrivateShouldInitSubsystem(SDL_INIT_JOYSTICK)) {
199  if (SDL_JoystickInit() < 0) {
200  return (-1);
201  }
202  }
203  SDL_PrivateSubsystemRefCountIncr(SDL_INIT_JOYSTICK);
204 #else
205  return SDL_SetError("SDL not built with joystick support");
206 #endif
207  }
208 
209  if ((flags & SDL_INIT_GAMECONTROLLER)){
210 #if !SDL_JOYSTICK_DISABLED
211  if (SDL_PrivateShouldInitSubsystem(SDL_INIT_GAMECONTROLLER)) {
212  if (SDL_GameControllerInit() < 0) {
213  return (-1);
214  }
215  }
216  SDL_PrivateSubsystemRefCountIncr(SDL_INIT_GAMECONTROLLER);
217 #else
218  return SDL_SetError("SDL not built with joystick support");
219 #endif
220  }
221 
222  /* Initialize the haptic subsystem */
223  if ((flags & SDL_INIT_HAPTIC)){
224 #if !SDL_HAPTIC_DISABLED
225  if (SDL_PrivateShouldInitSubsystem(SDL_INIT_HAPTIC)) {
226  if (SDL_HapticInit() < 0) {
227  return (-1);
228  }
229  }
230  SDL_PrivateSubsystemRefCountIncr(SDL_INIT_HAPTIC);
231 #else
232  return SDL_SetError("SDL not built with haptic (force feedback) support");
233 #endif
234  }
235 
236  /* Initialize the sensor subsystem */
237  if ((flags & SDL_INIT_SENSOR)){
238 #if !SDL_SENSOR_DISABLED
239  if (SDL_PrivateShouldInitSubsystem(SDL_INIT_SENSOR)) {
240  if (SDL_SensorInit() < 0) {
241  return (-1);
242  }
243  }
244  SDL_PrivateSubsystemRefCountIncr(SDL_INIT_SENSOR);
245 #else
246  return SDL_SetError("SDL not built with sensor support");
247 #endif
248  }
249 
250  return (0);
251 }
#define SDL_INIT_SENSOR
Definition: SDL.h:84
#define SDL_ClearError
#define SDL_INIT_EVENTS
Definition: SDL.h:83
static SDL_bool SDL_MainIsReady
Definition: SDL.c:52
#define SDL_INIT_JOYSTICK
Definition: SDL.h:80
#define SDL_AudioInit
int SDL_JoystickInit(void)
Definition: SDL_joystick.c:114
int SDL_StartEventLoop(void)
Definition: SDL_events.c:391
int SDL_TimerInit(void)
Definition: SDL_timer.c:207
int SDL_QuitInit(void)
Definition: SDL_quit.c:92
static void SDL_PrivateSubsystemRefCountIncr(Uint32 subsystem)
Definition: SDL.c:59
#define SDL_VideoInit
int SDL_SensorInit(void)
Definition: SDL_sensor.c:69
#define NULL
Definition: begin_code.h:164
static SDL_bool SDL_PrivateShouldInitSubsystem(Uint32 subsystem)
Definition: SDL.c:78
#define SDL_SetError
GLbitfield flags
#define SDL_INIT_TIMER
Definition: SDL.h:77
#define SDL_INIT_AUDIO
Definition: SDL.h:78
void SDL_TicksInit(void)
#define SDL_INIT_GAMECONTROLLER
Definition: SDL.h:82
#define SDL_INIT_HAPTIC
Definition: SDL.h:81
int SDL_GameControllerInit(void)
int SDL_HapticInit(void)
Definition: SDL_haptic.c:35
#define SDL_INIT_VIDEO
Definition: SDL.h:79

§ SDL_IsTablet()

SDL_bool SDL_IsTablet ( void  )

Return true if the current device is a tablet.

Definition at line 479 of file SDL.c.

References APIENTRY, SDL_FALSE, SDL_IsAndroidTablet(), and TRUE.

480 {
481 #if __ANDROID__
482  extern SDL_bool SDL_IsAndroidTablet(void);
483  return SDL_IsAndroidTablet();
484 #elif __IPHONEOS__
485  extern SDL_bool SDL_IsIPad(void);
486  return SDL_IsIPad();
487 #else
488  return SDL_FALSE;
489 #endif
490 }
SDL_bool SDL_IsAndroidTablet(void)
SDL_bool
Definition: SDL_stdinc.h:161

§ SDL_PrivateShouldInitSubsystem()

static SDL_bool SDL_PrivateShouldInitSubsystem ( Uint32  subsystem)
static

Definition at line 78 of file SDL.c.

References SDL_assert, SDL_FALSE, SDL_MostSignificantBitIndex32(), SDL_SubsystemRefCount, and SDL_TRUE.

Referenced by SDL_InitSubSystem().

79 {
80  int subsystem_index = SDL_MostSignificantBitIndex32(subsystem);
81  SDL_assert(SDL_SubsystemRefCount[subsystem_index] < 255);
82  return (SDL_SubsystemRefCount[subsystem_index] == 0) ? SDL_TRUE : SDL_FALSE;
83 }
static Uint8 SDL_SubsystemRefCount[32]
Definition: SDL.c:55
SDL_FORCE_INLINE int SDL_MostSignificantBitIndex32(Uint32 x)
Definition: SDL_bits.h:61
#define SDL_assert(condition)
Definition: SDL_assert.h:169

§ SDL_PrivateShouldQuitSubsystem()

static SDL_bool SDL_PrivateShouldQuitSubsystem ( Uint32  subsystem)
static

Definition at line 87 of file SDL.c.

References SDL_bInMainQuit, SDL_FALSE, SDL_MostSignificantBitIndex32(), SDL_SubsystemRefCount, and SDL_TRUE.

Referenced by SDL_QuitSubSystem().

87  {
88  int subsystem_index = SDL_MostSignificantBitIndex32(subsystem);
89  if (SDL_SubsystemRefCount[subsystem_index] == 0) {
90  return SDL_FALSE;
91  }
92 
93  /* If we're in SDL_Quit, we shut down every subsystem, even if refcount
94  * isn't zero.
95  */
96  return (SDL_SubsystemRefCount[subsystem_index] == 1 || SDL_bInMainQuit) ? SDL_TRUE : SDL_FALSE;
97 }
static Uint8 SDL_SubsystemRefCount[32]
Definition: SDL.c:55
SDL_FORCE_INLINE int SDL_MostSignificantBitIndex32(Uint32 x)
Definition: SDL_bits.h:61
static SDL_bool SDL_bInMainQuit
Definition: SDL.c:54

§ SDL_PrivateSubsystemRefCountDecr()

static void SDL_PrivateSubsystemRefCountDecr ( Uint32  subsystem)
static

Definition at line 68 of file SDL.c.

References SDL_MostSignificantBitIndex32(), and SDL_SubsystemRefCount.

Referenced by SDL_QuitSubSystem().

69 {
70  int subsystem_index = SDL_MostSignificantBitIndex32(subsystem);
71  if (SDL_SubsystemRefCount[subsystem_index] > 0) {
72  --SDL_SubsystemRefCount[subsystem_index];
73  }
74 }
static Uint8 SDL_SubsystemRefCount[32]
Definition: SDL.c:55
SDL_FORCE_INLINE int SDL_MostSignificantBitIndex32(Uint32 x)
Definition: SDL_bits.h:61

§ SDL_PrivateSubsystemRefCountIncr()

static void SDL_PrivateSubsystemRefCountIncr ( Uint32  subsystem)
static

Definition at line 59 of file SDL.c.

References SDL_assert, SDL_MostSignificantBitIndex32(), and SDL_SubsystemRefCount.

Referenced by SDL_InitSubSystem().

60 {
61  int subsystem_index = SDL_MostSignificantBitIndex32(subsystem);
62  SDL_assert(SDL_SubsystemRefCount[subsystem_index] < 255);
63  ++SDL_SubsystemRefCount[subsystem_index];
64 }
static Uint8 SDL_SubsystemRefCount[32]
Definition: SDL.c:55
SDL_FORCE_INLINE int SDL_MostSignificantBitIndex32(Uint32 x)
Definition: SDL_bits.h:61
#define SDL_assert(condition)
Definition: SDL_assert.h:169

§ SDL_Quit()

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.

371 {
373 
374  /* Quit all subsystems */
375 #if SDL_VIDEO_DRIVER_WINDOWS
376  SDL_HelperWindowDestroy();
377 #endif
379 
380 #if !SDL_TIMERS_DISABLED
381  SDL_TicksQuit();
382 #endif
383 
384  SDL_ClearHints();
387 
388  /* Now that every subsystem has been quit, we reset the subsystem refcount
389  * and the list of initialized subsystems.
390  */
392 
394 }
#define SDL_LogResetPriorities
static Uint8 SDL_SubsystemRefCount[32]
Definition: SDL.c:55
void SDL_QuitSubSystem(Uint32 flags)
Definition: SDL.c:260
#define SDL_ClearHints
static SDL_bool SDL_bInMainQuit
Definition: SDL.c:54
void SDL_AssertionsQuit(void)
Definition: SDL_assert.c:397
#define SDL_INIT_EVERYTHING
Definition: SDL.h:86
GLuint GLfloat x0
void SDL_TicksQuit(void)
#define SDL_memset

§ SDL_QuitSubSystem()

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.

Referenced by SDL_Quit().

261 {
262  /* Shut down requested initialized subsystems */
263 #if !SDL_SENSOR_DISABLED
264  if ((flags & SDL_INIT_SENSOR)) {
265  if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_SENSOR)) {
266  SDL_SensorQuit();
267  }
268  SDL_PrivateSubsystemRefCountDecr(SDL_INIT_SENSOR);
269  }
270 #endif
271 
272 #if !SDL_JOYSTICK_DISABLED
273  if ((flags & SDL_INIT_GAMECONTROLLER)) {
274  /* game controller implies joystick */
276 
277  if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_GAMECONTROLLER)) {
279  }
280  SDL_PrivateSubsystemRefCountDecr(SDL_INIT_GAMECONTROLLER);
281  }
282 
283  if ((flags & SDL_INIT_JOYSTICK)) {
284  /* joystick implies events */
286 
287  if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_JOYSTICK)) {
289  }
290  SDL_PrivateSubsystemRefCountDecr(SDL_INIT_JOYSTICK);
291  }
292 #endif
293 
294 #if !SDL_HAPTIC_DISABLED
295  if ((flags & SDL_INIT_HAPTIC)) {
296  if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_HAPTIC)) {
297  SDL_HapticQuit();
298  }
299  SDL_PrivateSubsystemRefCountDecr(SDL_INIT_HAPTIC);
300  }
301 #endif
302 
303 #if !SDL_AUDIO_DISABLED
304  if ((flags & SDL_INIT_AUDIO)) {
305  if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_AUDIO)) {
306  SDL_AudioQuit();
307  }
308  SDL_PrivateSubsystemRefCountDecr(SDL_INIT_AUDIO);
309  }
310 #endif
311 
312 #if !SDL_VIDEO_DISABLED
313  if ((flags & SDL_INIT_VIDEO)) {
314  /* video implies events */
316 
317  if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_VIDEO)) {
318  SDL_VideoQuit();
319  }
320  SDL_PrivateSubsystemRefCountDecr(SDL_INIT_VIDEO);
321  }
322 #endif
323 
324 #if !SDL_TIMERS_DISABLED
325  if ((flags & SDL_INIT_TIMER)) {
326  if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_TIMER)) {
327  SDL_TimerQuit();
328  }
329  SDL_PrivateSubsystemRefCountDecr(SDL_INIT_TIMER);
330  }
331 #endif
332 
333 #if !SDL_EVENTS_DISABLED
334  if ((flags & SDL_INIT_EVENTS)) {
335  if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_EVENTS)) {
336  SDL_QuitQuit();
338  }
339  SDL_PrivateSubsystemRefCountDecr(SDL_INIT_EVENTS);
340  }
341 #endif
342 }
#define SDL_INIT_SENSOR
Definition: SDL.h:84
#define SDL_INIT_EVENTS
Definition: SDL.h:83
void SDL_TimerQuit(void)
Definition: SDL_timer.c:239
void SDL_HapticQuit(void)
Definition: SDL_haptic.c:390
#define SDL_INIT_JOYSTICK
Definition: SDL.h:80
#define SDL_AudioQuit
void SDL_GameControllerQuit(void)
GLbitfield flags
#define SDL_INIT_TIMER
Definition: SDL.h:77
#define SDL_INIT_AUDIO
Definition: SDL.h:78
static void SDL_PrivateSubsystemRefCountDecr(Uint32 subsystem)
Definition: SDL.c:68
#define SDL_VideoQuit
void SDL_SensorQuit(void)
Definition: SDL_sensor.c:440
static SDL_bool SDL_PrivateShouldQuitSubsystem(Uint32 subsystem)
Definition: SDL.c:87
#define SDL_INIT_GAMECONTROLLER
Definition: SDL.h:82
void SDL_JoystickQuit(void)
Definition: SDL_joystick.c:697
#define SDL_INIT_HAPTIC
Definition: SDL.h:81
#define SDL_INIT_VIDEO
Definition: SDL.h:79
void SDL_QuitQuit(void)
Definition: SDL_quit.c:128
void SDL_StopEventLoop(void)
Definition: SDL_events.c:317

§ SDL_SetMainReady()

void SDL_SetMainReady ( void  )

This is called by the real SDL main function to let the rest of the library know that initialization was done properly.

Calling this yourself without knowing what you're doing can cause crashes and hard to diagnose problems with your application.

Definition at line 100 of file SDL.c.

References SDL_MainIsReady, and SDL_TRUE.

101 {
103 }
static SDL_bool SDL_MainIsReady
Definition: SDL.c:52

§ SDL_WasInit()

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.

346 {
347  int i;
348  int num_subsystems = SDL_arraysize(SDL_SubsystemRefCount);
349  Uint32 initialized = 0;
350 
351  if (!flags) {
353  }
354 
355  num_subsystems = SDL_min(num_subsystems, SDL_MostSignificantBitIndex32(flags) + 1);
356 
357  /* Iterate over each bit in flags, and check the matching subsystem. */
358  for (i = 0; i < num_subsystems; ++i) {
359  if ((flags & 1) && SDL_SubsystemRefCount[i] > 0) {
360  initialized |= (1 << i);
361  }
362 
363  flags >>= 1;
364  }
365 
366  return initialized;
367 }
#define SDL_min(x, y)
Definition: SDL_stdinc.h:406
static Uint8 SDL_SubsystemRefCount[32]
Definition: SDL.c:55
SDL_FORCE_INLINE int SDL_MostSignificantBitIndex32(Uint32 x)
Definition: SDL_bits.h:61
#define SDL_INIT_EVERYTHING
Definition: SDL.h:86
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
Definition: SDL_x11sym.h:50
GLbitfield flags
uint32_t Uint32
Definition: SDL_stdinc.h:203
#define SDL_arraysize(array)
Definition: SDL_stdinc.h:115

Variable Documentation

§ SDL_bInMainQuit

SDL_bool SDL_bInMainQuit = SDL_FALSE
static

Definition at line 54 of file SDL.c.

Referenced by SDL_PrivateShouldQuitSubsystem(), and SDL_Quit().

§ SDL_MainIsReady

SDL_bool SDL_MainIsReady = SDL_TRUE
static

Definition at line 52 of file SDL.c.

Referenced by SDL_InitSubSystem(), and SDL_SetMainReady().

§ SDL_SubsystemRefCount