/game_engine

Primary LanguageC++MIT LicenseMIT

game_engine

A highly configurable C++ 2D game engine static library

It supports:

  • 2D hardware accelerate widget rendering with double-buffering
  • Multithreaded backend utilities (rendering, audio, inputs, asset load/unload)
  • Convinient loading & unloading of application dependencies
  • GUI tuning - frame rate, window specifics
  • Convinient mechanism of thread-safe communication channel with the rendering thread (UI thread)
  • External communicator integrated with the Engine. It can be conviniently extended with communication protocols such as (ROS2 executors, gRPC, RabbitMQ, etc...)
  • Convinient Base class Game skeleton, which could be easily extented into any specific Game object
  • Simple visual debugging tools (toggle with the ~ key in-game)

Examples:

int32_t main(int32_t argc, char **args) {
  Application app;

  const auto dependencies =
      GuiConfigGenerator::generateDependencies(argc, args);
  if (ErrorCode::SUCCESS != app.loadDependencies(dependencies)) {
    LOGERR("app.loadDependencies() failed");
    return EXIT_FAILURE;
  }

  auto game = std::make_unique<DevBattleGui>();
  app.obtain(std::move(game));

  const auto cfg = GuiConfigGenerator::generateConfig();
  if (ErrorCode::SUCCESS != app.init(cfg)) {
    LOGERR("app.init() failed");
    return EXIT_FAILURE;
  }

  if (ErrorCode::SUCCESS != app.run()) {
    LOGERR("app.run() failed");
    return EXIT_FAILURE;
  }

  return EXIT_SUCCESS;
}

Usage from plain CMake

  • Consume directly with find_package(game_engine) in a CMakeLists.txt
  • Link against your target with suitable access modifier
target_link_libraries(
    ${PROJECT_NAME} 
    PUBLIC
        game_engine::game_engine
)

Usage as part of ROS1(catkin) / ROS2(colcon) meta-build systems

  • Consume directly with find_package(game_engine) in the package CMakeLists.txt
  • Link agains your target
  • The library automatically exposes and install it's artifacts following ROS1/ROS2 structure
  • Example usage project: https://github.com/zhivkopetrov/robotics_v1

Dependencies

Supported Platforms

Linux:

  • g++ (9.3 and above)
    • Tested up to g++ 12.1
  • clang++ (10 and above)
    • Tested up to clang++ 14.0
  • Emscripten (3.1.28 and above)
    • emcc/em++
  • Robot Operating System 2 (ROS2)
    • Through colcon meta-build system (CMake based)
  • Robot Operating System 1 (ROS1)
    • Through catkin meta-build system (CMake based)
      • Due to soon ROS1 end-of-life catkin builds are not actively supported

Windows:

  • MSVC++ (14.20 and above) Visual Studio 2019
    • Tested up to 17.30 Visual Studio 2022
  • Emscripten (3.1.28 and above)
    • emcc/em++
    • NOTE: non-MSVC CMake build generator is needed
      • For example: ninja
  • ROS1/ROS2
    • Although the code is ROS compatible, actual ROS functionalities have not been tested on Windows