Additional Header Files#

The PowerVR Framework contains some useful header files that solve some of the most problematic OpenGL issues and bring Vulkan closer to the C++ world.

These header files have no dependencies and are not part of any module. They can be used exactly as they are and each one functions individually. They can all be found in [SDKROOT]/include.

vk_bindings.h and vk_bindings_helper.h#

In Vulkan, each driver, device, or Vulkan installation on the developer’s system is represented as Vulkan objects. For example, there is the VkInstance, the VkPhysicalDevice, VkDisplay and others. The Vulkan API is used by calling vk functions globally and passing the corresponding object – for example vkCreateBuffer(myVulkanDevice…).

Objects that belong to different physical devices (and their corresponding VkPhysicalDevice) need to dispatch to different functions. This is because they use different drivers to implement the functions. The Vulkan Loader (the vulkan-1.dll that is linked against) will need to do this dispatching, because the global function called is located in the loader. The loader must therefore determine which device it needs to be dispatched to, and then call the appropriate function. It must return the result of the function call. This process causes a needless level of indirection.

The Vulkan-recommended way to tackle this is simple. Do not use the global functions for functions dispatched to a VkDevice – these are functions that get a VkDevice as their first parameter. Instead, get function pointers for the functions specific to that device, so that the dispatching can be skipped.

vk_bindings.h does exactly this. It is an auto-generated file that provides all the function pointer definitions and loading code to get per-instance and per-device function pointers.

DynamicGles.h and DynamicEGL.h#

DynamicGles.h and DynamicEgl.h 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:

  1. Drop the files somewhere where the compiler will find the header file. This is usually wherever library header files are usually stored.

  2. Enable OpenGL ES functions by writing down #include DynamicGLES.h at the top of the code file.

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. Everything else is done automatically, including loading the extension function pointers.

You do not need to link to the libraries (libGLESv2.dll/.lib/so,libEGL.dll/.lib/so) because 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. You can do this 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.