Typedefs | Functions
World

Detailed Description

The top-level context of a Pugl application or plugin.

The world contains all library-wide state. There is no static data in Pugl, so it is safe to use multiple worlds in a single process. This is to facilitate plugins or other situations where it is not possible to share a world, but a single world should be shared for all views where possible.

Typedefs

typedef struct PuglWorldImpl PuglWorld
 

Functions

PuglWorldpuglNewWorld (void)
 
void puglFreeWorld (PuglWorld *world)
 
void * puglGetNativeWorld (PuglWorld *world)
 
PuglStatus puglSetClassName (PuglWorld *world, const char *name)
 
double puglGetTime (const PuglWorld *world)
 
PuglStatus puglPollEvents (PuglWorld *world, double timeout)
 
PuglStatus puglDispatchEvents (PuglWorld *world)
 

Typedef Documentation

◆ PuglWorld

typedef struct PuglWorldImpl PuglWorld

The "world" of application state.

The world represents everything that is not associated with a particular view. Several worlds can be created in a single process, but code using different worlds must be isolated so they are never mixed. Views are strongly associated with the world they were created in.

Function Documentation

◆ puglNewWorld()

PuglWorld* puglNewWorld ( void  )

Create a new world.

Returns
A new world, which must be later freed with puglFreeWorld().

◆ puglFreeWorld()

void puglFreeWorld ( PuglWorld world)

Free a world allocated with puglNewWorld().

◆ puglGetNativeWorld()

void* puglGetNativeWorld ( PuglWorld world)

Return a pointer to the native handle of the world.

Returns
  • X11: A pointer to the Display.
  • MacOS: NULL.
  • Windows: The HMODULE of the calling process.

◆ puglSetClassName()

PuglStatus puglSetClassName ( PuglWorld world,
const char *  name 
)

Set the class name of the application.

This is a stable identifier for the application, used as the window class/instance name on X11 and Windows. It is not displayed to the user, but can be used in scripts and by window managers, so it should be the same for every instance of the application, but different from other applications.

◆ puglGetTime()

double puglGetTime ( const 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.

◆ puglPollEvents()

PuglStatus puglPollEvents ( PuglWorld world,
double  timeout 
)

Poll for events that are ready to be processed.

This polls for events that are ready for any view in the world, potentially blocking depending on timeout.

Parameters
worldThe world to poll for events.
timeoutMaximum time to wait, in seconds. If zero, the call returns immediately, if negative, the call blocks indefinitely.
Returns
PUGL_SUCCESS if events are read, PUGL_FAILURE if not, or an error.

◆ puglDispatchEvents()

PuglStatus puglDispatchEvents ( PuglWorld world)

Dispatch any pending events to views.

This processes all pending events, dispatching them to the appropriate views. View event handlers will be called in the scope of this call. This function does not block, if no events are pending then it will return immediately.