Skip to content

kubazuch/kEn

Repository files navigation

kEn

A 3D game engine written in C++23 for self-education, featuring a custom math library, OpenGL 4.6 renderer, ECS-like scene graph, and an event system.

Greatly influenced by TheCherno's Game Engine series and Hazel, as well as my previous Java project.

The project structure originates from resin, a project I contributed to, and was further refined following eray, which also used resin as its base.

Modules

Module Description
mEn Header-only C++23 math library -- vectors, matrices, quaternions, GLSL-style free functions
kEn 3D rendering/engine library -- OpenGL backend, layer stack, event system, scene graph
Sandbox Demo application that consumes kEn

Requirements

  • CMake 3.30+
  • C++23 compiler: MSVC (VS 2022), GCC 14, or Clang
  • Ninja (recommended for dev builds)

All other dependencies are fetched automatically via CMake's FetchContent: GLAD v2.0.8 (OpenGL 4.6), GLFW 3.4, ImGui 1.92.6-docking, ImGuizmo 1.83, assimp 6.0.4, nativefiledialog-extended 1.3.0, spdlog 1.17.0, stb

Building

The project uses CMake Presets.

Windows (MSVC + Ninja)

# Debug
cmake --preset=windows-msvc-debug
cmake --build --preset=windows-msvc-debug

# Release
cmake --preset=windows-msvc-release
cmake --build --preset=windows-msvc-release

Windows (Clang + Ninja)

# Debug
cmake --preset=windows-clang-debug
cmake --build --preset=windows-clang-debug

Linux (GCC 14)

# Debug
cmake --preset=linux-gcc-debug
cmake --build --preset=linux-gcc-debug

# Release
cmake --preset=linux-gcc-release
cmake --build --preset=linux-gcc-release

Linux (Clang)

cmake --preset=linux-clang-debug
cmake --build --preset=linux-clang-debug

Output: build/bin/ (executables), build/lib/ (libraries).

CMake options

Option Default Description
BUILD_TESTING ON Build mEn unit tests (GoogleTest)
MEN_USE_GLM OFF Use GLM types instead of native mEn
BUILD_GLFW ON Fetch GLFW via FetchContent (OFF = system GLFW)
BUILD_ASSIMP ON Fetch assimp via FetchContent (OFF = system assimp)

Tests

Only mEn has a test suite. Tests use GoogleTest and are enabled by default (BUILD_TESTING=ON).

cmake --preset=windows-msvc-debug
cmake --build --preset=windows-msvc-debug
ctest --test-dir build/windows-msvc-debug

# Or run directly with a GTest filter
./build/bin/mEn_tests --gtest_filter="Vec3.*"

Architecture

mEn -- Math Library

Header-only INTERFACE library. Public API: mEn/src/mEn.hpp.

  • Vec2/3/4, Mat3/4, Quat -- column-major matrices, union-based swizzles (x/r/s, y/g/t, ...)
  • GLSL-style free functions -- dot, cross, normalize, mix, clamp, perspective, lookAt, slerp, and more; all accept scalars and vectors uniformly
  • Declarations in .hpp, implementations in *.inl (included at end of each header)
  • Optional GLM interop via MEN_USE_GLM

kEn -- Engine Library

Public API: kEn/src/kEn.hpp. Entry point: include kEn/src/kEn/core/entry_point.hpp and implement create_application().

  • Application -- singleton; fixed 60 TPS loop; owns LayerStack + Window
  • Layer stack -- ordered pipeline: on_attach -> on_update -> on_render -> on_imgui -> on_detach
  • Event system -- type-erased EventDispatcher; events bubble through layers in reverse order; KEN_BIND_EVENT_HANDLER() macro for member callbacks
  • Transform -- hierarchical with dirty-flag caching; world matrix lazily recomputed and propagated to children
  • Renderer -- static facade over OpenGL; manages scene data (view/proj matrices, lights); supports point, directional, and spot lights
  • Scene graph -- GameObject static registry (max 6400); parent-child hierarchy; GameComponent base for attach/update/render/imgui/event hooks
  • Built-in components -- ModelComponent, FreeLookComponent, FreeMoveComponent, LookAtComponent
  • Cameras -- OrthographicCamera, PerspectiveCamera
  • Asset loading -- OBJ/FBX via assimp; textures via stb_image

License

See LICENSE. Third-party license notices are in THIRD_PARTY_LICENSES/.

About

Yet another basic game engine for my self-education, this time in C++.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors