Comparison of C++ Low-Level Graphics, Cross-Platform Frameworks and Libraries
Tags: cpp, opensource
Published: 2020-02-04 14:18:06

(This article is self-translation from [my original post in Japanese](https://qiita.com/funatsufumiya/items/98ca9aca0c9f8b608ca1). I'm sorry if not translated well.)

I usually write codes of graphical, cross-platform apps with **OpenGL**, but recently thought how I can create apps supporting **Metal**, **DirectX**, or **Vulkan** with **Low-Level Graphics APIs**.

So I researched frameworks and libraries which is:

- **Implemented in C++** ( C++98 or 11,14,17 etc. )
- **Supports low-level graphics APIs** ( Vulkan, DirectX11/12, Metal etc. )
- **Cross platform** ( Win/Mac/Linux, iOS/Android etc. )
- **Lightweight or embeddable / extensible** compared to Unity and Unreal Engine 4

**Note:** I just focused on low-level Graphics APIs. So **please check other articles if you need comparison of game engines**. There are many game engines implemented with frameworks in this article.

## Table of Contents

| |Pros :white_check_mark: |Cons :x: |
|---|---|---|
|[LLGL](#llgl-low-level-graphics-library)|Supports many APIs|Need knowledge of each platform|
|[The Forge](#the-forge)|Supports many platforms|Need knowledge of each platform|
|[Diligent Engine](#diligent-engine)|Same code for platforms|No Metal support|
|[bgfx](#bgfx)|Same code for platforms / Easy|No tessellation shader support[^3]|
|[oryol / sokol_gfx](#oryol-sokolgfx)|For embedded and Web|No computing shader|
|[Methane Kit](#methane-kit)|Win / Mac compatibility|No mobiles support|
|[bs::framework](#bsframework)|For game engine development|Only stable in Windows|

## LLGL (Low Level Graphics Library)

https://github.com/LukasBanana/LLGL

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/hte297qq2974kpzcoexv.jpeg)

- License: **BSD-3 clause**

- Supported Platforms:

|  | DirectX | Metal | Vulkan | OpenGL | OpenGL ES | 
|---|---|---|---|---|---|
| Windows | :white_check_mark: | - | :white_check_mark: | :white_check_mark: | - |
| Mac | - | :white_check_mark: | - | :white_check_mark: | - |
| Linux | - | - | :white_check_mark: | :white_check_mark: | - |
| Android | - | - | :x: | - | :white_check_mark: |
| iOS | - | :white_check_mark: | - | - | :x: |

- Supported Shader Types:

| Vertex | Fragment | Compute | Geometry | Hull (TC) | Domain (TE) | 
|---|---|---|---|---|---|
| :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |

( Different shaders needed for each platform such as glsl/hlsl/metal/spv. No automatic cross-compilation. )

- Summary:

Few dependencies and easy build using cmake. Supporting DirectX / Metal / Vulkan / OpenGL (ES), and every types of shaders. I think this is **the most comprehensive and high performance framework**, with compact implementation.

This framework wraps low-level APIs, but **you have to configure every parameter for different platform, and sometimes different codes using macros are needed**. So the highest performance on each platform can be achieved, but you need advanced knowledge of Metal, DirectX and Vulkan, and also GPU.

Additionally, **different shaders are needed for each platform**. In this case, cross-compiling your shader code by yourself makes it easier, using `spirv-cross` or `shaderc` and so on. This can be bothered, but separated shaders are good point when higher performance and detailed configuration is needed.

## The Forge

https://github.com/ConfettiFX/The-Forge

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/0w6tgexw5kir8m1p5ygi.jpeg)

- License: **Apache-2.0**

- Supported Platforms:

|  | DirectX | Metal | Vulkan | OpenGL | OpenGL ES | 
|---|---|---|---|---|---|
| Windows | :white_check_mark: | - | :white_check_mark: | :x: | - |
| Mac | - | :white_check_mark: | - | :x: | - |
| Linux | - | - | :white_check_mark: | :x: | - |
| Android | - | - | :white_check_mark: | - | :x: |
| iOS | - | :white_check_mark: | - | - | :x: |

( Also supports **XBOX, PS4, Switch, Stadia.** )

- Supported Shader Types:

| Vertex | Fragment | Compute | Geometry | Hull (TC) | Domain (TE) | 
|---|---|---|---|---|---|
| :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |

( Need different shaders for each platforms such as glsl/hlsl/metal/spv. No automatic cross-compilation. )

- Summary:

This is very **high-quality framework created for implementing renderers** of custom (or your own) game engine. However, **OpenGL (ES) is not supported**. So you can't use this for older smartphones or PCs.

This framework seems to be **stable and well maintenanced**. CI and unit tests are used in many cases and already used in many products.

The usability is just like [LLGL](#llgl-low-level-graphics-library). Advanced knowledge of each platform is needed, but you can configure as you like if high performance is needed.


## Diligent Engine

https://github.com/DiligentGraphics/DiligentEngine

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/al02wz71gpbhadav1i5u.jpeg)

- License: **Apache-2.0**

- Supported Platforms:

|  | DirectX | Metal | Vulkan | OpenGL | OpenGL ES | 
|---|---|---|---|---|---|
| Windows | :white_check_mark: | - | :white_check_mark: | :white_check_mark: | - |
| Mac | - | :x: | :white_check_mark: (MoltenVK) | :white_check_mark: | - |
| Linux | - | - | :white_check_mark: | :white_check_mark: | - |
| Android | - | - | :x: | - | :white_check_mark: |
| iOS | - | :x: | :white_check_mark: (MoltenVK) | - | :white_check_mark: |

- Supported Shader Types:

| Vertex | Fragment | Compute | Geometry | Hull (TC) | Domain (TE) | 
|---|---|---|---|---|---|
| :white_check_mark: | :white_check_mark: | :white_check_mark: (`*2`) | :white_check_mark: | :white_check_mark: | :white_check_mark: |

  
( `*1` Shaders are automatically cross-compiled from HLSL )
( `*2` Can not use compute shader in Mac OpenGL, because Mac only supports OpenGL 4.1 or lower )

- Summary:

Few dependencies and easy build using cmake [^1]. This framework's name has "Engine" but this is **lightweight and portable** framework.

Noteworthy, **the same source code (without macros) and shaders are applied for every platform**. In most cases, rewriting your code is not needed.

However, disappointedly, **Metal is not supported** so that **compute shader cannot be used on Mac OpenGL** (because Mac's OpenGL version is lower than 4.3.) Except for that, there is very **efficiently implemented modern API**, when compared to [bgfx](#bgfx) (similar framework, describes later), 

## bgfx

https://github.com/bkaradzic/bgfx

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/2zt22dm52ysqn9noogr7.jpeg)

- License: **BSD-2 clause**

- Supported Platforms:

|  | DirectX | Metal | Vulkan | OpenGL | OpenGL ES | 
|---|---|---|---|---|---|
| Windows | :white_check_mark: | - | :white_check_mark: | :white_check_mark: | - |
| Mac | - | :white_check_mark: | :question: | :white_check_mark: | - |
| Linux | - | - | :white_check_mark: | :white_check_mark: | - |
| Android | - | - | :question: | - | :white_check_mark: |
| iOS | - | :white_check_mark: | :question: | - | :white_check_mark: |

( Supports **WebGL** with Emscripten or asm.js. Also supports Raspberry Pi )

- Supported Shader Types:

| Vertex | Fragment | Compute | Geometry | Hull (TC) | Domain (TE) | 
|---|---|---|---|---|---|
| :white_check_mark: | :white_check_mark: | :white_check_mark: | :x: | :x: (`*2`) | :x: (`*2`) |

( `*1` Automatically cross-compiled from original shader language like GLSL )
( `*2` For DirectX and OpenGL, there is [an unofficial fork](https://github.com/LSBOSS/bgfx) which enables hull/domain shader, but not maintenanced for a long time... )

- Summary:

Released and being **developed since 2015**, there are many products using this framework, and **many examples and forums'  Q&As can be found**. Building this framework is also easy with cmake, and an original build manager called GENie makes it easier.

Just like Diligent Engine, **the same source code is used for multiple platforms** without macros (in most cases). **APIs are very simple and easy to understand** and very extensible with libraries you want. 

However, only one regrettable point is that **tessellation shaders are not supported**, but computer shader enables it (see the official examples.) And this can be done in Mac and iOS because **Metal is supported**, this is very strong point when compared to Diligent Engine.

About shaders, an original shader language like GLSL will be automatically cross-compiled for all platforms. But it is a little unique, variable definition of input and output as a header file for them.

At last, please note that **some functionalities are limited for platform compatibility**, such as 
 not complete command buffers, tessellation shader (described above). **The compatibility seems to be treated as the most important point** in this framework's development policy. I feel this is the good point, but can be a burden of the performance. Moreover, some APIs is not so modern and not so efficient when compared to Diligent Engine. But this may be improved because recently often updated.  

## oryol / sokol_gfx

https://github.com/floooh/oryol
https://github.com/floooh/sokol

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/kinmnem98407ugq6tvil.jpeg)

- License: **MIT** (oryol), **zlib** (sokol)

- Supported Platforms:

|  | DirectX | Metal | Vulkan | OpenGL | OpenGL ES | 
|---|---|---|---|---|---|
| Windows | :white_check_mark: | - | :x: | :white_check_mark: | - |
| Mac | - | :white_check_mark: | :x: | :white_check_mark: | - |
| Linux | - | - | :x: | :white_check_mark: | - |
| Android | - | - | :x: | - | :white_check_mark: |
| iOS | - | :white_check_mark: | :x: | - | :white_check_mark: |

( **WebGL** is supported, and you can run on **Raspberry Pi** with OpenGL ES. )

- Supported Shader Types:

| Vertex | Fragment | Compute | Geometry | Hull (TC) | Domain (TE) | 
|---|---|---|---|---|---|
| :white_check_mark: | :white_check_mark: | :x: | :x: | :x: | :x: |

( For `sokol_gfx`, you should prepare shaders for each platform. )
( For `oryol`, GLSL-like language is auto cross-compiled. )

- Summary:

`oryol` and `sokol_gfx` are created by the same author. `sokol_gfx` is a **header-only single file library for C language**, and `oryol` is a **lightweight C++ framework**. It is designed as [Orthodox C++](https://gist.github.com/bkaradzic/2e39896bc7d8c34e042b), so you can probably use it with C++11 with older compilers.

These two are very **compact file-size libraries, having sufficient functionalities**. This feature will work well with **WebGL**, the total file size will be very small when compiling with `asm.js`/`wasm`.

The only feature I miss, is that **compute shader is not supported**. But the author says that it may be implemented as another library as an addon (for sokol_gfx). This is very good news if true.

## Methane Kit

https://github.com/egorodet/MethaneKit

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/vdzgwo227brlpq78olvr.jpeg)

- License: **Apache-2.0**

- Supported Platforms:

|  | DirectX | Metal | Vulkan | OpenGL | OpenGL ES | 
|---|---|---|---|---|---|
| Windows | :white_check_mark: | - | :x: | :x: | - |
| Mac | - | :white_check_mark: | :x: | :x: | - |
| Linux | - | - | :white_check_mark: (`*1`) | :x: | - |
| Android | - | - | :x: | - | :x: |
| iOS | - | :x: | :x: | - | :x: |

( `*1` Linux/Vulkan version is currently in development )

- Supported Shader Types:

| Vertex | Fragment | Compute | Geometry | Hull (TC) | Domain (TE) | 
|---|---|---|---|---|---|
| :white_check_mark: | :white_check_mark: | :x: | :x: | :x: | :x: |

( HLSL 5.1 is used for auto cross-compiling. )

- Summary:

This framework is based on C++17, and much **focused on **Desktop**. **Windows/Mac compatibility** is treated the most important in this framework. You just need the same source code and shaders for Windows/Mac. Recently, Linux/Vulkan version is announced and now in development.

This is very young framework which is published on GitHub a year ago, and now very actively updated recently.

## bs::framework

https://github.com/GameFoundry/bsf

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/ghrmyucyjcn9wajwvxh5.jpeg)

- License: **MIT**

- Supported Platforms:

|  | DirectX | Metal | Vulkan | OpenGL | OpenGL ES | 
|---|---|---|---|---|---|
| Windows | :white_check_mark: | - | :white_check_mark: | :white_check_mark: | - |
| Mac | - | :x: | :x: (`*1`) | :white_check_mark: (`*2`) | - |
| Linux | - | - | :white_check_mark: | :white_check_mark: | - |
| Android | - | - | :x: | - | :x: |
| iOS | - | :x: | :x: (`*1`) | - | :x: |

( `*1` Implementation via MoltenVK is under discussion, at the time of writing. )
( `*2` **Not working properly on Mac** at the time of writing. )

- Supported Shader Types:

| Vertex | Fragment | Compute | Geometry | Hull (TC) | Domain (TE) | 
|---|---|---|---|---|---|
| :white_check_mark: | :white_check_mark: | :white_check_mark: (`*2`) | :white_check_mark: | :white_check_mark: | :white_check_mark: |

( `*1` HLSL subset language is auto cross-compiled. )
( `*2` compute shader is disabled on Mac, because Metal/Vulkan is not supported and OpenGL 4.3 or above is required but not on Mac. )

- Summary:

This is **an integrated framework which provides functionalities for/as game engine**, created by the author of [Banshee 3D Engine](https://www.banshee3d.com/). This is **still in beta version** and very young, the first version was released only a year before.

Based on C++14, and provides the functionalities like Unity / UE4, scene component system, physics, file loading functions, animations, sound players, low-level graphics APIs. Well documented and well-structured.

However, **not working properly on Mac** at the time of this writing, and **mobiles are not supported**, and more, **Metal is not supported** [^2].

## Other frameworks

- Acid (https://github.com/EQMG/Acid) ....... Game engine with Vulkan / MoltenVK.
- magnum (https://github.com/mosra/magnum) ....... Game framework with OpenGL / WebGL. Considered to be implemented in Vulkan.
- Wicked Engine (https://github.com/turanszkij/WickedEngine) ....... 
 Game engine with DirectX, only for Windows.
- Rizz (https://github.com/septag/rizz) ....... Tiny C framework using sokol_gfx. [glslcc](https://github.com/septag/glslcc) is used for cross-compiling, and can use compute shader on DirectX as experimental.

**Note:** In this article I focused on low-level graphics APIs, so I intentionally wrote nothing about OpenGL-related frameworks, such as [openFrameworks](https://openframeworks.cc/) or [Cinder](https://libcinder.org/). However, there are Vulkan implementations  ([openFrameworks-vk](https://github.com/openframeworks-vk/openFrameworks), [Cinder-Vulkan](https://github.com/cinder/Cinder/tree/vulkan)). But it is experimental and not seems maintenanced well...

If you want to know about OpenGL related creative frameworks, I recommend [awesome-creative-coding](https://github.com/terkelg/awesome-creative-coding).

## Similar Frameworks ( Implemented in Other Languages )

- gfx-rs (https://github.com/gfx-rs/gfx) ....... Implemented in Rust language. This is the most complete framework in this theme. Maybe you can use it with C API from C++?
- veldrid (https://github.com/mellinoe/veldrid) ....... .NET Implementation.
- Kha (https://github.com/Kode/Kha) ....... Haxe Implementation. Many platforms and APIs are supported. It seems easy to use this. Probably you can use this framework if cross-compiled to C++.

## Conclusion

It became too long article than I expected... Thank you for reading. Any comments are welcome :)

I made simple comparison table:

| |Pros :white_check_mark: |Cons :x: |
|---|---|---|
|[LLGL](#llgl-low-level-graphics-library)|Supports many APIs|Need knowledge of each platform|
|[The Forge](#the-forge)|Supports many platforms|Need knowledge of each platform|
|[Diligent Engine](#diligent-engine)|Same code for platforms|No Metal support|
|[bgfx](#bgfx)|Same code for platforms / Easy|No tessellation shader support[^3]|
|[oryol / sokol_gfx](#oryol--sokol_gfx)|For embedded and Web|No computing shader|
|[Methane Kit](#methane-kit)|Win / Mac compatibility|No mobiles support|
|[bs::framework](#bsframework)|For game engine development|Only stable in Windows|

I maybe use bgfx if I need one in my production, because of its easiness and compatibility.

LLGL and The Forge are strong options for high performance. These two can be use for your own original game engine development. However, in some case, it have to be compared with Unity, or Unreal Engine 4.

## References

- awesome-vulkan (https://github.com/vinjn/awesome-vulkan#Libraries)

[^1]: In this time, Windows script is not prepared. So you have to read scripts for Mac/Linux, and mimic it and you need type some commands.
[^2]: For building, [Hello World](http://docs.bsframework.io/latest/build.html) can be built soon, but [Examples](https://github.com/gamefoundry/bsfExamples) needs many additional files before building by script, and every time fails downloading. You may need many modifications of your cmake file. And some case [not working properly on mac](https://github.com/GameFoundry/bsf/issues/129), I could not work it well on my laptop, with pre-built binary and original build from master branch.
[^3]: Tessellation with compute shader is supported.