diff options
author | David Robillard <d@drobilla.net> | 2019-07-22 16:30:53 +0200 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2019-09-03 08:32:16 +0200 |
commit | e83c2b421d140244a6b9edb051b3e0d4aacda332 (patch) | |
tree | 398e49f43c96f4602496874fa7b3680236138720 /pugl/detail/win.c | |
parent | 5081d49f9f08596c07a8ed32430a4fa3e1baf352 (diff) | |
download | pugl-e83c2b421d140244a6b9edb051b3e0d4aacda332.tar.gz pugl-e83c2b421d140244a6b9edb051b3e0d4aacda332.tar.bz2 pugl-e83c2b421d140244a6b9edb051b3e0d4aacda332.zip |
Add PuglWorld
The old API was broken for programs that manage multiple views, since it was
impossible to wait for events on any view. There are also several functions in
the API which are not actually associated with views at all, so those can now
be moved to the more appropriate PuglWorld to make this more clear.
The old puglInit() and puglDestroy() functions are preserved for compatibility,
but marked as deprecated.
Diffstat (limited to 'pugl/detail/win.c')
-rw-r--r-- | pugl/detail/win.c | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/pugl/detail/win.c b/pugl/detail/win.c index a4597b5..804c883 100644 --- a/pugl/detail/win.c +++ b/pugl/detail/win.c @@ -88,10 +88,14 @@ puglRegisterWindowClass(const char* name) return RegisterClassEx(&wc); } -PuglInternals* -puglInitInternals(void) +PuglWorldInternals* +puglInitWorldInternals(void) { - PuglInternals* impl = (PuglInternals*)calloc(1, sizeof(PuglInternals)); + PuglWorldInternals* impl = (PuglWorldInternals*)calloc( + 1, sizeof(PuglWorldInternals)); + if (!impl) { + return NULL; + } HMODULE user32 = LoadLibrary("user32.dll"); if (user32) { @@ -110,6 +114,12 @@ puglInitInternals(void) return impl; } +PuglInternals* +puglInitViewInternals(void) +{ + return (PuglInternals*)calloc(1, sizeof(PuglInternals)); +} + int puglCreateWindow(PuglView* view, const char* title) { @@ -171,19 +181,23 @@ puglHideWindow(PuglView* view) } void -puglDestroy(PuglView* view) +puglFreeViewInternals(PuglView* view) { if (view) { view->backend->destroy(view); ReleaseDC(view->impl->hwnd, view->impl->hdc); DestroyWindow(view->impl->hwnd); UnregisterClass(view->windowClass ? view->windowClass : DEFAULT_CLASSNAME, NULL); - free(view->windowClass); free(view->impl); - free(view); } } +void +puglFreeWorldInternals(PuglWorld* world) +{ + free(world->impl); +} + static PuglKey keySymToSpecial(WPARAM sym) { @@ -694,8 +708,8 @@ puglGetTime(PuglView* view) { LARGE_INTEGER count; QueryPerformanceCounter(&count); - const double now = (double)count.QuadPart / view->impl->timerFrequency; - return now - view->start_time; + return ((double)count.QuadPart / view->world->impl->timerFrequency - + view->start_time); } void |