What are DynamicGles.h and DynamicEGL.h?

DynamicGles.h and DynamicEgl.h provide access to all OpenGL ES or EGL functions with a single convenient header file

DynamicGles.h and DynamicEgl.h are based upon similar principles - they provide a convenient single header file solution that loads OpenGL ES/EGL. This includes all supported extensions, dynamically and without statically linking to anything, by using advanced C++ features.

To use them, drop the files somewhere where the compiler will find the header file. This is usually wherever library header files are usually stored. “#include DynamicGLES.h” can then be written at the top of the code file, and everything will just work. The code will then have OpenGL ES functions available.

There is no need to link against EGL or OpenGL ES, or define function pointers.

It is still necessary to test for extension support, and there is a function for that in EGL. However, everything else is automatic including loading the extension function pointers.

The libraries (libGLESv2.dll/.lib/so,libEGL.dll/.lib/so) do not need to be linked to as they are loaded at runtime. However, they do need to be present on the platform where the application runs, and accessible to the application at runtime.

DynamicGles.h can limit the compile-time OpenGL ES version. This can be done by defining DYNAMICGLES_GLES2, DYNAMICGLES_GLES3, DYNAMICGLES_GLES31, or DYNAMICGLES_GLES32. The default is always the highest supported.

These are all replacements for the corresponding gl2.h/gl3.h/gl2ext.h/egl.h, so these do not need to be included directly.

Whenever possible, namespaces are used to group symbols and keep the global namespace as clear as possible.

  • DynamicGles.h places functions in gl:: (so glGenBuffers becomes gl::GenBuffers) unless DYNAMICGLES_NO_NAMESPACE is defined before including the file.
  • DynamicEGL.h places functions in egl:: (so eglSwapBuffers becomes egl::SwapBuffers) unless DYNAMICEGL_NO_NAMESPACE is defined before including the file.