aboutsummaryrefslogtreecommitdiffstats
path: root/pugl/pugl_win.c
diff options
context:
space:
mode:
Diffstat (limited to 'pugl/pugl_win.c')
-rw-r--r--pugl/pugl_win.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/pugl/pugl_win.c b/pugl/pugl_win.c
index e751df9..5f9d555 100644
--- a/pugl/pugl_win.c
+++ b/pugl/pugl_win.c
@@ -99,7 +99,13 @@ wndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
PuglInternals*
puglInitInternals(void)
{
- return (PuglInternals*)calloc(1, sizeof(PuglInternals));
+ PuglInternals* impl = (PuglInternals*)calloc(1, sizeof(PuglInternals));
+
+ LARGE_INTEGER frequency;
+ QueryPerformanceFrequency(&frequency);
+ impl->timerFrequency = (double)frequency.QuadPart;
+
+ return impl;
}
void
@@ -324,10 +330,6 @@ puglCreateWindow(PuglView* view, const char* title)
wglSwapInterval(1);
}
- LARGE_INTEGER frequency;
- QueryPerformanceFrequency(&frequency);
- impl->timerFrequency = (double)frequency.QuadPart;
-
SetWindowLongPtr(impl->hwnd, GWLP_USERDATA, (LONG_PTR)view);
return 0;
@@ -770,7 +772,8 @@ puglGetTime(PuglView* view)
{
LARGE_INTEGER count;
QueryPerformanceCounter(&count);
- return (double)count.QuadPart / view->impl->timerFrequency;
+ const double now = (double)count.QuadPart / view->impl->timerFrequency;
+ return now - view->start_time;
}
void