Your Donations help keep my Software going!
I'm on a short vacation and will be back soon.
I'm selling some Homebrew Game Dev Devices. Check it out.
BootstrapNative
Description
tBootstrapNative.cpp contains the entry point for the native platform. Platforms can occasionally have entry points other than main that are unique to their platform. For instance, on Win32, the entry point is WinMain.
Once in the entry point, there are typically startup and shutdown routines that need to be called before and after the main portion of the program. To abstract this out so that native code never has to be written from within the application, this is to be done within the entry point, not within program_main.
Generally, the contract of the entry point is to:
- Call startup routines
- Save any platform-specific information needed later
- Call program_main
- Call shutdown routines
- Return exit code produced by program_main
Example
This is an example of what a Win32 entry point that calls program_main might look like.
//The Platform's actual main routine int __stdcall WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { char **argv; int argc; int result; gWin32Instance = hInstance; // Get argc, argv argv = (char**)CommandLineToArgvW(GetCommandLineW(), &argc); // Call main result = (int)program_main((tUInt32)argc, argv); // Free argv LocalFree(argv); // Return result from main return result; }
Notes
- Singleton classes exist outside of the entry point; you are guaranteed that they are initialized before the entry point and destroyed after it.