typedef struct gpcogl_s gpcogl_t;
struct gpcogl_s { GLint array_max_size; GLint array_max_active; GLint glver_major, glver_minor; const unsigned char *gl_vendor; const unsigned char *renderer_vendor; (...) };
int gpcogl_gli_make_context(gpcogl_t *ctx, const char *option);
void gpcogl_gli_destroy_context(gpcogl_t *ctx);
int gpcogl_gli_make_context_window(gpcogl_t *ctx, int wsx, int wsy);
void gpcogl_flush(gpcogl_t *ctx);
A computation context is called gpcogl_t, which is a struct of gpcogl_s. An application may maintain zero or more active, independent contexts in parallel.
The following fields of the context struct are public and can be read by the caller.
array_max_size: maximum size of any array in x or y direction.
array_max_active: maximum number of arrays that can be accessed by a shader program as input and output. There can be more arrays uploaded in GPU memory, but they are passive, unaccessible to the current shader program. A shader program always has one output array and can have at most (array_max_active-2) input arrays. OpenGL guarantees that array_max_active >= 16. glver_major, glver_minor: OpenGL API version (for diagnostics). gl_vendor, renderer_vendor: vendor name of different components of the stack (for diagnostics).
The GLI layer is responsible for managing contexts.
A new context is created using gpcogl_gli_make_context() or gpcogl_gli_make_context_window(). The former creates an off-screen rendering context (typical use case), the latter creates a GUI window for debugging (no array download from the GPU is possible). Some GLIs do not support the _window variant and most applications shouldn't use it. The newly created context is always activated automatically.
Some GLIs require an option argument when creating a contexts, e.g. to specify which GPU to use. The user manual has more on GLI options.
gpcogl_gli_destroy_context() removes a context, freenig up all memory associated with it.
There is no explicit context switch call because each call that operates in a context will take a context argument, typically as the first argument. The lib assumes no other part of the software makes OpenGL context switches.
If screen target was chosen for debugging, using gpcogl_gli_make_context_window(), the result of a computation appears only after calling gpcogl_flush();
The actual screen rendering, which is really a main loop, has to be triggered by calling ctx->screen_render() with a callback function. The callback function may call compute() functions and then gpcogl_flush(). The output of any compute is redirected to the RGB GUI window, there is no way to download computed array data.