예제 #1
0
void CEngine::_MainLoop()
{    
	_Running = true;
        
    _pGameInterface->Init();
    
    if (_ProcessInterval == 0) {
        SetProcessInterval(30);
    }
    
    double dTime = glfwGetTime();
    
	while (_Running)
    {
		_Draw();
        if ((glfwGetTime() - dTime) > _ProcessInterval)
        {
            _Process();
            dTime = glfwGetTime();
        }
	}
    _pGameInterface->Free();
    
	glfwTerminate();
}
예제 #2
0
void Engine::Run(void)
{
    uint32 ms;
    uint32 diff;
    float diff_scaled;
    while(!s_quit)
    {
        if(IsReset())
            _Reset();

        ms = GetTicks();
        diff = ms - s_lastFrameTimeReal;
        if(diff > 127) // 127 ms max. allowed diff time
            diff = 127;
        diff_scaled = diff * s_speed;
        s_fracTime = diff_scaled / 1000.0f;

        s_accuTime += diff_scaled;
        s_diffTime = uint32(s_accuTime);
        s_accuTime -= s_diffTime; // s_accuTime stores the remaining sub-milliseconds
        s_diffTimeReal = diff; // limiting this to 127 max is intentional (its not the real REAL diff then, but oh well)
        
        _ProcessEvents();
        if(!_paused)
        {
            s_curFrameTime += s_diffTime;
            _Process();
            if(_screen)
                _Render();
        }

        _CalcFPS();
        s_lastFrameTimeReal = ms;
    }
}