main topic

CategoryMain

Redefine main() if necessary so that it is called by SDL.

In order to make this consistent on all platforms, the application's main() should look like this:

#include <SDL3/SDL.h>
#include <SDL3/SDL_main.h>

int main(int argc, char *argv[])
{
}

SDL will take care of platform specific details on how it gets called.

This is also where an app can be configured to use the main callbacks, via the SDL_MAIN_USE_CALLBACKS macro.

SDL_main.h is a "single-header library," which is to say that including this header inserts code into your program, and you should only include it once in most cases. SDL.h does not include this header automatically.

For more information, see:

https://wiki.libsdl.org/SDL3/README-main-functions

Functions

sdlEnterAppMainCallbacks(int argc, Pointer<Pointer<Int8>> argv, Pointer<NativeFunction<SdlAppInitFunc>> appinit, Pointer<NativeFunction<SdlAppIterateFunc>> appiter, Pointer<NativeFunction<SdlAppEventFunc>> appevent, Pointer<NativeFunction<SdlAppQuitFunc>> appquit) int main
An entry point for SDL's use in SDL_MAIN_USE_CALLBACKS.
sdlGdkSuspendComplete() → void main
Callback from the application to let the suspend continue.
sdlRegisterApp(String? name, int style, Pointer<NativeType> hInst) bool main
Register a win32 window class for SDL's use.
sdlRunApp(int argc, Pointer<Pointer<Int8>> argv, Pointer<NativeFunction<SdlMainFunc>> mainFunction, Pointer<NativeType> reserved) int main
Initializes and launches an SDL application, by doing platform-specific initialization before calling your mainFunction and cleanups after it returns, if that is needed for a specific platform, otherwise it just calls mainFunction.
sdlSetMainReady() → void main
Circumvent failure of SDL_Init() when not using SDL_main() as an entry point.
sdlUnregisterApp() → void main
Deregister the win32 window class from an SDL_RegisterApp call.