Home

Awesome

flextGL

Build Status Coverage Status

flextGL is an OpenGL and Vulkan header and loader generator.

It is a bit different than other comparable systems:

You will need the following dependencies:

What's new?

Source tree

Usage

You create your loader code by writing a profile file and passing it to the script.

Here is what a typical profile might look like:

version 3.3 core
extension EXT_texture_filter_anisotropic optional
extension ARB_tesselation_shader optional

This requests an OpenGL core profile and the extensions for anisotropic filtering and tesselation shaders. Those extensions were requested as optional. This means that a missing extension won't cause an error. Instead, the programmer will have to check before using it. This can be easily done by testing a generated global variable. For OpenGL ES a typical profile might look like:

version 3.0 es
extension OES_standard_derivatives optional
extension OES_vertex_array_object optional

Because the world is far from ideal, certain vendors don't bother upstreaming their extensions. To handle that, one can supply additional spec URLs to get merged to the main one. Local files passed to extraspec also work, in case it's needed to manually add an entrypoint defined nowhere else. If the file path is relative, it's resolved relative to the profile file location.

version 2.0 es

extraspec https://raw.githubusercontent.com/google/angle/master/scripts/gl_angle_ext.xml

# This one is from the vanilla gl.xml
extension OES_vertex_array_object optional
# This one ... thanks for the unnecessary extra pain, Google
extension ANGLE_multi_draw optional

A Vulkan profile, whitelisting only some particular functions, can look like:

version 1.1 vulkan

extension KHR_swapchain optional

begin functions
    CreateInstance
    CreateBuffer
    CmdDraw
    CreateSwapchainKHR
end functions

In case of Vulkan it's also possible to generate the output from a particular release by saying e.g. version 1.1.73 vulkan. That is useful in case you need to match exactly the release version required by vulkan.hpp, for example.

The profile file is then passed to the script like this:

$ python flextGLgen.py -D generated -t <template-of-your-choice> profile.txt

This will create the requested source code and put it in the generated/ directory.

The best way to work with flextGL is to integrate it in your build-system. The example project demonstrates this for Make and CMake here.

Generated API for OpenGL

The builtin OpenGL templates all generate the following API:

Take a look at the example program to get an idea on how it's used.

Note that it's possible to supply your own template with your own API that might or might not resemble the above.

Generated API for Vulkan

For simplicity, the default template generates all function pointers globally and loads them as instance-specific. See this blog post for other options. Apart from Vulkan APIs, two functions are defined:

Note that it's possible to supply your own template with your own API that might or might not resemble the above.

Templates

At the moment, there are three template sets available:

Installing Wheezy Template on Windows

If you have Python 3.4+ installed you should be able to install Wheezy using pip.

$ pip install --user wheezy.template

The --user does a local install in your home-folder. You can omit it if you want to do a system-wide installation.

If you have an older version of Python or don't have pip for some reason, then you need to install it first.

Credits

License

flextGL is licensed under the MIT/Expat license, see the COPYING file for details.