loading...

Comparison of C++ Low-Level Graphics, Cross-Platform Frameworks and Libraries

funatsufumiya profile image funatsufumiya Updated on ・9 min read

(This article is self-translation from my original post in Japanese. 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 ✅ Cons ❌
LLGL Supports many APIs Need knowledge of each platform
The Forge Supports many platforms Need knowledge of each platform
Diligent Engine Same code for platforms No Metal support
bgfx Same code for platforms / Easy No tessellation shader support1
oryol / sokol_gfx For embedded and Web No computing shader
Methane Kit Win / Mac compatibility No mobiles support
bs::framework For game engine development Only stable in Windows

LLGL (Low Level Graphics Library)

https://github.com/LukasBanana/LLGL

Alt Text

  • License: BSD-3 clause

  • Supported Platforms:

DirectX Metal Vulkan OpenGL OpenGL ES
Windows - -
Mac - - -
Linux - - -
Android - - -
iOS - - -
  • Supported Shader Types:
Vertex Fragment Compute Geometry Hull (TC) Domain (TE)

( 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

  • License: Apache-2.0

  • Supported Platforms:

DirectX Metal Vulkan OpenGL OpenGL ES
Windows - -
Mac - - -
Linux - - -
Android - - -
iOS - - -

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

  • Supported Shader Types:
Vertex Fragment Compute Geometry Hull (TC) Domain (TE)

( 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. 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

  • License: Apache-2.0

  • Supported Platforms:

DirectX Metal Vulkan OpenGL OpenGL ES
Windows - -
Mac - ✅ (MoltenVK) -
Linux - - -
Android - - -
iOS - ✅ (MoltenVK) -
  • Supported Shader Types:
Vertex Fragment Compute Geometry Hull (TC) Domain (TE)
✅ (*2)

( *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 2. 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 (similar framework, describes later),

bgfx

https://github.com/bkaradzic/bgfx

Alt Text

  • License: BSD-2 clause

  • Supported Platforms:

DirectX Metal Vulkan OpenGL OpenGL ES
Windows - -
Mac - -
Linux - - -
Android - - -
iOS - -

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

  • Supported Shader Types:
Vertex Fragment Compute Geometry Hull (TC) Domain (TE)
❌ (*2) ❌ (*2)

( *1 Automatically cross-compiled from original shader language like GLSL )
( *2 For DirectX and OpenGL, there is an unofficial fork 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

  • License: MIT (oryol), zlib (sokol)

  • Supported Platforms:

DirectX Metal Vulkan OpenGL OpenGL ES
Windows - -
Mac - -
Linux - - -
Android - - -
iOS - -

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

  • Supported Shader Types:
Vertex Fragment Compute Geometry Hull (TC) Domain (TE)

( 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++, 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

  • License: Apache-2.0

  • Supported Platforms:

DirectX Metal Vulkan OpenGL OpenGL ES
Windows - -
Mac - -
Linux - - ✅ (*1) -
Android - - -
iOS - -

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

  • Supported Shader Types:
Vertex Fragment Compute Geometry Hull (TC) Domain (TE)

( 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

  • License: MIT

  • Supported Platforms:

DirectX Metal Vulkan OpenGL OpenGL ES
Windows - -
Mac - ❌ (*1) ✅ (*2) -
Linux - - -
Android - - -
iOS - ❌ (*1) -

( *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)
✅ (*2)

( *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. 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 3.

Other frameworks

Note: In this article I focused on low-level graphics APIs, so I intentionally wrote nothing about OpenGL-related frameworks, such as openFrameworks or Cinder. However, there are Vulkan implementations (openFrameworks-vk, Cinder-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.

Similar Frameworks ( Implemented in Other Languages )

Conclusion

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

I made simple comparison table:

Pros ✅ Cons ❌
LLGL Supports many APIs Need knowledge of each platform
The Forge Supports many platforms Need knowledge of each platform
Diligent Engine Same code for platforms No Metal support
bgfx Same code for platforms / Easy No tessellation shader support1
oryol / sokol_gfx For embedded and Web No computing shader
Methane Kit Win / Mac compatibility No mobiles support
bs::framework 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


  1. Tessellation with compute shader is supported.  

  2. 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. 

  3. For building, Hello World can be built soon, but Examples 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, I could not work it well on my laptop, with pre-built binary and original build from master branch. 

Posted on by:

funatsufumiya profile

funatsufumiya

@funatsufumiya

C++ / ML programmer, woking at a digital art creation company, in Japan.

Discussion

markdown guide