Skip to content

essam-tobgi-dev/Xi-Engine

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

14 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Xi Engine

image image

A modern, lightweight 3D game engine built with C++20 and OpenGL 4.5.

Download

Overview

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.

Features

Core Systems

  • 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

Rendering

  • 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):


Lua Scripting Support in Xi Engine

image

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

Example

-- 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
end

Lua scripts are attached directly to game objects, making iteration fast and flexible for both developers and designers.

Editor

  • 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

Physics

  • Collision Detection - Box and sphere colliders
  • Rigid Body Dynamics - Mass, velocity, and force-based simulation
  • Fixed Timestep - Deterministic physics updates

Audio

  • MiniAudio Backend - Cross-platform audio playback
  • Audio Sources - Positional audio components
  • Audio Clips - Sound asset management

Demo

xi
xi.mp4

Project Structure

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

Dependencies

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

Building

Requirements

  • Visual Studio 2022 (v145 toolset)
  • Windows 10 SDK
  • C++20 compatible compiler

Build Steps

  1. Clone the repository:

    git clone https://github.com/essam-tobgi-dev/Xi-Engine.git
    cd Xi-Engine
  2. Open Xi Engine.sln in Visual Studio 2022

  3. Select the desired configuration:

    • Debug x64 - Development with debugging symbols
    • Release x64 - Optimized build
  4. Build the solution (F7 or Build > Build Solution)

  5. Run the application (F5)

Controls

Editor Camera

  • 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

Application

  • Escape - Quit application

Usage Example

#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);
    }
};

Architecture

Entity Component System

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

Rendering Pipeline

  1. Scene objects submit render commands to the queue
  2. Commands are sorted (front-to-back for opaque, back-to-front for transparent)
  3. Materials bind shaders and set uniforms
  4. Meshes are drawn with the appropriate render state

Editor Integration

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.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

About

Xi Engine is a lightweight C++ game engine built with OpenGL (GLEW), GLFW, and ImGui, focused on simplicity, performance, and developer-friendly tooling. It provides a modern editor-driven workflow with real-time rendering, flexible architecture, and a minimal yet powerful core designed for learning, experimentation.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors