aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pugl/pugl_internal.h11
-rw-r--r--pugl/pugl_internal_types.h1
-rw-r--r--pugl/pugl_osx.m2
-rw-r--r--pugl/pugl_win.c15
-rw-r--r--pugl/pugl_x11.c2
5 files changed, 18 insertions, 13 deletions
diff --git a/pugl/pugl_internal.h b/pugl/pugl_internal.h
index 2860a7f..fea5959 100644
--- a/pugl/pugl_internal.h
+++ b/pugl/pugl_internal.h
@@ -61,11 +61,12 @@ puglInit(int* pargc, char** argv)
return NULL;
}
- view->hints = puglDefaultHints();
- view->ctx_type = PUGL_GL;
- view->impl = impl;
- view->width = 640;
- view->height = 480;
+ view->hints = puglDefaultHints();
+ view->ctx_type = PUGL_GL;
+ view->impl = impl;
+ view->width = 640;
+ view->height = 480;
+ view->start_time = puglGetTime(view);
return view;
}
diff --git a/pugl/pugl_internal_types.h b/pugl/pugl_internal_types.h
index 19452cd..9e718ee 100644
--- a/pugl/pugl_internal_types.h
+++ b/pugl/pugl_internal_types.h
@@ -54,6 +54,7 @@ struct PuglViewImpl {
char* windowClass;
PuglNativeWindow parent;
PuglContextType ctx_type;
+ double start_time;
uintptr_t transient_parent;
PuglHints hints;
diff --git a/pugl/pugl_osx.m b/pugl/pugl_osx.m
index 519b7dd..1870207 100644
--- a/pugl/pugl_osx.m
+++ b/pugl/pugl_osx.m
@@ -743,7 +743,7 @@ puglGetTime(PuglView* view)
{
struct timespec ts;
clock_gettime(CLOCK_MONOTONIC, &ts);
- return (double)ts.tv_sec + ts.tv_nsec / 1000000000.0;
+ return ((double)ts.tv_sec + ts.tv_nsec / 1000000000.0) - view->start_time;
}
void
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
diff --git a/pugl/pugl_x11.c b/pugl/pugl_x11.c
index d7db801..15142e1 100644
--- a/pugl/pugl_x11.c
+++ b/pugl/pugl_x11.c
@@ -524,7 +524,7 @@ puglGetTime(PuglView* view)
{
struct timespec ts;
clock_gettime(CLOCK_MONOTONIC, &ts);
- return (double)ts.tv_sec + ts.tv_nsec / 1000000000.0;
+ return ((double)ts.tv_sec + ts.tv_nsec / 1000000000.0) - view->start_time;
}
void