hostile-takeover/game/sdl/main.cpp
Nathan Fulton 8f0e81a3f5 Create main thread via host
Create the main thread via host rather than being a global variable in
base; this way, no base threads are created before the host runs main()
because that can cause issues on some platforms.
2016-08-24 16:20:31 -04:00

41 lines
1.0 KiB
C++

// Platform-specific entrypoints (e.g. mac/SDLMain.m) do early platform-specific
// setup and establish a uniform 'SDL' environment. Then they invoke SDL_main
// (see below) which does platform-independent SDL setup and calls the main
// game entrypoint wi::GameMain.
//
// Further platform-specific setup is done as the game calls Host* interfaces
// as it initializes.
#include "game/ht.h"
#include "game/sdl/sdleventserver.h"
#include "base/thread.h"
#if 0
/* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */
static void quit(int rc)
{
SDL_Quit();
exit(rc);
}
#endif
#ifdef __cplusplus
extern "C"
#endif
int SDL_main(int argc, char *argv[])
{
// Create the main thread
base::Thread *main_thread = new base::Thread();
// Set up the main thread as the SDL event thread.
base::Thread::current().set_ss(new wi::SdlEventServer());
// Let the host have a pointer to the thread
wi::HostSetGameThread(main_thread);
// TODO(darrinm): pass args through
wi::GameMain((char *)"");
return 0;
}