SDL 3.0
SDL_main.h
Go to the documentation of this file.
1/*
2 Simple DirectMedia Layer
3 Copyright (C) 1997-2025 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 * # CategoryMain
24 *
25 * Redefine main() if necessary so that it is called by SDL.
26 *
27 * In order to make this consistent on all platforms, the application's main()
28 * should look like this:
29 *
30 * ```c
31 * int main(int argc, char *argv[])
32 * {
33 * }
34 * ```
35 *
36 * SDL will take care of platform specific details on how it gets called.
37 *
38 * This is also where an app can be configured to use the main callbacks, via
39 * the SDL_MAIN_USE_CALLBACKS macro.
40 *
41 * This is a "single-header library," which is to say that including this
42 * header inserts code into your program, and you should only include it once
43 * in most cases. SDL.h does not include this header automatically.
44 *
45 * For more information, see:
46 *
47 * https://wiki.libsdl.org/SDL3/README/main-functions
48 */
49
50#ifndef SDL_main_h_
51#define SDL_main_h_
52
54#include <SDL3/SDL_stdinc.h>
55#include <SDL3/SDL_error.h>
56#include <SDL3/SDL_events.h>
57
58#ifdef SDL_WIKI_DOCUMENTATION_SECTION
59
60/**
61 * Inform SDL that the app is providing an entry point instead of SDL.
62 *
63 * SDL does not define this macro, but will check if it is defined when
64 * including `SDL_main.h`. If defined, SDL will expect the app to provide the
65 * proper entry point for the platform, and all the other magic details
66 * needed, like manually calling SDL_SetMainReady.
67 *
68 * Please see [README/main-functions](README/main-functions), (or
69 * docs/README-main-functions.md in the source tree) for a more detailed
70 * explanation.
71 *
72 * \since This macro is used by the headers since SDL 3.2.0.
73 */
74#define SDL_MAIN_HANDLED 1
75
76/**
77 * Inform SDL to use the main callbacks instead of main.
78 *
79 * SDL does not define this macro, but will check if it is defined when
80 * including `SDL_main.h`. If defined, SDL will expect the app to provide
81 * several functions: SDL_AppInit, SDL_AppEvent, SDL_AppIterate, and
82 * SDL_AppQuit. The app should not provide a `main` function in this case, and
83 * doing so will likely cause the build to fail.
84 *
85 * Please see [README/main-functions](README/main-functions), (or
86 * docs/README-main-functions.md in the source tree) for a more detailed
87 * explanation.
88 *
89 * \since This macro is used by the headers since SDL 3.2.0.
90 *
91 * \sa SDL_AppInit
92 * \sa SDL_AppEvent
93 * \sa SDL_AppIterate
94 * \sa SDL_AppQuit
95 */
96#define SDL_MAIN_USE_CALLBACKS 1
97
98/**
99 * Defined if the target platform offers a special mainline through SDL.
100 *
101 * This won't be defined otherwise. If defined, SDL's headers will redefine
102 * `main` to `SDL_main`.
103 *
104 * This macro is defined by `SDL_main.h`, which is not automatically included
105 * by `SDL.h`.
106 *
107 * Even if available, an app can define SDL_MAIN_HANDLED and provide their
108 * own, if they know what they're doing.
109 *
110 * This macro is used internally by SDL, and apps probably shouldn't rely on it.
111 *
112 * \since This macro is available since SDL 3.2.0.
113 */
114#define SDL_MAIN_AVAILABLE
115
116/**
117 * Defined if the target platform _requires_ a special mainline through SDL.
118 *
119 * This won't be defined otherwise. If defined, SDL's headers will redefine
120 * `main` to `SDL_main`.
121 *
122 * This macro is defined by `SDL_main.h`, which is not automatically included
123 * by `SDL.h`.
124 *
125 * Even if required, an app can define SDL_MAIN_HANDLED and provide their
126 * own, if they know what they're doing.
127 *
128 * This macro is used internally by SDL, and apps probably shouldn't rely on it.
129 *
130 * \since This macro is available since SDL 3.2.0.
131 */
132#define SDL_MAIN_NEEDED
133
134#endif
135
136#if defined(__has_include)
137 #if __has_include("SDL_main_private.h") && __has_include("SDL_main_impl_private.h")
138 #define SDL_PLATFORM_PRIVATE_MAIN
139 #endif
140#endif
141
142#ifndef SDL_MAIN_HANDLED
143 #if defined(SDL_PLATFORM_PRIVATE_MAIN)
144 /* Private platforms may have their own ideas about entry points. */
145 #include "SDL_main_private.h"
146
147 #elif defined(SDL_PLATFORM_WIN32)
148 /* On Windows SDL provides WinMain(), which parses the command line and passes
149 the arguments to your main function.
150
151 If you provide your own WinMain(), you may define SDL_MAIN_HANDLED
152 */
153 #define SDL_MAIN_AVAILABLE
154
155 #elif defined(SDL_PLATFORM_GDK)
156 /* On GDK, SDL provides a main function that initializes the game runtime.
157
158 If you prefer to write your own WinMain-function instead of having SDL
159 provide one that calls your main() function,
160 #define SDL_MAIN_HANDLED before #include'ing SDL_main.h
161 and call the SDL_RunApp function from your entry point.
162 */
163 #define SDL_MAIN_NEEDED
164
165 #elif defined(SDL_PLATFORM_IOS)
166 /* On iOS SDL provides a main function that creates an application delegate
167 and starts the iOS application run loop.
168
169 To use it, just #include SDL_main.h in the source file that contains your
170 main() function.
171
172 See src/video/uikit/SDL_uikitappdelegate.m for more details.
173 */
174 #define SDL_MAIN_NEEDED
175
176 #elif defined(SDL_PLATFORM_ANDROID)
177 /* On Android SDL provides a Java class in SDLActivity.java that is the
178 main activity entry point.
179
180 See docs/README-android.md for more details on extending that class.
181 */
182 #define SDL_MAIN_NEEDED
183
184 /* As this is launched from Java, the real entry point (main() function)
185 is outside of the the binary built from this code.
186 This define makes sure that, unlike on other platforms, SDL_main.h
187 and SDL_main_impl.h export an `SDL_main()` function (to be called
188 from Java), but don't implement a native `int main(int argc, char* argv[])`
189 or similar.
190 */
191 #define SDL_MAIN_EXPORTED
192
193 #elif defined(SDL_PLATFORM_EMSCRIPTEN)
194 /* On Emscripten, SDL provides a main function that converts URL
195 parameters that start with "SDL_" to environment variables, so
196 they can be used as SDL hints, etc.
197
198 This is 100% optional, so if you don't want this to happen, you may
199 define SDL_MAIN_HANDLED
200 */
201 #define SDL_MAIN_AVAILABLE
202
203 #elif defined(SDL_PLATFORM_PSP)
204 /* On PSP SDL provides a main function that sets the module info,
205 activates the GPU and starts the thread required to be able to exit
206 the software.
207
208 If you provide this yourself, you may define SDL_MAIN_HANDLED
209 */
210 #define SDL_MAIN_AVAILABLE
211
212 #elif defined(SDL_PLATFORM_PS2)
213 #define SDL_MAIN_AVAILABLE
214
215 #define SDL_PS2_SKIP_IOP_RESET() \
216 void reset_IOP(); \
217 void reset_IOP() {}
218
219 #elif defined(SDL_PLATFORM_3DS)
220 /*
221 On N3DS, SDL provides a main function that sets up the screens
222 and storage.
223
224 If you provide this yourself, you may define SDL_MAIN_HANDLED
225 */
226 #define SDL_MAIN_AVAILABLE
227
228 #endif
229#endif /* SDL_MAIN_HANDLED */
230
231
232#ifdef SDL_WIKI_DOCUMENTATION_SECTION
233
234/**
235 * A macro to tag a main entry point function as exported.
236 *
237 * Most platforms don't need this, and the macro will be defined to nothing.
238 * Some, like Android, keep the entry points in a shared library and need to
239 * explicitly export the symbols.
240 *
241 * External code rarely needs this, and if it needs something, it's almost
242 * always SDL_DECLSPEC instead.
243 *
244 * \since This macro is available since SDL 3.2.0.
245 *
246 * \sa SDL_DECLSPEC
247 */
248#define SDLMAIN_DECLSPEC
249
250#elif defined(SDL_MAIN_EXPORTED)
251/* We need to export SDL_main so it can be launched from external code,
252 like SDLActivity.java on Android */
253#define SDLMAIN_DECLSPEC SDL_DECLSPEC
254#else
255/* usually this is empty */
256#define SDLMAIN_DECLSPEC
257#endif /* SDL_MAIN_EXPORTED */
258
259#if defined(SDL_MAIN_NEEDED) || defined(SDL_MAIN_AVAILABLE) || defined(SDL_MAIN_USE_CALLBACKS)
260#define main SDL_main
261#endif
262
263#include <SDL3/SDL_init.h>
264#include <SDL3/SDL_begin_code.h>
265#ifdef __cplusplus
266extern "C" {
267#endif
268
269/*
270 * You can (optionally!) define SDL_MAIN_USE_CALLBACKS before including
271 * SDL_main.h, and then your application will _not_ have a standard
272 * "main" entry point. Instead, it will operate as a collection of
273 * functions that are called as necessary by the system. On some
274 * platforms, this is just a layer where SDL drives your program
275 * instead of your program driving SDL, on other platforms this might
276 * hook into the OS to manage the lifecycle. Programs on most platforms
277 * can use whichever approach they prefer, but the decision boils down
278 * to:
279 *
280 * - Using a standard "main" function: this works like it always has for
281 * the past 50+ years in C programming, and your app is in control.
282 * - Using the callback functions: this might clean up some code,
283 * avoid some #ifdef blocks in your program for some platforms, be more
284 * resource-friendly to the system, and possibly be the primary way to
285 * access some future platforms (but none require this at the moment).
286 *
287 * This is up to the app; both approaches are considered valid and supported
288 * ways to write SDL apps.
289 *
290 * If using the callbacks, don't define a "main" function. Instead, implement
291 * the functions listed below in your program.
292 */
293#ifdef SDL_MAIN_USE_CALLBACKS
294
295/**
296 * App-implemented initial entry point for SDL_MAIN_USE_CALLBACKS apps.
297 *
298 * Apps implement this function when using SDL_MAIN_USE_CALLBACKS. If using a
299 * standard "main" function, you should not supply this.
300 *
301 * This function is called by SDL once, at startup. The function should
302 * initialize whatever is necessary, possibly create windows and open audio
303 * devices, etc. The `argc` and `argv` parameters work like they would with a
304 * standard "main" function.
305 *
306 * This function should not go into an infinite mainloop; it should do any
307 * one-time setup it requires and then return.
308 *
309 * The app may optionally assign a pointer to `*appstate`. This pointer will
310 * be provided on every future call to the other entry points, to allow
311 * application state to be preserved between functions without the app needing
312 * to use a global variable. If this isn't set, the pointer will be NULL in
313 * future entry points.
314 *
315 * If this function returns SDL_APP_CONTINUE, the app will proceed to normal
316 * operation, and will begin receiving repeated calls to SDL_AppIterate and
317 * SDL_AppEvent for the life of the program. If this function returns
318 * SDL_APP_FAILURE, SDL will call SDL_AppQuit and terminate the process with
319 * an exit code that reports an error to the platform. If it returns
320 * SDL_APP_SUCCESS, SDL calls SDL_AppQuit and terminates with an exit code
321 * that reports success to the platform.
322 *
323 * This function is called by SDL on the main thread.
324 *
325 * \param appstate a place where the app can optionally store a pointer for
326 * future use.
327 * \param argc the standard ANSI C main's argc; number of elements in `argv`.
328 * \param argv the standard ANSI C main's argv; array of command line
329 * arguments.
330 * \returns SDL_APP_FAILURE to terminate with an error, SDL_APP_SUCCESS to
331 * terminate with success, SDL_APP_CONTINUE to continue.
332 *
333 * \since This function is available since SDL 3.2.0.
334 *
335 * \sa SDL_AppIterate
336 * \sa SDL_AppEvent
337 * \sa SDL_AppQuit
338 */
339extern SDLMAIN_DECLSPEC SDL_AppResult SDLCALL SDL_AppInit(void **appstate, int argc, char *argv[]);
340
341/**
342 * App-implemented iteration entry point for SDL_MAIN_USE_CALLBACKS apps.
343 *
344 * Apps implement this function when using SDL_MAIN_USE_CALLBACKS. If using a
345 * standard "main" function, you should not supply this.
346 *
347 * This function is called repeatedly by SDL after SDL_AppInit returns 0. The
348 * function should operate as a single iteration the program's primary loop;
349 * it should update whatever state it needs and draw a new frame of video,
350 * usually.
351 *
352 * On some platforms, this function will be called at the refresh rate of the
353 * display (which might change during the life of your app!). There are no
354 * promises made about what frequency this function might run at. You should
355 * use SDL's timer functions if you need to see how much time has passed since
356 * the last iteration.
357 *
358 * There is no need to process the SDL event queue during this function; SDL
359 * will send events as they arrive in SDL_AppEvent, and in most cases the
360 * event queue will be empty when this function runs anyhow.
361 *
362 * This function should not go into an infinite mainloop; it should do one
363 * iteration of whatever the program does and return.
364 *
365 * The `appstate` parameter is an optional pointer provided by the app during
366 * SDL_AppInit(). If the app never provided a pointer, this will be NULL.
367 *
368 * If this function returns SDL_APP_CONTINUE, the app will continue normal
369 * operation, receiving repeated calls to SDL_AppIterate and SDL_AppEvent for
370 * the life of the program. If this function returns SDL_APP_FAILURE, SDL will
371 * call SDL_AppQuit and terminate the process with an exit code that reports
372 * an error to the platform. If it returns SDL_APP_SUCCESS, SDL calls
373 * SDL_AppQuit and terminates with an exit code that reports success to the
374 * platform.
375 *
376 * This function is called by SDL on the main thread.
377 *
378 * \param appstate an optional pointer, provided by the app in SDL_AppInit.
379 * \returns SDL_APP_FAILURE to terminate with an error, SDL_APP_SUCCESS to
380 * terminate with success, SDL_APP_CONTINUE to continue.
381 *
382 * \threadsafety This function may get called concurrently with SDL_AppEvent()
383 * for events not pushed on the main thread.
384 *
385 * \since This function is available since SDL 3.2.0.
386 *
387 * \sa SDL_AppInit
388 * \sa SDL_AppEvent
389 */
390extern SDLMAIN_DECLSPEC SDL_AppResult SDLCALL SDL_AppIterate(void *appstate);
391
392/**
393 * App-implemented event entry point for SDL_MAIN_USE_CALLBACKS apps.
394 *
395 * Apps implement this function when using SDL_MAIN_USE_CALLBACKS. If using a
396 * standard "main" function, you should not supply this.
397 *
398 * This function is called as needed by SDL after SDL_AppInit returns
399 * SDL_APP_CONTINUE. It is called once for each new event.
400 *
401 * There is (currently) no guarantee about what thread this will be called
402 * from; whatever thread pushes an event onto SDL's queue will trigger this
403 * function. SDL is responsible for pumping the event queue between each call
404 * to SDL_AppIterate, so in normal operation one should only get events in a
405 * serial fashion, but be careful if you have a thread that explicitly calls
406 * SDL_PushEvent. SDL itself will push events to the queue on the main thread.
407 *
408 * Events sent to this function are not owned by the app; if you need to save
409 * the data, you should copy it.
410 *
411 * This function should not go into an infinite mainloop; it should handle the
412 * provided event appropriately and return.
413 *
414 * The `appstate` parameter is an optional pointer provided by the app during
415 * SDL_AppInit(). If the app never provided a pointer, this will be NULL.
416 *
417 * If this function returns SDL_APP_CONTINUE, the app will continue normal
418 * operation, receiving repeated calls to SDL_AppIterate and SDL_AppEvent for
419 * the life of the program. If this function returns SDL_APP_FAILURE, SDL will
420 * call SDL_AppQuit and terminate the process with an exit code that reports
421 * an error to the platform. If it returns SDL_APP_SUCCESS, SDL calls
422 * SDL_AppQuit and terminates with an exit code that reports success to the
423 * platform.
424 *
425 * \param appstate an optional pointer, provided by the app in SDL_AppInit.
426 * \param event the new event for the app to examine.
427 * \returns SDL_APP_FAILURE to terminate with an error, SDL_APP_SUCCESS to
428 * terminate with success, SDL_APP_CONTINUE to continue.
429 *
430 * \threadsafety This function may get called concurrently with
431 * SDL_AppIterate() or SDL_AppQuit() for events not pushed from
432 * the main thread.
433 *
434 * \since This function is available since SDL 3.2.0.
435 *
436 * \sa SDL_AppInit
437 * \sa SDL_AppIterate
438 */
439extern SDLMAIN_DECLSPEC SDL_AppResult SDLCALL SDL_AppEvent(void *appstate, SDL_Event *event);
440
441/**
442 * App-implemented deinit entry point for SDL_MAIN_USE_CALLBACKS apps.
443 *
444 * Apps implement this function when using SDL_MAIN_USE_CALLBACKS. If using a
445 * standard "main" function, you should not supply this.
446 *
447 * This function is called once by SDL before terminating the program.
448 *
449 * This function will be called no matter what, even if SDL_AppInit requests
450 * termination.
451 *
452 * This function should not go into an infinite mainloop; it should
453 * deinitialize any resources necessary, perform whatever shutdown activities,
454 * and return.
455 *
456 * You do not need to call SDL_Quit() in this function, as SDL will call it
457 * after this function returns and before the process terminates, but it is
458 * safe to do so.
459 *
460 * The `appstate` parameter is an optional pointer provided by the app during
461 * SDL_AppInit(). If the app never provided a pointer, this will be NULL. This
462 * function call is the last time this pointer will be provided, so any
463 * resources to it should be cleaned up here.
464 *
465 * This function is called by SDL on the main thread.
466 *
467 * \param appstate an optional pointer, provided by the app in SDL_AppInit.
468 * \param result the result code that terminated the app (success or failure).
469 *
470 * \threadsafety SDL_AppEvent() may get called concurrently with this function
471 * if other threads that push events are still active.
472 *
473 * \since This function is available since SDL 3.2.0.
474 *
475 * \sa SDL_AppInit
476 */
477extern SDLMAIN_DECLSPEC void SDLCALL SDL_AppQuit(void *appstate, SDL_AppResult result);
478
479#endif /* SDL_MAIN_USE_CALLBACKS */
480
481
482/**
483 * The prototype for the application's main() function
484 *
485 * \param argc an ANSI-C style main function's argc.
486 * \param argv an ANSI-C style main function's argv.
487 * \returns an ANSI-C main return code; generally 0 is considered successful
488 * program completion, and small non-zero values are considered
489 * errors.
490 *
491 * \since This datatype is available since SDL 3.2.0.
492 */
493typedef int (SDLCALL *SDL_main_func)(int argc, char *argv[]);
494
495/**
496 * An app-supplied function for program entry.
497 *
498 * Apps do not directly create this function; they should create a standard
499 * ANSI-C `main` function instead. If SDL needs to insert some startup code
500 * before `main` runs, or the platform doesn't actually _use_ a function
501 * called "main", SDL will do some macro magic to redefine `main` to
502 * `SDL_main` and provide its own `main`.
503 *
504 * Apps should include `SDL_main.h` in the same file as their `main` function,
505 * and they should not use that symbol for anything else in that file, as it
506 * might get redefined.
507 *
508 * This function is only provided by the app if it isn't using
509 * SDL_MAIN_USE_CALLBACKS.
510 *
511 * Program startup is a surprisingly complex topic. Please see
512 * [README/main-functions](README/main-functions), (or
513 * docs/README-main-functions.md in the source tree) for a more detailed
514 * explanation.
515 *
516 * \param argc an ANSI-C style main function's argc.
517 * \param argv an ANSI-C style main function's argv.
518 * \returns an ANSI-C main return code; generally 0 is considered successful
519 * program completion, and small non-zero values are considered
520 * errors.
521 *
522 * \threadsafety This is the program entry point.
523 *
524 * \since This function is available since SDL 3.2.0.
525 */
526extern SDLMAIN_DECLSPEC int SDLCALL SDL_main(int argc, char *argv[]);
527
528/**
529 * Circumvent failure of SDL_Init() when not using SDL_main() as an entry
530 * point.
531 *
532 * This function is defined in SDL_main.h, along with the preprocessor rule to
533 * redefine main() as SDL_main(). Thus to ensure that your main() function
534 * will not be changed it is necessary to define SDL_MAIN_HANDLED before
535 * including SDL.h.
536 *
537 * \since This function is available since SDL 3.2.0.
538 *
539 * \sa SDL_Init
540 */
541extern SDL_DECLSPEC void SDLCALL SDL_SetMainReady(void);
542
543/**
544 * Initializes and launches an SDL application, by doing platform-specific
545 * initialization before calling your mainFunction and cleanups after it
546 * returns, if that is needed for a specific platform, otherwise it just calls
547 * mainFunction.
548 *
549 * You can use this if you want to use your own main() implementation without
550 * using SDL_main (like when using SDL_MAIN_HANDLED). When using this, you do
551 * *not* need SDL_SetMainReady().
552 *
553 * \param argc the argc parameter from the application's main() function, or 0
554 * if the platform's main-equivalent has no argc.
555 * \param argv the argv parameter from the application's main() function, or
556 * NULL if the platform's main-equivalent has no argv.
557 * \param mainFunction your SDL app's C-style main(). NOT the function you're
558 * calling this from! Its name doesn't matter; it doesn't
559 * literally have to be `main`.
560 * \param reserved should be NULL (reserved for future use, will probably be
561 * platform-specific then).
562 * \returns the return value from mainFunction: 0 on success, otherwise
563 * failure; SDL_GetError() might have more information on the
564 * failure.
565 *
566 * \threadsafety Generally this is called once, near startup, from the
567 * process's initial thread.
568 *
569 * \since This function is available since SDL 3.2.0.
570 */
571extern SDL_DECLSPEC int SDLCALL SDL_RunApp(int argc, char *argv[], SDL_main_func mainFunction, void *reserved);
572
573/**
574 * An entry point for SDL's use in SDL_MAIN_USE_CALLBACKS.
575 *
576 * Generally, you should not call this function directly. This only exists to
577 * hand off work into SDL as soon as possible, where it has a lot more control
578 * and functionality available, and make the inline code in SDL_main.h as
579 * small as possible.
580 *
581 * Not all platforms use this, it's actual use is hidden in a magic
582 * header-only library, and you should not call this directly unless you
583 * _really_ know what you're doing.
584 *
585 * \param argc standard Unix main argc.
586 * \param argv standard Unix main argv.
587 * \param appinit the application's SDL_AppInit function.
588 * \param appiter the application's SDL_AppIterate function.
589 * \param appevent the application's SDL_AppEvent function.
590 * \param appquit the application's SDL_AppQuit function.
591 * \returns standard Unix main return value.
592 *
593 * \threadsafety It is not safe to call this anywhere except as the only
594 * function call in SDL_main.
595 *
596 * \since This function is available since SDL 3.2.0.
597 */
598extern SDL_DECLSPEC int SDLCALL SDL_EnterAppMainCallbacks(int argc, char *argv[], SDL_AppInit_func appinit, SDL_AppIterate_func appiter, SDL_AppEvent_func appevent, SDL_AppQuit_func appquit);
599
600
601#if defined(SDL_PLATFORM_WINDOWS)
602
603/**
604 * Register a win32 window class for SDL's use.
605 *
606 * This can be called to set the application window class at startup. It is
607 * safe to call this multiple times, as long as every call is eventually
608 * paired with a call to SDL_UnregisterApp, but a second registration attempt
609 * while a previous registration is still active will be ignored, other than
610 * to increment a counter.
611 *
612 * Most applications do not need to, and should not, call this directly; SDL
613 * will call it when initializing the video subsystem.
614 *
615 * \param name the window class name, in UTF-8 encoding. If NULL, SDL
616 * currently uses "SDL_app" but this isn't guaranteed.
617 * \param style the value to use in WNDCLASSEX::style. If `name` is NULL, SDL
618 * currently uses `(CS_BYTEALIGNCLIENT | CS_OWNDC)` regardless of
619 * what is specified here.
620 * \param hInst the HINSTANCE to use in WNDCLASSEX::hInstance. If zero, SDL
621 * will use `GetModuleHandle(NULL)` instead.
622 * \returns true on success or false on failure; call SDL_GetError() for more
623 * information.
624 *
625 * \since This function is available since SDL 3.2.0.
626 */
627extern SDL_DECLSPEC bool SDLCALL SDL_RegisterApp(const char *name, Uint32 style, void *hInst);
628
629/**
630 * Deregister the win32 window class from an SDL_RegisterApp call.
631 *
632 * This can be called to undo the effects of SDL_RegisterApp.
633 *
634 * Most applications do not need to, and should not, call this directly; SDL
635 * will call it when deinitializing the video subsystem.
636 *
637 * It is safe to call this multiple times, as long as every call is eventually
638 * paired with a prior call to SDL_RegisterApp. The window class will only be
639 * deregistered when the registration counter in SDL_RegisterApp decrements to
640 * zero through calls to this function.
641 *
642 * \since This function is available since SDL 3.2.0.
643 */
644extern SDL_DECLSPEC void SDLCALL SDL_UnregisterApp(void);
645
646#endif /* defined(SDL_PLATFORM_WINDOWS) */
647
648/**
649 * Callback from the application to let the suspend continue.
650 *
651 * This function is only needed for Xbox GDK support; all other platforms will
652 * do nothing and set an "unsupported" error message.
653 *
654 * \since This function is available since SDL 3.2.0.
655 */
656extern SDL_DECLSPEC void SDLCALL SDL_GDKSuspendComplete(void);
657
658#ifdef __cplusplus
659}
660#endif
661
662#include <SDL3/SDL_close_code.h>
663
664#if !defined(SDL_MAIN_HANDLED) && !defined(SDL_MAIN_NOIMPL)
665 /* include header-only SDL_main implementations */
666 #if defined(SDL_MAIN_USE_CALLBACKS) || defined(SDL_MAIN_NEEDED) || defined(SDL_MAIN_AVAILABLE)
667 /* platforms which main (-equivalent) can be implemented in plain C */
668 #include <SDL3/SDL_main_impl.h>
669 #endif
670#endif
671
672#endif /* SDL_main_h_ */
SDL_AppResult(* SDL_AppEvent_func)(void *appstate, SDL_Event *event)
Definition SDL_init.h:164
SDL_AppResult(* SDL_AppInit_func)(void **appstate, int argc, char *argv[])
Definition SDL_init.h:133
SDL_AppResult
Definition SDL_init.h:110
void(* SDL_AppQuit_func)(void *appstate, SDL_AppResult result)
Definition SDL_init.h:178
SDL_AppResult(* SDL_AppIterate_func)(void *appstate)
Definition SDL_init.h:148
void SDL_SetMainReady(void)
SDLMAIN_DECLSPEC int SDL_main(int argc, char *argv[])
#define SDLMAIN_DECLSPEC
Definition SDL_main.h:256
int(* SDL_main_func)(int argc, char *argv[])
Definition SDL_main.h:493
int SDL_EnterAppMainCallbacks(int argc, char *argv[], SDL_AppInit_func appinit, SDL_AppIterate_func appiter, SDL_AppEvent_func appevent, SDL_AppQuit_func appquit)
int SDL_RunApp(int argc, char *argv[], SDL_main_func mainFunction, void *reserved)
void SDL_GDKSuspendComplete(void)
uint32_t Uint32
Definition SDL_stdinc.h:461
void SDL_AppQuit(void *appstate, SDL_AppResult result)
Definition hello.c:65
SDL_AppResult SDL_AppInit(void **appstate, int argc, char *argv[])
Definition hello.c:20
SDL_AppResult SDL_AppIterate(void *appstate)
Definition hello.c:41
SDL_AppResult SDL_AppEvent(void *appstate, SDL_Event *event)
Definition hello.c:31