private void Sync_Loop() { //Init InitLogic(); InitGraphics(); Stopwatch logicTimer = new Stopwatch(); Stopwatch drawTimer = new Stopwatch(); Sampler fpsAvg = new Sampler(100); Sampler tpsAvg = new Sampler(100); //Initial Stuff GEngine.LoadStatics(this); SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, ParseRenderScale(Properties.RenderScaleQuality)); while (!ResourcesLoaded) { SDL_Delay(1000); } logicTimer.Start(); drawTimer.Start(); double total; bool flip = false; do { total = GetPreciseMs(); if (ETtoMS(logicTimer.ElapsedTicks) >= Properties.TargetLogictime) { _cur_logictime = ETtoMS(logicTimer.ElapsedTicks); tpsAvg.AddPoint(1000.00 / _cur_logictime); logicTimer.Restart(); LogicStep(); } if (ETtoMS(drawTimer.ElapsedTicks) >= Properties.TargetFrametime || !Properties.EnableFramelimiter) { if (!flip) { _cur_frametime = ETtoMS(drawTimer.ElapsedTicks); fpsAvg.AddPoint(1000.00 / _cur_frametime); drawTimer.Restart(); DrawStep(); } if (!Properties.EnableFramelimiter) { flip = !flip; } } total = GetPreciseMs() - total; _cur_totaltime = total; _fps = fpsAvg.GetAverage(); _tps = tpsAvg.GetAverage(); } while (!_StopThread); _Aborted_S = true; }