SDL
3.0
SDL_init.h
Go to the documentation of this file.
1
/*
2
Simple DirectMedia Layer
3
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
4
5
This software is provided 'as-is', without any express or implied
6
warranty. In no event will the authors be held liable for any damages
7
arising from the use of this software.
8
9
Permission is granted to anyone to use this software for any purpose,
10
including commercial applications, and to alter it and redistribute it
11
freely, subject to the following restrictions:
12
13
1. The origin of this software must not be misrepresented; you must not
14
claim that you wrote the original software. If you use this software
15
in a product, an acknowledgment in the product documentation would be
16
appreciated but is not required.
17
2. Altered source versions must be plainly marked as such, and must not be
18
misrepresented as being the original software.
19
3. This notice may not be removed or altered from any source distribution.
20
*/
21
22
/**
23
* \file SDL_init.h
24
*
25
* Init and quit header for the SDL library
26
*/
27
28
#ifndef SDL_init_h_
29
#define SDL_init_h_
30
31
#include <
SDL3/SDL_stdinc.h
>
32
33
#include <
SDL3/SDL_begin_code.h
>
34
/* Set up for C function definitions, even when using C++ */
35
#ifdef __cplusplus
36
extern
"C"
{
37
#endif
38
39
/* As of version 0.5, SDL is loaded dynamically into the application */
40
41
/**
42
* Initialization flags for SDL_Init and/or SDL_InitSubSystem
43
*
44
* These are the flags which may be passed to SDL_Init(). You should
45
* specify the subsystems which you will be using in your application.
46
*
47
* \sa SDL_Init
48
* \sa SDL_Quit
49
* \sa SDL_InitSubSystem
50
* \sa SDL_QuitSubSystem
51
* \sa SDL_WasInit
52
*/
53
typedef
enum
54
{
55
SDL_INIT_TIMER
= 0x00000001,
56
SDL_INIT_AUDIO
= 0x00000010,
57
SDL_INIT_VIDEO
= 0x00000020,
/**< `SDL_INIT_VIDEO` implies `SDL_INIT_EVENTS` */
58
SDL_INIT_JOYSTICK
= 0x00000200,
/**< `SDL_INIT_JOYSTICK` implies `SDL_INIT_EVENTS` */
59
SDL_INIT_HAPTIC
= 0x00001000,
60
SDL_INIT_GAMEPAD
= 0x00002000,
/**< `SDL_INIT_GAMEPAD` implies `SDL_INIT_JOYSTICK` */
61
SDL_INIT_EVENTS
= 0x00004000,
62
SDL_INIT_SENSOR
= 0x00008000
63
}
SDL_InitFlags
;
64
65
/**
66
* Initialize the SDL library.
67
*
68
* SDL_Init() simply forwards to calling SDL_InitSubSystem(). Therefore, the
69
* two may be used interchangeably. Though for readability of your code
70
* SDL_InitSubSystem() might be preferred.
71
*
72
* The file I/O (for example: SDL_RWFromFile) and threading (SDL_CreateThread)
73
* subsystems are initialized by default. Message boxes
74
* (SDL_ShowSimpleMessageBox) also attempt to work without initializing the
75
* video subsystem, in hopes of being useful in showing an error dialog when
76
* SDL_Init fails. You must specifically initialize other subsystems if you
77
* use them in your application.
78
*
79
* Logging (such as SDL_Log) works without initialization, too.
80
*
81
* `flags` may be any of the following OR'd together:
82
*
83
* - `SDL_INIT_TIMER`: timer subsystem
84
* - `SDL_INIT_AUDIO`: audio subsystem
85
* - `SDL_INIT_VIDEO`: video subsystem; automatically initializes the events
86
* subsystem
87
* - `SDL_INIT_JOYSTICK`: joystick subsystem; automatically initializes the
88
* events subsystem
89
* - `SDL_INIT_HAPTIC`: haptic (force feedback) subsystem
90
* - `SDL_INIT_GAMEPAD`: gamepad subsystem; automatically initializes the
91
* joystick subsystem
92
* - `SDL_INIT_EVENTS`: events subsystem
93
* - `SDL_INIT_SENSOR`: sensor subsystem
94
*
95
* Subsystem initialization is ref-counted, you must call SDL_QuitSubSystem()
96
* for each SDL_InitSubSystem() to correctly shutdown a subsystem manually (or
97
* call SDL_Quit() to force shutdown). If a subsystem is already loaded then
98
* this call will increase the ref-count and return.
99
*
100
* \param flags subsystem initialization flags
101
* \returns 0 on success or a negative error code on failure; call
102
* SDL_GetError() for more information.
103
*
104
* \since This function is available since SDL 3.0.0.
105
*
106
* \sa SDL_InitSubSystem
107
* \sa SDL_Quit
108
* \sa SDL_SetMainReady
109
* \sa SDL_WasInit
110
*/
111
extern
DECLSPEC
int
SDLCALL
SDL_Init
(
Uint32
flags);
112
113
/**
114
* Compatibility function to initialize the SDL library.
115
*
116
* This function and SDL_Init() are interchangeable.
117
*
118
* \param flags any of the flags used by SDL_Init(); see SDL_Init for details.
119
* \returns 0 on success or a negative error code on failure; call
120
* SDL_GetError() for more information.
121
*
122
* \since This function is available since SDL 3.0.0.
123
*
124
* \sa SDL_Init
125
* \sa SDL_Quit
126
* \sa SDL_QuitSubSystem
127
*/
128
extern
DECLSPEC
int
SDLCALL
SDL_InitSubSystem
(
Uint32
flags);
129
130
/**
131
* Shut down specific SDL subsystems.
132
*
133
* You still need to call SDL_Quit() even if you close all open subsystems
134
* with SDL_QuitSubSystem().
135
*
136
* \param flags any of the flags used by SDL_Init(); see SDL_Init for details.
137
*
138
* \since This function is available since SDL 3.0.0.
139
*
140
* \sa SDL_InitSubSystem
141
* \sa SDL_Quit
142
*/
143
extern
DECLSPEC
void
SDLCALL
SDL_QuitSubSystem
(
Uint32
flags);
144
145
/**
146
* Get a mask of the specified subsystems which are currently initialized.
147
*
148
* \param flags any of the flags used by SDL_Init(); see SDL_Init for details.
149
* \returns a mask of all initialized subsystems if `flags` is 0, otherwise it
150
* returns the initialization status of the specified subsystems.
151
*
152
* \since This function is available since SDL 3.0.0.
153
*
154
* \sa SDL_Init
155
* \sa SDL_InitSubSystem
156
*/
157
extern
DECLSPEC
Uint32
SDLCALL
SDL_WasInit
(
Uint32
flags);
158
159
/**
160
* Clean up all initialized subsystems.
161
*
162
* You should call this function even if you have already shutdown each
163
* initialized subsystem with SDL_QuitSubSystem(). It is safe to call this
164
* function even in the case of errors in initialization.
165
*
166
* You can use this function with atexit() to ensure that it is run when your
167
* application is shutdown, but it is not wise to do this from a library or
168
* other dynamically loaded code.
169
*
170
* \since This function is available since SDL 3.0.0.
171
*
172
* \sa SDL_Init
173
* \sa SDL_QuitSubSystem
174
*/
175
extern
DECLSPEC
void
SDLCALL
SDL_Quit
(
void
);
176
177
/* Ends C function definitions when using C++ */
178
#ifdef __cplusplus
179
}
180
#endif
181
#include <
SDL3/SDL_close_code.h
>
182
183
#endif
/* SDL_init_h_ */
SDL_begin_code.h
SDL_close_code.h
SDL_WasInit
Uint32 SDL_WasInit(Uint32 flags)
SDL_InitSubSystem
int SDL_InitSubSystem(Uint32 flags)
SDL_InitFlags
SDL_InitFlags
Definition
SDL_init.h:54
SDL_INIT_HAPTIC
@ SDL_INIT_HAPTIC
Definition
SDL_init.h:59
SDL_INIT_JOYSTICK
@ SDL_INIT_JOYSTICK
Definition
SDL_init.h:58
SDL_INIT_GAMEPAD
@ SDL_INIT_GAMEPAD
Definition
SDL_init.h:60
SDL_INIT_SENSOR
@ SDL_INIT_SENSOR
Definition
SDL_init.h:62
SDL_INIT_TIMER
@ SDL_INIT_TIMER
Definition
SDL_init.h:55
SDL_INIT_AUDIO
@ SDL_INIT_AUDIO
Definition
SDL_init.h:56
SDL_INIT_VIDEO
@ SDL_INIT_VIDEO
Definition
SDL_init.h:57
SDL_INIT_EVENTS
@ SDL_INIT_EVENTS
Definition
SDL_init.h:61
SDL_QuitSubSystem
void SDL_QuitSubSystem(Uint32 flags)
SDL_Quit
void SDL_Quit(void)
SDL_Init
int SDL_Init(Uint32 flags)
SDL_stdinc.h
Uint32
uint32_t Uint32
Definition
SDL_stdinc.h:174
include
SDL3
SDL_init.h
Generated by
1.9.8