while(run) { mTimer.Tick(); CalculateFrameStats(); //deltaT = mTimer.GetDeltaTime(); //if(deltaT > 250) deltaT = 250; // max 0.25 sec, for breakpoints etc. while(PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) { TranslateMessage(&msg); DispatchMessage(&msg); if(msg.message == WM_QUIT) { run = false; SetState(APPL_STATE::STOPPED); } } if(mInputManager.NeedJoypadInput()) { if(!UpdatePolledRAWInput()) { CLOG(ERROR, "INPUT") << error_joypad_disconnect.c_str(); if(GetCurrentState() != APPL_STATE::PAUSED) SetState(APPL_STATE::PAUSED); gXInputControllerId = GetXInputControllerId(); if(gXInputControllerId != -1) { SetState(GetLastState()); CLOG(DEBUG, "INPUT") << debug_joypad_reconnect.c_str(); } } } if(!ProcessUserActions()) return false; if(GetCurrentState() != APPL_STATE::PAUSED) { double lastFrameTime = mTimer.GetDeltaTime(); if(lastFrameTime > 250) lastFrameTime = 250; // max 0.25 sec, for breakpoints etc. accumulator += lastFrameTime; while(accumulator >= fixedUpdateTime) { if(!Update(fixedUpdateTime, mTimer.GetTotalTime())) { CLOG(FATAL, "GAMEBASE") << fatal_update_appl.c_str(); return(int)msg.wParam; } accumulator -= fixedUpdateTime; if(!ResetRAWHIDInput()) return false; } // pass alpha to Draw to blend last and current state (using lerp) -> 2 states in meshInst class // Render must create 'temp' matrices, to use for drawing only float alpha = static_cast(accumulator) / fixedUpdateTime; if(!Render(alpha)) { CLOG(FATAL, "GAMEBASE") << fatal_render_appl.c_str(); return(int)msg.wParam; } } else { Sleep(100); }