void StateManager::game_loop(SDL_Renderer* ren) { SDL_Event event; while (SDL_PollEvent(&event)) { on_event(&event); } on_loop(); render(ren); }
int CApp::on_execute() { if (!on_init()) return -1; SDL_Event event; while (running) { while (SDL_PollEvent(&event)) on_event(&event); on_loop(); on_render(); } on_cleanup(); return 0; }
int App::start(){ int iret = 0; bool bret = 0; while (true){ app_tick_update(impl_); if (impl_->stoping){ //need stop bret = on_stop(); if (bret){ break; } continue; } if (impl_->restarting){//need restart bret = on_restart(); if (bret){ break; } continue; } if (impl_->reloading){//need reload _app_reload_env(impl_); iret = on_reload(); if (iret){ GLOG_ERR("reload error ret :%d !", iret); } impl_->reloading = false; } //running if (impl_->stcp) { //one tick , one us ? iret += dctcp_poll(impl_->stcp, impl_->maxtptick, impl_->maxtptick); } iret = on_loop(); if (iret == 0){ on_idle(); } } iret = impl_->shm_pool.stop(); if (iret){ GLOG_ERR("shm pool stop error ret:%d", iret); } return on_exit(); }