summaryrefslogtreecommitdiffhomepage
path: root/src/core.c
diff options
context:
space:
mode:
authorraysan5 <[email protected]>2019-12-04 17:59:17 +0100
committerraysan5 <[email protected]>2019-12-04 17:59:17 +0100
commit08adb4b8c3085641a7e316f1489a4111dbc9d5c0 (patch)
tree54e56296caca00929a432614df0909cf6268aac3 /src/core.c
parent3d936061c8a39e4918399a805aac6b33ed97310a (diff)
downloadraylib-08adb4b8c3085641a7e316f1489a4111dbc9d5c0.tar.gz
raylib-08adb4b8c3085641a7e316f1489a4111dbc9d5c0.zip
Check and testing timming #865
Diffstat (limited to 'src/core.c')
-rw-r--r--src/core.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/core.c b/src/core.c
index c82a0613..583be4df 100644
--- a/src/core.c
+++ b/src/core.c
@@ -1265,27 +1265,29 @@ void EndDrawing(void)
SwapBuffers(); // Copy back buffer to front buffer
PollInputEvents(); // Poll user events
-
+
// Frame time control system
currentTime = GetTime();
drawTime = currentTime - previousTime;
previousTime = currentTime;
frameTime = updateTime + drawTime;
-
+
// Wait for some milliseconds...
if (frameTime < targetTime)
{
Wait((float)(targetTime - frameTime)*1000.0f);
currentTime = GetTime();
- double extraTime = currentTime - previousTime;
+ double waitTime = currentTime - previousTime;
previousTime = currentTime;
- frameTime += extraTime;
+ frameTime += waitTime; // Total frame time: update + draw + wait
+
+ //SetWindowTitle(FormatText("Update: %f, Draw: %f, Req.Wait: %f, Real.Wait: %f, Total: %f, Target: %f\n",
+ // (float)updateTime, (float)drawTime, (float)(targetTime - (updateTime + drawTime)),
+ // (float)waitTime, (float)frameTime, (float)targetTime));
}
-
- return;
}
// Initialize 2D mode with custom camera (2D)
@@ -1588,13 +1590,12 @@ void SetTargetFPS(int fps)
// Returns current FPS
int GetFPS(void)
{
- return (int)(1.0f/GetFrameTime());
+ return (int)roundf(1.0f/GetFrameTime());
}
// Returns time in seconds for last frame drawn
float GetFrameTime(void)
{
- // NOTE: We round value to milliseconds
return (float)frameTime;
}