int main(int argc, char *argv[]) { int errors=0; bool printanyway=false; //look for options for (int i=0; i<argc; i++) { std::string argv_str(argv[i]); if (argv_str.find("printanyway")!=std::string::npos) { printanyway = true; } } //look for files for (int i=0; i<argc; i++) { std::string argv_str(argv[i]); if (argv_str.find(".spike_sion")!=std::string::npos) { std::cout << "spike file" << std::endl; errors += readSpikeFile(argv[i], printanyway); } if (argv_str.find(".multi_sion")!=std::string::npos) { std::cout << "multi file" << std::endl; errors += readMultiFile(argv[i], printanyway); } } if (errors>1 && !printanyway) std::cerr << errors << " errors found" << std::endl; };
void argv_msg_prefix (const int msglev, const struct argv *a, const char *prefix) { struct gc_arena gc = gc_new (); msg (msglev, "%s: %s", prefix, argv_str (a, &gc, 0)); gc_free (&gc); }
void argv_msg (const int msglev, const struct argv *a) { struct gc_arena gc = gc_new (); msg (msglev, "%s", argv_str (a, &gc, 0)); gc_free (&gc); }
int Viewer::init(int argc, char *argv[]) { fmt::print("Start init\n"); for (auto i = 0; i < argc; i++) { std::string argv_str(argv[i]); if (argv_str == "-b1") { m_benchmark_mode = 1; m_max_frames = 500; } else if (argv_str == "-b2") { m_benchmark_mode = 2; m_max_frames = 250; } else if (argv_str == "-b3") { m_benchmark_mode = 3; m_max_frames = 125; } else if (argv_str == "-b4") { m_benchmark_mode = 4; m_max_frames = 50; } else if (argv_str == "-b5") { m_benchmark_mode = 5; m_max_frames = 25; } // Save image after n frames and quit auto found = argv_str.find("-f"); if (found != std::string::npos) { m_benchmark_mode = -1; m_max_frames = std::stoi(argv_str.substr(found + 2, argv_str.length())); } } if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO) != 0) { std::cerr << "SDL_Init error: " << SDL_GetError() << std::endl; return 1; } m_window = SDL_CreateWindow("trac0r", 100, 100, m_screen_width, m_screen_height, SDL_WINDOW_SHOWN); if (m_window == nullptr) { std::cerr << "SDL_CreateWindow error: " << SDL_GetError() << std::endl; SDL_Quit(); return 1; } // m_render = SDL_CreateRenderer(m_window, -1, SDL_RENDERER_ACCELERATED | // SDL_RENDERER_PRESENTVSYNC); m_render = SDL_CreateRenderer(m_window, -1, SDL_RENDERER_ACCELERATED); m_render_tex = SDL_CreateTexture(m_render, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, m_screen_width, m_screen_height); m_pixels.resize(m_screen_width * m_screen_height, 0); if (m_render == nullptr) { SDL_DestroyWindow(m_window); std::cerr << "SDL_CreateRenderer error: " << SDL_GetError() << std::endl; SDL_Quit(); return 1; } if (TTF_Init() != 0) { std::cerr << "SDL_ttf could not initialize! SDL_ttf error: " << SDL_GetError() << std::endl; return 1; } auto font_path = "res/DejaVuSansMono-Bold.ttf"; m_font = TTF_OpenFont(font_path, 14); if (m_font == nullptr) { std::cerr << "SDL_ttf could not open '" << font_path << "'" << std::endl; return 1; } // Setup scene setup_scene(); m_renderer = std::make_unique<trac0r::Renderer>(m_screen_width, m_screen_height, m_camera, m_scene, m_print_perf); m_renderer->print_sysinfo(); fmt::print("Finish init\n"); return 0; }