Each OpenGL context in your application will need a GLAF context for it.
Declare as many GLint variables as contexts you have, for storing
the ID of each GLAF context.
After creating each OpenGL context, call glaf_InitializeContext()
in order to create (and initialize) the GLAF context that belongs to the
OpenGL context. This call has some overhead because GLAF will check for
feature availability, guess the best way of accessing features depending
on the OpenGL version and the extensions string, and cache the pointers
to functions if the feature needs functions (some features are enumerant-based
Of course, the OpenGL context must be current before you call glaf_InitializeContext().
Store the return value of glaf_InitializeContext() in the proper
If you want verbose messages of GLAF context initialization, register a
verbose callback with glaf_SetVerbose() before you call glaf_InitializeContext().
Otherwise, the initialization will be silent.
If your application has more than one context, call glaf_ReadyForContext(id)
after making a context current, and before you call any other GLAF functions
in the context. This function is very fast (just updating a global
pointer to point to the current context structure). If your application
has just one context, you don't need to call glaf_ReadyForContext(id),
because glaf_InitializeContext() implies glaf_ReadyForContext(id).
If your application needs to destroy contexts at runtime, call glaf_FreeContext(id)
for such purpose.
And that's all about contexts' management.
Alternative contexts management
If you're sure about your OpenGL implementation providing the same extensions
and procedure addresses for all the contexts in your application, you can
create just one GLAF context (call glaf_InitializeContext just
once), and you don't need to call glaf_ReadyForContext at all. Note,
however, than this may be non-portable across platforms, since the requisites
for constant procedure addresses are different in different platforms.
Just read the documentation for all platforms that you plan to support.
Using one GLAF context for several OpenGL contexts is an easy way
of achieving straightforward thread-safety.
Use of features
For a given feature XXXXX, call glaf_IsXXXXXSupported() for
determining availability. These functions are also very fast, because
they just return a cached result, so you can afford to call them from your
Functions (if any) for feature XXXXX match those of the original
API. If you'll use GLAF names, just substitute the 'gl' preffix
by 'glaf_' and eliminate any extensions suffixes if they exist.
If you'll use OpenGL names, use core-naming (not extension-naming). Anyway,
read the GLAF features documentation, because some features may need additional
About enumerants (if any) for feature XXXXX, you can use the
original enumerants from your OpenGL include files if you wish. Alternatively,
you can use GLAF enumerants (just substitute the 'GL_' preffix by
and eliminate any extension suffixes). These GLAF enumerants are defined
numerically, so you can compile with support of advanced features even
if your OpenGL include files are outdated. Apart from compilation compatibility,
the choice doesn't matter, since both GLAF and GL enumerants contain the