summaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorLeo Tenenbaum <pommicket@gmail.com>2021-03-02 13:06:48 -0500
committerLeo Tenenbaum <pommicket@gmail.com>2021-03-02 13:06:48 -0500
commit3600ff8d24ea87a0b63e4931010e0dd52232246c (patch)
tree80593ff98b88280fd131fc5ba8e3b43c1ee998f7 /main.c
parent64321c2a6f08cad8ebafafe1b09a913d16a1b0e2 (diff)
silence windows release build warning
also remove swap busy loop again because that's still happening
Diffstat (limited to 'main.c')
-rw-r--r--main.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/main.c b/main.c
index b56e1fd..ec4ffc3 100644
--- a/main.c
+++ b/main.c
@@ -566,9 +566,7 @@ int main(int argc, char **argv) {
#if DEBUG
//printf("\033[H\033[2J");
#endif
- #if PROFILE
double frame_start = time_get_seconds();
- #endif
SDL_Event event;
Uint8 const *keyboard_state = SDL_GetKeyboardState(NULL);
@@ -889,8 +887,8 @@ int main(int argc, char **argv) {
glFinish();
- #if PROFILE
double frame_end_noswap = time_get_seconds();
+ #if PROFILE
{
print("Frame (noswap): %.1f ms\n", (frame_end_noswap - frame_start) * 1000);
}
@@ -901,7 +899,12 @@ int main(int argc, char **argv) {
SDL_SetWindowTitle(window, ted->window_title);
SDL_SetCursor(ted->cursor);
-
+
+ i32 ms_wait = (i32)((frame_end_noswap - frame_start) * 1000);
+ if (ms_wait > 0) {
+ 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);