int TimerDelayForFPS(int fps) { if(TimerGetTicks() < ONE_SECOND / fps) { /* Sleep the remaining frame time */ SDL_Delay((ONE_SECOND / fps) - TimerGetTicks()); return fps; } else { return ONE_SECOND / TimerGetTicks(); } }
void TimerTuneMsDelay (TTimer *pThis) { assert (pThis != 0); unsigned nTicks = TimerGetTicks (pThis); TimerMsDelay (pThis, 1000); nTicks = TimerGetTicks (pThis) - nTicks; unsigned nFactor = 100 * HZ / nTicks; pThis->m_nMsDelay = pThis->m_nMsDelay * nFactor / 100; pThis->m_nusDelay = (pThis->m_nMsDelay + 500) / 1000; //LoggerWrite (LoggerGet (), "timer", LogNotice, "SpeedFactor is %u.%02u", nFactor / 100, nFactor % 100); }
int TimerDelay(int ms) { SDL_Delay(ms); return ONE_SECOND / TimerGetTicks(); }