summaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'main.c')
-rw-r--r--main.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/main.c b/main.c
index bba3b6b..22e7786 100644
--- a/main.c
+++ b/main.c
@@ -341,7 +341,7 @@ int main(int argc, char **argv) {
#if DEBUG
//printf("\033[H\033[2J");
#endif
- PROFILE_TIME(frame_start);
+ double frame_start = time_get_seconds();
SDL_Event event;
@@ -643,19 +643,24 @@ int main(int argc, char **argv) {
buffer_check_valid(&ted->buffers[i]);
buffer_check_valid(&ted->line_buffer);
#endif
-
- PROFILE_TIME(frame_end_noswap);
-
+
+ glFinish();
+
+ double frame_end_noswap = time_get_seconds();
#if PROFILE
{
print("Frame (noswap): %.1f ms\n", (frame_end_noswap - frame_start) * 1000);
}
#endif
-
-
+
+ u32 ms_wait = (u32)((frame_end_noswap - frame_start) * 1000);
+ if (ms_wait) ms_wait -= 1; // give swap an extra ms to make sure it's actually vsynced
+ SDL_Delay(ms_wait);
SDL_GL_SwapWindow(window);
PROFILE_TIME(frame_end);
+ assert(glGetError() == 0);
+
#if PROFILE
{
print("Frame: %.1f ms\n", (frame_end - frame_start) * 1000);