#include #include #include #include #include #include #include #include #undef main int main(int argc, char ** argv) try { using namespace psemek; util::clock clock; #ifdef PSEMEK_PACKAGE_MODE log::level const stdio_log_level = log::level::info; #else log::level const stdio_log_level = log::level::debug; #endif log::add_sink(log::default_sink(io::std_out(), stdio_log_level)); log::register_thread("main"); auto const factory = app::make_application_factory(); auto const options = factory->options(); sdl2::window window(options); gfx::init(); app::application::context context; for (int i = 0; i < argc; ++i) context.args.push_back(argv[i]); context.show_cursor = [&](bool show){ window.show_cursor(show); }; context.vsync = [&](bool on){ window.vsync(on); }; auto application = factory->create(options, context); if (!application) return EXIT_FAILURE; application->on_event(app::resize_event{window.size()}); window.show(); log::info() << "Started in " << util::pretty(clock.duration(), std::chrono::milliseconds{1}); log::info() << "Running"; while (application->running()) { if (sdl2::poll_events(*application)) application->stop(); if (!application->running()) break; application->update(); application->present(); window.swap(); } log::info() << "Quitting"; return EXIT_SUCCESS; } catch (std::exception const & e) { psemek::log::error() << e.what(); return EXIT_FAILURE; } catch (...) { psemek::log::error() << "Unknown exception"; return EXIT_FAILURE; }