//----------------------------------------------------------------// int GlutHost ( int argc, char** argv ) { _printMoaiVersion (); #ifdef _DEBUG printf ( "DEBUG BUILD\n" ); #endif // TODO: integrate this nicely with host //AKUInitMemPool ( 100 * 1024 * 1024 ); atexit ( _cleanup ); glutInit ( &argc, argv ); GlutRefreshContext (); char* lastScript = NULL; if ( argc < 2 ) { AKURunScript ( "main.lua" ); } else { AKUSetArgv ( argv ); for ( int i = 1; i < argc; ++i ) { char* arg = argv [ i ]; if ( strcmp( arg, "-e" ) == 0 ) { // sDynamicallyReevaluateLuaFiles = true; } else if ( strcmp( arg, "-s" ) == 0 && ++i < argc ) { char* script = argv [ i ]; AKURunString ( script ); } else { AKURunScript ( arg ); lastScript = arg; } } } //assuming that the last script is the entry point we watch for that directory and its subdirectories #if MOAI_WITH_FOLDER_WATCHER if ( lastScript && sDynamicallyReevaluateLuaFiles ) { #ifdef _WIN32 winhostext_WatchFolder ( lastScript ); #elif __APPLE__ FWWatchFolder( lastScript ); #endif } #endif if ( sHasWindow ) { glutTimerFunc ( 0, _onTimer, 0 ); glutMainLoop (); } return 0; }
//----------------------------------------------------------------// int work_moai_vfs ( int argc, char** argv ) { glutInit ( &argc, argv ); AKUCreateContext (); AKUSetInputConfigurationName ( "AKUGlut" ); AKUReserveInputDevices ( GlutInputDeviceID::TOTAL ); AKUSetInputDevice ( GlutInputDeviceID::DEVICE, "device" ); AKUReserveInputDeviceSensors ( GlutInputDeviceID::DEVICE, GlutInputDeviceSensorID::TOTAL ); AKUSetInputDeviceKeyboard ( GlutInputDeviceID::DEVICE, GlutInputDeviceSensorID::KEYBOARD, "keyboard" ); AKUSetInputDevicePointer ( GlutInputDeviceID::DEVICE, GlutInputDeviceSensorID::POINTER, "pointer" ); AKUSetInputDeviceButton ( GlutInputDeviceID::DEVICE, GlutInputDeviceSensorID::MOUSE_LEFT, "mouseLeft" ); AKUSetInputDeviceButton ( GlutInputDeviceID::DEVICE, GlutInputDeviceSensorID::MOUSE_MIDDLE, "mouseMiddle" ); AKUSetInputDeviceButton ( GlutInputDeviceID::DEVICE, GlutInputDeviceSensorID::MOUSE_RIGHT, "mouseRight" ); AKUSetFunc_EnterFullscreenMode ( _AKUEnterFullscreenModeFunc ); AKUSetFunc_ExitFullscreenMode ( _AKUExitFullscreenModeFunc ); AKUSetFunc_OpenWindow ( _AKUOpenWindowFunc ); AKUMountVirtualDirectory ( "test", "anim-basic.zip" ); AKUSetWorkingDirectory ( "test/anim-basic" ); AKURunScript ( "main.lua" ); return 0; }
//----------------------------------------------------------------// int GlutHost ( int argc, char** argv ) { // TODO: integrate this nicely with host //AKUInitMemPool ( 100 * 1024 * 1024 ); atexit ( _cleanup ); glutInit ( &argc, argv ); AKUCreateContext (); #ifdef GLUTHOST_USE_FMOD AKUFmodLoad (); #endif #ifdef GLUTHOST_USE_LUAEXT AKUExtLoadLuacrypto (); AKUExtLoadLuacurl (); AKUExtLoadLuasocket (); AKUExtLoadLuasql (); #endif #ifdef GLUTHOST_USE_UNTZ AKUUntzInit (); #endif #ifdef GLUTHOST_USE_PARTICLE_PRESETS ParticlePresets (); #endif AKUSetInputConfigurationName ( "AKUGlut" ); AKUReserveInputDevices ( GlutInputDeviceID::TOTAL ); AKUSetInputDevice ( GlutInputDeviceID::DEVICE, "device" ); AKUReserveInputDeviceSensors ( GlutInputDeviceID::DEVICE, GlutInputDeviceSensorID::TOTAL ); AKUSetInputDeviceKeyboard ( GlutInputDeviceID::DEVICE, GlutInputDeviceSensorID::KEYBOARD, "keyboard" ); AKUSetInputDevicePointer ( GlutInputDeviceID::DEVICE, GlutInputDeviceSensorID::POINTER, "pointer" ); AKUSetInputDeviceButton ( GlutInputDeviceID::DEVICE, GlutInputDeviceSensorID::MOUSE_LEFT, "mouseLeft" ); AKUSetInputDeviceButton ( GlutInputDeviceID::DEVICE, GlutInputDeviceSensorID::MOUSE_MIDDLE, "mouseMiddle" ); AKUSetInputDeviceButton ( GlutInputDeviceID::DEVICE, GlutInputDeviceSensorID::MOUSE_RIGHT, "mouseRight" ); AKUSetFunc_EnterFullscreenMode ( _AKUEnterFullscreenModeFunc ); AKUSetFunc_ExitFullscreenMode ( _AKUExitFullscreenModeFunc ); AKUSetFunc_OpenWindow ( _AKUOpenWindowFunc ); #ifdef GLUTHOST_USE_DEBUGGER AKUDebugHarnessInit (); #endif for ( int i = 1; i < argc; ++i ) { AKURunScript ( argv [ i ]); } if ( sHasWindow ) { glutTimerFunc ( 0, _onTimer, 0 ); glutMainLoop (); } return 0; }
//----------------------------------------------------------------// extern "C" void Java_com_ziplinegames_moai_Moai_AKURunScript ( JNIEnv* env, jclass obj, jstring jfilename ) { JNI_GET_CSTRING ( jfilename, filename ); AKURunScript ( filename ); JNI_RELEASE_CSTRING ( jfilename, filename ); }
void MoaiWidget::runScript(QString script){ mActiveFile = script; if(mInitialized) { const char *path = script.toAscii().data(); printf("Running script: %s \n", path); AKURunScript ( path ); } else mScripts = true; }
//----------------------------------------------------------------// int GlutHost ( int argc, char** argv ) { glutInit ( &argc, argv ); AKUCreateContext (); #ifdef GLUTHOST_USE_FMOD AKUFmodLoad (); #endif #ifdef GLUTHOST_USE_LUAEXT AKUExtLoadLuacrypto (); AKUExtLoadLuacurl (); AKUExtLoadLuasocket (); AKUExtLoadLuasql (); #endif #ifdef GLUTHOST_USE_UNTZ AKUUntzInit (); #endif #ifdef GLUTHOST_USE_PARTICLE_PRESETS ParticlePresets (); #endif AKUSetInputConfigurationName ( "AKUGlut" ); AKUReserveInputDevices ( GlutInputDeviceID::TOTAL ); AKUSetInputDevice ( GlutInputDeviceID::DEVICE, "device" ); AKUReserveInputDeviceSensors ( GlutInputDeviceID::DEVICE, GlutInputDeviceSensorID::TOTAL ); AKUSetInputDeviceKeyboard ( GlutInputDeviceID::DEVICE, GlutInputDeviceSensorID::KEYBOARD, "keyboard" ); AKUSetInputDevicePointer ( GlutInputDeviceID::DEVICE, GlutInputDeviceSensorID::POINTER, "pointer" ); AKUSetInputDeviceButton ( GlutInputDeviceID::DEVICE, GlutInputDeviceSensorID::MOUSE_LEFT, "mouseLeft" ); AKUSetInputDeviceButton ( GlutInputDeviceID::DEVICE, GlutInputDeviceSensorID::MOUSE_MIDDLE, "mouseMiddle" ); AKUSetInputDeviceButton ( GlutInputDeviceID::DEVICE, GlutInputDeviceSensorID::MOUSE_RIGHT, "mouseRight" ); AKUSetFunc_EnterFullscreenMode ( _AKUEnterFullscreenModeFunc ); AKUSetFunc_ExitFullscreenMode ( _AKUExitFullscreenModeFunc ); AKUSetFunc_OpenWindow ( _AKUOpenWindowFunc ); AKUSetFunc_StartGameLoop ( _AKUStartGameLoopFunc ); for ( int i = 1; i < argc; ++i ) { AKURunScript ( argv [ i ]); } return 0; }
//----------------------------------------------------------------// int main ( int argc, char *argv []) { AKUAppInitialize (); AKUModulesAppInitialize (); AKUCreateContext (); AKUModulesContextInitialize (); // Setup signal handler: quit on Ctrl-C signal ( SIGTERM, signal_handler ); signal ( SIGINT, signal_handler ); AKUSetArgv ( argv ); for ( int i = 1; i < argc; ++i ) { char* arg = argv [ i ]; if ( strcmp( arg, "-s" ) == 0 && ++i < argc ) { AKURunString ( argv [ i ]); } else { AKURunScript ( arg ); } } while ( sExitFlag == 0 ) { sleep ( 1 ); } printf ( "Exiting on signal %d, waiting for all threads to finish...", sExitFlag ); fflush ( stdout ); AKUModulesAppFinalize (); AKUAppFinalize (); printf ( "%s", " done.\n" ); return EXIT_SUCCESS; }
//----------------------------------------------------------------// int GlutHost ( int argc, char** argv ) { // TODO: integrate this nicely with host //AKUInitMemPool ( 100 * 1024 * 1024 ); atexit ( _cleanup ); glutInit ( &argc, argv ); GlutRefreshContext (); int i = 1; if ( argc > 2 && argv [ i ][ 0 ] == '-' && argv [ i ][ 1 ] == 'e' ) { sDynamicallyReevaluatsLuaFiles = true; i++; } for ( ; i < argc; ++i ) { AKURunScript ( argv [ i ]); } //assuming that the last script is the entry point we watch for that directory and its subdirectories if ( sDynamicallyReevaluatsLuaFiles ) { #ifdef _WIN32 winhostext_WatchFolder ( argv [ argc - 1 ]); #elif __APPLE__ FWWatchFolder( argv [ argc - 1 ] ); #endif } if ( sHasWindow ) { glutTimerFunc ( 0, _onTimer, 0 ); glutMainLoop (); } return 0; }
static void reloadLuaFile(const char * file) { AKURunScript(file); printf("%s reloaded.\n",file); }
//----------------------------------------------------------------// void AKUModulesParseArgs ( int argc, char** argv ) { #if AKU_WITH_TEST int total = argc - 1; int i = 1; for ( ; i < total; ++i ) { char* arg = argv [ i ]; if ( arg [ 0 ] != '-' ) break; // filter file if ( strcmp ( arg, "-f" ) == 0 ) { AKUTestSetFilterFile ( argv [ ++i ]); } // filter if ( strcmp ( arg, "-F" ) == 0 ) { AKUTestSetFilter ( argv [ ++i ]); } // results if ( strcmp ( arg, "-r" ) == 0 ) { AKUTestSetResultsFile ( argv [ ++i ]); } // staging if ( strcmp ( arg, "-s" ) == 0 ) { AKUTestSetStaging (); } // test if ( strcmp ( arg, "-t" ) == 0 ) { AKUTestRunTest ( argv [ ++i ]); } // xml results if ( strcmp ( arg, "-x" ) == 0 ) { AKUTestSetXmlResultsFile ( argv [ ++i ]); } } for ( ; i < argc; ++i ) { AKUTestRunScript ( argv [ i ]); } #else if ( argc < 2 ) { AKURunScript ( "main.lua" ); } else { AKUSetArgv ( argv ); for ( int i = 1; i < argc; ++i ) { char* arg = argv [ i ]; if (( strcmp ( arg, "-s" ) == 0 ) && ( ++i < argc )) { char* script = argv [ i ]; AKURunString ( script ); } else { AKURunScript ( arg ); } } } #endif }
static void reloadLuaFile(const char * file) { GlutRefreshContext (); AKURunScript(file); printf("%s reloaded.\n",file); }