aboutsummaryrefslogtreecommitdiffstats
path: root/pugl
diff options
context:
space:
mode:
Diffstat (limited to 'pugl')
-rw-r--r--pugl/detail/implementation.c3
-rw-r--r--pugl/detail/mac.m4
-rw-r--r--pugl/detail/types.h2
-rw-r--r--pugl/detail/win.c6
-rw-r--r--pugl/detail/x11.c4
-rw-r--r--pugl/pugl.h20
6 files changed, 20 insertions, 19 deletions
diff --git a/pugl/detail/implementation.c b/pugl/detail/implementation.c
index 29daf15..6ec19c2 100644
--- a/pugl/detail/implementation.c
+++ b/pugl/detail/implementation.c
@@ -67,6 +67,8 @@ puglNewWorld(void)
return NULL;
}
+ world->startTime = puglGetTime(world);
+
return world;
}
@@ -90,7 +92,6 @@ puglNewView(PuglWorld* const world)
view->world = world;
view->width = 640;
view->height = 480;
- view->start_time = puglGetTime(view);
puglSetDefaultHints(view->hints);
diff --git a/pugl/detail/mac.m b/pugl/detail/mac.m
index 23344ed..527724d 100644
--- a/pugl/detail/mac.m
+++ b/pugl/detail/mac.m
@@ -868,9 +868,9 @@ puglGetProcAddress(const char *name)
}
double
-puglGetTime(PuglView* view)
+puglGetTime(const PuglWorld* world)
{
- return (mach_absolute_time() / 1e9) - view->start_time;
+ return (mach_absolute_time() / 1e9) - world->startTime;
}
void
diff --git a/pugl/detail/types.h b/pugl/detail/types.h
index fdfb0f6..e279833 100644
--- a/pugl/detail/types.h
+++ b/pugl/detail/types.h
@@ -54,7 +54,6 @@ struct PuglViewImpl {
PuglEventFunc eventFunc;
char* windowClass;
PuglNativeWindow parent;
- double start_time;
uintptr_t transient_parent;
PuglHints hints;
int width;
@@ -71,6 +70,7 @@ struct PuglViewImpl {
/** Cross-platform world definition. */
struct PuglWorldImpl {
PuglWorldInternals* impl;
+ double startTime;
size_t numViews;
PuglView** views;
};
diff --git a/pugl/detail/win.c b/pugl/detail/win.c
index 804c883..6a0825a 100644
--- a/pugl/detail/win.c
+++ b/pugl/detail/win.c
@@ -704,12 +704,12 @@ wndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
}
double
-puglGetTime(PuglView* view)
+puglGetTime(const PuglWorld* world)
{
LARGE_INTEGER count;
QueryPerformanceCounter(&count);
- return ((double)count.QuadPart / view->world->impl->timerFrequency -
- view->start_time);
+ return ((double)count.QuadPart / world->impl->timerFrequency -
+ world->startTime);
}
void
diff --git a/pugl/detail/x11.c b/pugl/detail/x11.c
index e0b3dea..d54f1bf 100644
--- a/pugl/detail/x11.c
+++ b/pugl/detail/x11.c
@@ -600,11 +600,11 @@ puglProcessEvents(PuglView* view)
}
double
-puglGetTime(PuglView* view)
+puglGetTime(const PuglWorld* world)
{
struct timespec ts;
clock_gettime(CLOCK_MONOTONIC, &ts);
- return ((double)ts.tv_sec + ts.tv_nsec / 1000000000.0) - view->start_time;
+ return ((double)ts.tv_sec + ts.tv_nsec / 1000000000.0) - world->startTime;
}
void
diff --git a/pugl/pugl.h b/pugl/pugl.h
index 0dc5fc3..e7c7333 100644
--- a/pugl/pugl.h
+++ b/pugl/pugl.h
@@ -446,6 +446,16 @@ PUGL_API void
puglFreeWorld(PuglWorld* world);
/**
+ Return the time in seconds.
+
+ This is a monotonically increasing clock with high resolution. The returned
+ time is only useful to compare against other times returned by this
+ function, its absolute value has no meaning.
+*/
+PUGL_API double
+puglGetTime(const PuglWorld* world);
+
+/**
@}
@name Initialization
Configuration functions which must be called before creating a window.
@@ -748,16 +758,6 @@ PUGL_API PuglGlFunc
puglGetProcAddress(const char* name);
/**
- Return the time in seconds.
-
- This is a monotonically increasing clock with high resolution. The returned
- time is only useful to compare against other times returned by this
- function, its absolute value has no meaning.
-*/
-PUGL_API double
-puglGetTime(PuglView* view);
-
-/**
Request a redisplay on the next call to puglProcessEvents().
*/
PUGL_API void