libnoxgl - API reference

Version

extern const int noxgl_ver_major, noxgl_ver_minor, noxgl_ver_patch;

The noxgl_ver_ constants are provided to let user application read out API version of the lib runtime.

Library context and init/uninit

typedef struct noxgl_s noxgl_t;

noxgl_t *noxgl_init(const char *device, int off_screen);

void noxgl_uninit(noxgl_t *noxgl);

Library context keeps track of a connection to a GPU and can manage multiple OpenGL contexts. Library context is an opaque struct pointer (noxgl_t *); the struct is allocated by noxgl_init() and freed by noxgl_uninit().

noxgl_init() takes two arguments. device is a path to the drm/dri device to use, e.g. "/dev/dri/card0". off_screen is a boolean; when it is non-zero, it allows noxgl to do less initialization knowing there will not be any on-screen rendering. (Note: version 1.0.0 does not yet support on-screen rendering.)

Although it is possible to create multiple contexts using the same device, it's more useful when used with different devices: a single application can drive multiple GPUs.

OpenGL context

int noxgl_create_context(noxgl_t *noxgl, void **ctx_out, void **surface_out);

void noxgl_destroy_context(noxgl_t *noxgl, void *ctx, void *surface);

void noxgl_make_current_context(noxgl_t *noxgl, void *ctx, void *surface);

An OpenGL context is identified by the tuple:

  1. noxgl_t * library context
  2. void * ctx
  3. void * surface

A new OpenGL context is created within an existing noxgl context using noxgl_create_context(); ctx and surface are returned through ctx_out and surface_out. The function returns 0 on success and activates the new context.

The OpenGL context can be destroyed by passing the context tuple to noxgl_destroy_context(); after which ctx and surface are invalid.

The application may maintain multiple OpenGL contexts within a single noxgl context or within multiple noxgl contexts. Any of the OpenGL contexts can be activated using noxgl_make_current_context() with the context tuple. (Note: OpenGL has a lot of per OpenGL-context global states; OpenGL calls typically operate on the currently active OpenGL context.)

Diagnostics

void noxgl_print_info(noxgl_t *noxgl);

Print human readable information about all underlying layers to stdout. Useful for diagnostics, bugreporting and debugging.