aboutsummaryrefslogtreecommitdiffstats
path: root/pugl/pugl_win.cpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2019-06-27 22:07:36 +0200
committerDavid Robillard <d@drobilla.net>2019-06-27 22:48:43 +0200
commit664b49726136f861d695b96f4e285f9afcdc7127 (patch)
treefd08f9f13b9f89c782dc88363a92a161f54f7b42 /pugl/pugl_win.cpp
parentbd5d643192e189e2f4d34ecc1b93a7758cfeb583 (diff)
downloadpugl-664b49726136f861d695b96f4e285f9afcdc7127.tar.gz
pugl-664b49726136f861d695b96f4e285f9afcdc7127.tar.bz2
pugl-664b49726136f861d695b96f4e285f9afcdc7127.zip
Add puglGetTime()
Diffstat (limited to 'pugl/pugl_win.cpp')
-rw-r--r--pugl/pugl_win.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/pugl/pugl_win.cpp b/pugl/pugl_win.cpp
index 6185c91..2ae832b 100644
--- a/pugl/pugl_win.cpp
+++ b/pugl/pugl_win.cpp
@@ -55,6 +55,7 @@ struct PuglInternalsImpl {
HDC hdc;
HGLRC hglrc;
WNDCLASS wc;
+ double timerFrequency;
};
LRESULT CALLBACK
@@ -99,6 +100,10 @@ puglCreateWindow(PuglView* view, const char* title)
PuglInternals* impl = view->impl;
+ LARGE_INTEGER frequency;
+ QueryPerformanceFrequency(&frequency);
+ impl->timerFrequency = frequency.QuadPart;
+
if (!title) {
title = "Window";
}
@@ -619,6 +624,14 @@ puglGetProcAddress(const char* name)
return (PuglGlFunc)wglGetProcAddress(name);
}
+double
+puglGetTime(PuglView* view)
+{
+ LARGE_INTEGER count;
+ QueryPerformanceCounter(&count);
+ return double(count.QuadPart) / view->impl->timerFrequency;
+}
+
void
puglPostRedisplay(PuglView* view)
{