A modern, lightweight 3D game engine built with C++20 and OpenGL 4.5.
Xi Engine is a cross-platform game engine designed for real-time 3D applications. It features a modular architecture with an Entity Component System (ECS), physically-based rendering (PBR), and an integrated editor interface.
- Application Framework - Window management, input handling, and game loop
- Entity Component System - Flexible, data-oriented architecture for game objects
- Resource Management - Centralized loading and caching of assets
-
OpenGL 4.5 Renderer - Modern graphics pipeline with shader-based rendering
-
Physically-Based Rendering - PBR materials with metallic-roughness workflow
-
Multiple Light Types - Directional, point, and spot lights
-
Render Queue - Automatic sorting for opaque and transparent objects
-
Framebuffer Support - Off-screen rendering for editor viewports
Hereβs a small README section you can add (clean and simple, suitable for docs or a repo):
Xi Engine now supports Lua scripting for game development π This allows developers to quickly prototype and build gameplay logic using simple, lightweight scripts.
With Lua scripting, you can:
- Control object movement and behavior
- Handle input (keyboard, mouse, controller)
- Update game logic every frame
- React to events like start, update, and collisions
- Build full game mechanics without recompiling the engine
-- Script for Cube 1
-- This script allows the cube to move using WASD keys
local speed = 5 -- Movement speed (units per second)
-- Called once when the script starts
function OnStart()
-- Print a message to the console to inform the user
Log.Info("Movement enabled - use WASD")
end
-- Called every frame
-- dt = delta time (time passed since last frame)
function OnUpdate(dt)
-- Calculate movement distance based on frame time
local moveSpeed = speed * dt
-- Move forward when W is pressed
if Input.IsKeyDown(Key.W) then
Translate(0, 0, -moveSpeed)
end
-- Move backward when S is pressed
if Input.IsKeyDown(Key.S) then
Translate(0, 0, moveSpeed)
end
-- Move left when A is pressed
if Input.IsKeyDown(Key.A) then
Translate(-moveSpeed, 0, 0)
end
-- Move right when D is pressed
if Input.IsKeyDown(Key.D) then
Translate(moveSpeed, 0, 0)
end
endLua scripts are attached directly to game objects, making iteration fast and flexible for both developers and designers.
- ImGui Integration - Immediate mode GUI for editor tools
- Scene Hierarchy - Visual tree view of all entities
- Inspector Panel - Component editing interface
- Console - Runtime logging and debugging
- Scene Viewport - Real-time 3D preview with camera controls
- Collision Detection - Box and sphere colliders
- Rigid Body Dynamics - Mass, velocity, and force-based simulation
- Fixed Timestep - Deterministic physics updates
- MiniAudio Backend - Cross-platform audio playback
- Audio Sources - Positional audio components
- Audio Clips - Sound asset management
xi.mp4
Xi Engine/
βββ Engine/
β βββ Core/ # Application, Window, Input, Time, Logging
β βββ ECS/ # Entity, Component, System, World
β β βββ Components/ # Transform, MeshRenderer, Light, etc.
β βββ Renderer/ # Shader, Mesh, Material, Camera, Framebuffer
β βββ Physics/ # PhysicsWorld, Collision, Colliders
β βββ Audio/ # AudioEngine, AudioClip
β βββ Editor/ # EditorUI, SceneHierarchy, Inspector, Console
β βββ Resources/ # ResourceManager, SceneSerializer
βββ Game/ # Game-specific application code
βββ vendor/ # Third-party dependencies
βββ Shaders/ # GLSL shader files
| Library | Version | Purpose |
|---|---|---|
| GLFW | 3.x | Window and input management |
| GLEW | 2.x | OpenGL extension loading |
| GLM | 0.9.9+ | Mathematics library |
| Dear ImGui | 1.89+ | Editor interface |
| stb | - | Image loading |
| MiniAudio | - | Audio playback |
| nlohmann/json | 3.x | Scene serialization |
- Visual Studio 2022 (v145 toolset)
- Windows 10 SDK
- C++20 compatible compiler
-
Clone the repository:
git clone https://github.com/essam-tobgi-dev/Xi-Engine.git cd Xi-Engine -
Open
Xi Engine.slnin Visual Studio 2022 -
Select the desired configuration:
- Debug x64 - Development with debugging symbols
- Release x64 - Optimized build
-
Build the solution (F7 or Build > Build Solution)
-
Run the application (F5)
- Right-click + Drag - Enable camera control
- W/A/S/D - Move forward/left/backward/right
- Q/E - Move down/up
- Shift - Increase movement speed
- Mouse - Look around
- Escape - Quit application
#include "Engine/Core/Application.h"
#include "Engine/ECS/World.h"
#include "Engine/ECS/Components/Transform.h"
#include "Engine/ECS/Components/MeshRenderer.h"
class MyGame : public Xi::Application {
public:
void OnInit() override {
Xi::World& world = GetWorld();
Xi::Renderer& renderer = GetRenderer();
// Create an entity
Xi::Entity cube = world.CreateEntity("Cube");
// Add components
auto& transform = world.AddComponent<Xi::Transform>(cube);
transform.position = glm::vec3(0.0f, 1.0f, 0.0f);
auto& meshRenderer = world.AddComponent<Xi::MeshRenderer>(cube);
meshRenderer.mesh = Xi::Primitives::CreateCube();
meshRenderer.material = CreateMaterial(renderer);
}
};Xi Engine uses a component-based architecture where:
- Entities are unique identifiers (IDs)
- Components are pure data structures
- Systems operate on entities with specific component combinations
- Scene objects submit render commands to the queue
- Commands are sorted (front-to-back for opaque, back-to-front for transparent)
- Materials bind shaders and set uniforms
- Meshes are drawn with the appropriate render state
The editor renders the scene to an off-screen framebuffer, which is then displayed in an ImGui window. This allows for viewport manipulation without affecting the final output.
This project is licensed under the MIT License - see the LICENSE file for details.
- Learn OpenGL - Graphics programming tutorials
- Game Engine Architecture - Engine design reference
- EnTT - ECS design inspiration