diff options
-rw-r--r-- | pugl/detail/implementation.c | 12 | ||||
-rw-r--r-- | pugl/detail/types.h | 1 | ||||
-rw-r--r-- | pugl/pugl.h | 24 |
3 files changed, 36 insertions, 1 deletions
diff --git a/pugl/detail/implementation.c b/pugl/detail/implementation.c index 83f63ae..d3b47df 100644 --- a/pugl/detail/implementation.c +++ b/pugl/detail/implementation.c @@ -112,6 +112,18 @@ puglFreeWorld(PuglWorld* const world) free(world); } +void +puglSetWorldHandle(PuglWorld* world, PuglWorldHandle handle) +{ + world->handle = handle; +} + +PuglWorldHandle +puglGetWorldHandle(PuglWorld* world) +{ + return world->handle; +} + PuglStatus puglSetClassName(PuglWorld* const world, const char* const name) { diff --git a/pugl/detail/types.h b/pugl/detail/types.h index 656c34d..d229848 100644 --- a/pugl/detail/types.h +++ b/pugl/detail/types.h @@ -76,6 +76,7 @@ struct PuglViewImpl { /** Cross-platform world definition. */ struct PuglWorldImpl { PuglWorldInternals* impl; + PuglWorldHandle handle; char* className; double startTime; size_t numViews; diff --git a/pugl/pugl.h b/pugl/pugl.h index 7b45f2d..d14c086 100644 --- a/pugl/pugl.h +++ b/pugl/pugl.h @@ -462,6 +462,11 @@ puglStrerror(PuglStatus status); typedef struct PuglWorldImpl PuglWorld; /** + Handle for the world's opaque user data. +*/ +typedef void* PuglWorldHandle; + +/** Create a new world. @return A new world, which must be later freed with puglFreeWorld(). @@ -476,6 +481,23 @@ PUGL_API void puglFreeWorld(PuglWorld* world); /** + Set the user data for the world. + + This is usually a pointer to a struct that contains all the state which must + be accessed by several views. + + The handle is opaque to Pugl and is not interpreted in any way. +*/ +PUGL_API void +puglSetWorldHandle(PuglWorld* world, PuglWorldHandle handle); + +/** + Get the user data for the world. +*/ +PUGL_API PuglWorldHandle +puglGetWorldHandle(PuglWorld* world); + +/** Return a pointer to the native handle of the world. @return @@ -580,7 +602,7 @@ typedef struct PuglBackendImpl PuglBackend; typedef uintptr_t PuglNativeWindow; /** - Handle for opaque user data. + Handle for a view's opaque user data. */ typedef void* PuglHandle; |