/* * Hlavní funkce konzolové aplikace */ int main(int argc, char **argv) { int result; lua_State* L = luaL_newstate(); luaL_openlibs(L); registerLuaFunctions(L); result = luaL_dofile(L, argv[1]); /* Zpracování chyby */ if (result != 0) { fprintf(stderr, "Error # %d\n", result); } else { /* the function name */ lua_getglobal(L, "save"); /* the first argument */ lua_pushstring(L, "images/"); /* call the function with 1 arguments, return 0 result */ lua_call(L, 1, 0); } printLuaStack(L); lua_close(L); bitmapDestroy(bmp); return (result != 0); }
void Application::init(const std::vector<std::string>& args) { // capture exit signals signal(SIGTERM, exitSignalHandler); signal(SIGINT, exitSignalHandler); #ifdef CRASH_HANDLER installCrashHandler(); #endif std::string startupOptions; for(uint i=1;i<args.size();++i) { const std::string& arg = args[i]; startupOptions += " "; startupOptions += arg; } if(startupOptions.length() > 0) g_logger.info(stdext::format("Startup options: %s", startupOptions)); m_startupOptions = startupOptions; // initialize resources g_resources.init(args[0].c_str()); // initialize lua g_lua.init(); registerLuaFunctions(); }
bool App::create( int argc, char** argv ) { const char* configFilename = APP_NAME "_config.txt"; switch( argc ) { case 1: // use default configFilename break; case 2: configFilename = argv[1]; break; default: // print usage printf( "\nusage: %s [configFilename]\n\n", argv[0] ); return false; } char cwd[512]; if( getcwd( cwd, sizeof(cwd)-1 ) == NULL ) cwd[0] = '\0'; printf( "CWD\t\"%s\"\n", cwd ); printf( "configFilename\t\"%s\"\n", configFilename ); _config.create( configFilename ); registerLuaFunctions(); if( ! _config.loadFile() ) return false; printf( "instanceName\t\"%s\"\n", _instanceName.c_str() ); if( ! createGlSurface() ) return false; // now an OpenGL context exists _viewer = Viewer::factory( Viewer::getType( _config ) ); _scene = Scene::factory( Scene::getType( _config ) ); CHECK_GLERROR( "App::create" ); printInfo(); printf( "\n" ); resetStats(); return true; }
void OTClient::init(const std::vector<std::string>& args) { // register needed lua functions registerLuaFunctions(); g_shaders.init(); g_things.init(); //TODO: restore options /* if(g_graphics.parseOption(arg)) continue; if(arg == "-version" || arg == "--version" || arg == "-v") { stdext::print( m_appName, " ", m_appVersion, "\n" "Buitt on: ", BUILD_DATE, "\n", "Commit: ", BUILD_COMMIT, "\n", "Compiled by: ", BUILD_COMPILER, "\n", "Build type: ", BUILD_TYPE, "\n"); return; } else if(arg == "-help" || arg == "--help" || arg == "-h" || arg == "-?" || arg == "/?") { stdext::print( "Usage: ", args[0], " [options]\n" "Options:\n" " -help Display this information and exit\n" " -version Display version and exit\n" " \n" " -no-fbos Disable usage of opengl framebuffer objects\n" " -no-mipmaps Disable texture mipmaping\n" " -no-smooth Disable texture smoothing (bilinear filter)\n" " -no-non-power-of-two-textures Use only power of two textures\n" " -no-clamp-to-edge Don't use GL_CLAMP_TO_EDGE\n" " -no-backbuffer-cache Don't allow backbuffer caching\n" " -hardware-buffers Cache vertex arrays in hardware\n" " -opengl1 Use OpenGL 1.x painter\n" " -opengl2 Use OpenGL 2.0 painter\n"); return; } else { stdext::println("Unrecognized option '", arg, "', please see -help for available options list"); return; } */ }
void Application::init(std::vector<std::string>& args) { // capture exit signals signal(SIGTERM, exitSignalHandler); signal(SIGINT, exitSignalHandler); #ifdef CRASH_HANDLER installCrashHandler(); #endif // setup locale std::locale::global(std::locale()); // process args encoding g_platform.processArgs(args); g_asyncDispatcher.init(); std::string startupOptions; for(uint i=1;i<args.size();++i) { const std::string& arg = args[i]; startupOptions += " "; startupOptions += arg; } if(startupOptions.length() > 0) g_logger.info(stdext::format("Startup options: %s", startupOptions)); m_startupOptions = startupOptions; // initialize configs g_configs.init(); // initialize resources g_resources.init(args[0].c_str()); // initialize lua g_lua.init(); registerLuaFunctions(); }