Setup

Functions for creating and destroying a view.

void puglFreeView(PuglView *view)

Free a view created with puglNewView()

const PuglBackend *puglGetBackend(const PuglView *view)

Return the graphics backend used by a view.

void *puglGetHandle(PuglView *view)

Get the user data for a view.

double puglGetScaleFactor(const PuglView *view)

Return the scale factor of the view.

This factor describe how large UI elements (especially text) should be compared to “normal”. For example, 2.0 means the UI should be drawn twice as large. “Normal” is loosely defined as a typical default size on a “standard DPI” display (around 96 DPI).

int puglGetViewHint(const PuglView *view, PuglViewHint hint)

Get the value for a view hint.

If the view has been realized, this can be used to get the actual value of a hint which was initially set to PUGL_DONT_CARE, or has been adjusted from the suggested value.

const char *puglGetViewString(const PuglView *view, PuglStringHint key)

Get a view string property.

The returned string should be accessed immediately, or copied. It may become invalid upon any call to any function that manipulates the same view.

PuglWorld *puglGetWorld(PuglView *view)

Return the world that view is a part of.

PuglView *puglNewView(PuglWorld *world)

Create a new view.

A newly created view doesn’t correspond to a real system view or window until it’s configured and realized.

PuglStatus puglRegisterDropType(PuglView *view, const char *type)

Register support for accepting a type of dropped data.

Before realizing the view, this should be called to register every type of dragged data the view may accept when dropped.

Parameters:
  • view – The view that will accept this type of dropped data.

  • type – The MIME type to accept, “text/plain” is assumed if NULL.

Returns:

PuglStatus.PUGL_SUCCESS, or PuglStatus.PUGL_UNSUPPORTED if the system doesn’t support this type.

PuglStatus puglSetBackend(PuglView *view, const PuglBackend *backend)

Set the graphics backend to use for a view.

This must be called once to set the graphics backend before calling puglRealize().

Pugl includes a “stub” backend for platform-specific applications, and several portable backends:

These backends are modules that aren’t compiled in to the main Pugl library to avoid unnecessary dependencies. To use a particular backend, applications must link against the appropriate backend library, or be sure to compile in the appropriate code if using a local copy of Pugl.

PuglStatus puglSetEventFunc(PuglView *view, PuglEventFunc eventFunc)

Set the function to call when an event occurs.

void puglSetHandle(PuglView *view, void *handle)

Set the user data for a view.

This is usually a pointer to a struct that contains all the state needed by a view. Everything needed to process events should be stored here, not in static variables.

The handle is opaque to Pugl and isn’t interpreted in any way.

PuglStatus puglSetViewHint(PuglView *view, PuglViewHint hint, int value)

Set a hint to configure view properties.

This only has an effect when called before puglRealize().

PuglStatus puglSetViewString(PuglView *view, PuglStringHint key, const char *value)

Set a string property to configure view properties.

This is similar to puglSetViewHint() but sets hints with string values. The string value only needs to be valid for the duration of this call, it will be copied if necessary.