libgpcogl - GLI

A GLI is a small driver library acting as an openGL Interface, performing openGL Initialization. Before OpenGL can be used to instruct the GPU, an OpenGL context needs to be acquired. This has to be done through the operatingsystem (often via the windowing system). Since there are different systems and different methods (with different limitations) out there, this layer is modularized: gpcogl offers multiple GLI implementations.

The user needs to pick a GLI and use that GLI for initializing libgpcogl and creating contexts. Destroying the context and uninitializing the library is also done using the same GLI. (GLI has no other role - all the GPU controlling is done via OpenGL APIs by libgpcogl.)

Currently the following GLIs are shipped with libgpcogl:

Selecting a GLI

Most applications will use only one GLI at a time. Selecting the GLI is done by linking the given GLI, e.g. -lgpcogl_gli_glut or -lgpcogl_gli_noxgl.

The API is the same for all GLIs and is declared in gli.h. The only exception is the debug function gpcogl_gli_make_context_window() which may not be implemented by some GLIs.

GLI-specific options

gli_glut

The gpcogl_gli_init() call gets argc and argv, typically from main()'s argc and argv, holding configuration as specified for glutInit. The most notable argument is -display; this is how the GPU can be selected in case of having multiple GPUs, assuming the target GPU has an X11 running on it.

gli_noxgl

The gpcogl_gli_make_context() call's option argument is either NULL or contains the full path to the drm device to open, e.g. "/dev/dri/card0". This allows the caller to create multiple contexts using different drm devices.

When option is NULL, the GLI uses the environment variable GPCOGL_NOXGL_DEVICE for device path. If that's also NULL, it falls back to the hardwired "/dev/dri/card0".

Note: the env var and hardwired fallback options are available only when using gpcogl_gli_make_context() call; using gpcogl_noxgl_make_context() directly will always stick to whatever passed on in the option argument.

Advanced: using multiple GLIs

Normally a single GLI is picked and used. However, it is possible to link multiple GLIs and create parallel contexts using different GLIs. For this link multiple GLIs using -l and then do not use gli.h but the GLI-specific header, such as gli_glut.h or gli_noxgl.h.