示例#1
0
int main(int argc, char **argv)
{
   // Setup the Function Pointers
//   nav_funcs.request_handler = &reqHandler;
   nav_funcs.wset_course = &setCourse;

   printf("Starting Up\n");
   navigation_startup();
   printf("Started\n");

   printf("Shutting Down\n");
   navigation_shutdown();
   printf("Shut Down\n");
   
   return 0;
}
示例#2
0
int main (int argc, const char **argv)
{
#ifdef WIN32
	{
		// set the console to accept escape sequences (Win10+)
		HANDLE console = GetStdHandle(STD_OUTPUT_HANDLE);

		if (console != INVALID_HANDLE_VALUE)
		{
			DWORD consoleMode = 0;
			GetConsoleMode(console, &consoleMode);

			consoleMode |= 4; // ENABLE_VIRTUAL_TERMINAL_PROCESSING; but that isn't available in our current SDK target

			SetConsoleMode(console, consoleMode);
		}
	}
#endif

    int exit_code = EXIT_SUCCESS;

    try {

        // Experiment with floating point masks.
        // #ifdef FE_NOMASK_ENV
        // feenableexcept(FE_INVALID);
        // feenableexcept(FE_DIVBYZERO | FE_INVALID);
        // #endif

        bgl = new BackgroundLoader();

        size_t winid = gfx_init(cb);

        debug_drawer = new BulletDebugDrawer(ogre_sm); // FIXME: hack

        #ifdef WIN32
        mouse = new MouseDirectInput8(winid);
        bool use_dinput = getenv("GRIT_DINPUT")!=NULL;
        keyboard = use_dinput ? (Keyboard *)new KeyboardDirectInput8(winid)
                      : (Keyboard *)new KeyboardWinAPI(winid);
        #else
        mouse = new MouseX11(winid);
        keyboard = new KeyboardX11(winid);
        #endif
        clipboard_init();

        physics_init();

        net_init();

        core_option_init();
        streamer_init();

        navigation_init();

        // audio_init(getenv("GRIT_AUDIO_DEV"));
        audio_init(NULL);

        std::vector<std::string> args;
        for (int i=0 ; i<argc ; i++) {
            args.push_back(argv[i]);
        }

        try {
            const char *init_file = getenv("GRIT_INIT");
            if (init_file == nullptr) init_file = "/system/init.lua";
            init_lua(init_file, args, core_L);
        } catch (Exception &e) {
            CERR << "Fatal error: " << e << std::endl;
            exit_code = EXIT_FAILURE;
        }

        // Lua returns - we quit.
        
        CVERB << "Shutting down Lua net subsystem..." << std::endl;

        net_shutdown(core_L);

        navigation_shutdown();

        object_all_del(core_L);  // Will remove all demands from background loader.

        CVERB << "Shutting down Lua graphics subsystem..." << std::endl;

        gfx_shutdown_lua(core_L);

        CVERB << "Shutting down Background Loader..." << std::endl;

        bgl->shutdown();

        CVERB << "Shutting down Mouse & Keyboard..." << std::endl;

        if (mouse) delete mouse;
        if (keyboard) delete keyboard;

        CVERB << "Shutting down clipboard..." << std::endl;
        clipboard_shutdown();

        CVERB << "Shutting down Lua VM..." << std::endl;
        if (core_L) shutdown_lua(core_L);

        CVERB << "Shutting down audio subsystem..." << std::endl;
        audio_shutdown(); //close AL device

        CVERB << "Shutting down physics subsystem..." << std::endl;
        physics_shutdown();

        CVERB << "Shutting down the physics debug drawer..." << std::endl;
        if (debug_drawer) delete debug_drawer;

        CVERB << "Shutting down the Graphics subsystem..." << std::endl;
        gfx_shutdown();

        delete bgl;

    } catch (Exception &e) {
        std::cerr << "TOP LEVEL ERROR: " << e << std::endl;
        return EXIT_FAILURE;
    }

    return exit_code;
}