Skip to content
This repository has been archived by the owner on Mar 13, 2024. It is now read-only.

Henauxg/ExperimEngine

Repository files navigation

ExperimEngine

ExperimEngine is a personal side project made to experiment (hence the name) with various tech pieces in order to make a tiny C++ game engine.

Along the way, I aim to learn many things such as 3D graphics with Vulkan, some shader fun, and to embed a scripting/modding language.

Current work :

  • Investigation for a scripting language
  • Integration of an old-school CPU renderer made by a friend, as an application to test texture rendering

Done :

  • Integration of Dear ImGui docking/viewports branch in the native Vulkan Renderer.
  • Web-support : WebGPU renderer implementation and integration of Dear ImGui in the WebGPU renderer.

Modding and Scripting

ExperimEngine will include an API for a second language both for scripting and modding. A common way of doing this is to embed a language into the host language (here C++), see embeddable_languages. In adddition to modding, this allow for quick iteration while working a on a game by reloading scripts at run-time instead of a slow C++ compilation. Both modding and scripting have similar needs : there needs to be a fast, easy to use and powerful C++ API.

Lua is the language considered for now but this may still change.

Languages being evaluated

Lua :

Classic embedded language in game engines. Pros :

  • Blazing fast perfomances, thanks to LuaJIT
  • Awesome C++ interop (with sol, although others exist)
  • Open-source and light-weight
  • Easy to embed

Cons :

  • LuaJIT is not maintained (and quite complex) and is 32-bit only
  • Lua's best performances come from the JIT but JIT compiling seems to be forbidden on apple devices
  • Weird syntax, 1-indexed arrays, feels quite different from usual languages nowadays.

Wren

Wren is described as "Smalltalk in a Lua-sized package with a dash of Erlang and wrapped up in a familiar, modern syntax" Pros :

  • Fast, without JIT
  • Open-source and light-weight
  • Easy to embed
  • Modern syntax

Cons :

  • C++ interop seems seems less advanced than sol in lua
  • Quite a niche language (ecosystem, tooling, user-base)

C#/.NET

I planned to :

Scripting in C# could great but the main problem is to obtain a clean C#/C++(classes/objects) interop without resorting to Windows-only solutions. The C#/.NET ecosystem seems to be rapidly evolving with interop being taken into account.

Pros:

Cons :

  • Not light-weight
  • Hard to embed, hard to provide an egronomic & performant C++ interop

Mono is an open source implementation of Microsoft's .NET Framework, and provides a good embedding API but seems to be behind in terms of features and performances.

Elements to investigate :

  • UnrealCLR for C++/C# in Unreal Engine.
  • Compatibility with emscripten/webassembly ?

Javascript :

Embedding google's V8 and its C++ API or another JS engine (Mozilla's SpiderMonkey).

Pros :

  • Gigantic eco-system, widespread language with good community support/tooling
  • Good C++ interop (V8)

Cons :

  • V8/SpiderMonkey are not light-weight

There are some lighter JS engine out there : Duktape, JerryScript and more, but I have yet to investigate the performance impact & C++ interop possibilities.

Cross-platform support

Native support

Libraries and languages are chosen with cross-platform as a focus point. As of today, there should be no major concern in targeting platforms such as Windows, Linux, MacOs, Android and more.

Right now, the build system is focused on Windows 64 bits only for practical reasons (read laziness, the current development environment is Wx64).

Web support

Idealy, an ExperimEngine app should be able to run on a web-browser.

Current state : Implementation of a separate WebGPU rendering backend

Technologies :

  • Emscripten to compile C++ to WebAssembly.
    • emscripten also provides support for the SLD2 API (already used as an OS abstraction in ExperimEngine).
    • If OpenGL was a rendering target, emscripten could also be used to automatically convert it to WebGL.
  • WebGPU, a modern API for GPU rendering on the web. It is pretty similar to (and relies on) APIs such as Metal, Vulkan and DirectX12, although a bit higher level, and with web safety in mind.
    • As of today (06/12/2020) WebGPU is still in a really early stage and only available in experimentals features of some web-browsers, which does not seem like an issue : by the time I would be able to develop a back-end for it, it could be stabilized/mature enough.
    • Supporting WebGPU and Vulkan would mean implementing/supporting 2 rendering backends in ExperimEngine (*)

(*) About supporting 2 backends :

As far as I understand, since WebGPU has Metal/Vulkan/DX12 implementations, it's in theory more portable than Vulkan. So I could get away with just a WebGPU backend and target pretty much the same platforms as Vulkan+WebGPU.

See projects like wgpu-rs (see also : wgpu & gfx-rs) for Rust or Dawn in C++.

I still intend to keep working on a separate Native Vulkan renderer for now. This may prove too heavy but I hope that WebGPU relying on Vulkan means that both backends would share a lot in term of workflow with WebGPU being the simplest.

Issues encountered :

  • I was hoping to reuse the same glsl/spirv shaders used for Vulkan renderer in WebGPU. So far it is not the case since some Vulkan shaders use features not (yet?) available in WebGPU :
    • Push constants are not included in WebGPU yet, see issue 75
    • Combined image samplers are not included in WebGPU yet, see issue 770

Dependencies/Libraries

For now dependencies (windows 64bits) are packaged within the project in order to facilitate the environment setup on multiples machines.

Some of the dependencies may become git submodule.

Libraries are picked trying to respect as much as possible the following criterias :

  1. C/C++
  2. Cross-platform
  3. Light-weight & Performant

Used :

Vulkan:

Scripting:

Others:

May be used in the future :

Tooling

Credits and useful resources

Vulkan

WebGPU

OpenGl and 3D

License:

MIT. See LICENSE

About

Tiny C++ game engine experimentation

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages