Skip to content

RobinLandraud/Strake-Engine

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation


Strake Engine

Circular Image

A full designed GameObject Component-Based OOP with OpenGL
" Explore the docs "

Table of Contents
  1. About The Project
  2. Getting Started
  3. Usage
  4. Screenshot
  5. Roadmap
  6. License
  7. Contact
  8. Acknowledgments

About The Project

With this project, I aimed to develop a comprehensive GameObject-Component System using Open Graphics Library (OpenGL). The goal is to create more stable and maintainable projects/games through a well-structured hierarchy that is both readable and easily modifiable.

Inspired by severals engines, this Component-Based OOP optimizes games automatically by updating entities at multiple frequency scales, ensuring efficient performance.

Built With

Our engine is built using a combination of powerful and flexible technologies to provide a smooth and efficient experience for both developers and users. Key components include:

  • C++: The core of the engine is written in C++, enabling high performance, low-level access, and flexibility for complex systems.
  • OpenGL: For rendering, OpenGL is used to handle 2D and 3D graphics, allowing for smooth and immersive visuals.
  • GLEW: GLEW (OpenGL Extension Wrangler) is used to manage OpenGL extensions, ensuring that the engine is compatible with a wide range of OpenGL features across different platforms.
  • GLM: The GLM library is utilized for math operations, providing essential functions for handling vectors, matrices, and transformations in 3D space.
  • GLFW: For managing windows, input, and context creation, GLFW provides a simple and cross-platform solution.
  • STB Image: STB Image handles texture loading, making it easy to import and work with various image formats in our rendering pipeline.
  • Assimp: Assimp (Open Asset Import Library) is used to import and process various 3D model formats, ensuring that the engine can work with a wide range of asset types and integrate external 3D models with ease.
  • CMake: Our build system is powered by CMake, simplifying the process of building the engine and its dependencies across different platforms.

These technologies come together to create an engine that is both powerful and easy to extend, providing a solid foundation for game development, simulation, and other interactive applications.

Getting Started

Follow these steps to set up and run the engine on your machine.

Prerequisites

Before you begin, ensure you have the following installed:

💡 Note for Windows Users: Library management is handled using the vcpkg package manager. Refer to the Windows installation steps for details.

  • C++ Compiler: A C++17 or later compatible compiler (e.g., GCC, Clang, or MSVC).
  • CMake: A cross-platform build system. CMake.
  • OpenGL: A modern OpenGL-compatible GPU and drivers.
  • GLEW: OpenGL Extension Wrangler. GLEW.
  • GLFW: A library for window and input management. GLFW.
  • GLM: Header-only math library. GLM.
  • Assimp: A library for importing and processing various 3D model formats. Assimp.

Additionally, ensure you have:

  • Git: For cloning the repository. Git.

Installation

  1. Clone the Repository
    Open your terminal or command prompt and run:

    git clone https://github.com/RobinLandraud/Strake-Engine
    cd Strake-Engine
  2. Install Dependencies Ensure all prerequisite libraries are installed before compiling the project.

    • On Linux: Libraries are typically managed through your package manager and located via the PATH environment variable. Ensure all required libraries are properly installed and accessible.

    • On Windows: Dependencies are managed using vcpkg. You need to update the VCPKG_TOOLCHAIN variable in your environmentby setting it to the path of your vcpkg.cmake installation. You need to update the VCPKG_BIN variable in your environment by setting it to the path of your vcpkg.exe installation. Here an example of .env file:

      VCPKG_TOOLCHAIN="C:/path/to/vcpkg/scripts/buildsystems/vcpkg.cmake"
      VCPKG_BIN="C:/path/to/vcpkg/vcpkg.exe"

      If prerequisites are not yet installed, use the command:

      just install
  3. Compile the Project

    💡 Note: Ensure all dependencies are installed before proceeding with the compilation.

    Open a terminal, navigate to the project directory, and build the project with this justfile command:

    just build

    Once the build process completes, the executable will be located in the Release folder:

    • Strake.out (Unix)
    • Strake.exe (Windows)

These steps will ensure the engine is properly compiled and ready to run on your platform.

Usage

To begin, we create a window and initialize the Engine. You can set up your scene and add objects within it.

1. Create the Application

Strake::Application app("Strake Engine V0.1.1", WIN_WIDTH, WIN_HEIGHT, FPS);

2. Create a texure

Strake::Texture &metalTexture = app.getTextureManager().addTexture<Strake::Texture2D>("metal", "assets/metal.jpg");

3. Create a material

Strake::Material &metalicMaterial = app.getMaterialManager().addMaterial("metal");
metalicMaterial.addTexture(metalTexture, "textureSampler");
metalicMaterial.setShininess(256.0f);

4. Create a Scene

CS::Scene &scene = app.getSceneManager().addScene("Main Scene");
app.getSceneManager().setCurrentScene("Main Scene");

5. Add a Gameobject with Mesh

Strake::GameObject &object = scene.addGameObject("Cube");
object.getTransform().setLocalPosition(glm::vec3(x, y, z));
object.addComponent<Strake::Cube>();
object.addComponent<Strake::MeshRenderer>(metalicMaterial);

6. Add a Camera

Strake::GameObject &player = scene.addGameObject("Main Camera");
player.addComponent<Strake::Camera>();
Strake::Camera &cam = player.getComponent<Strake::Camera>();
cam.setProjection(45.0f, static_cast<float>(WIN_WIDTH) / static_cast<float>(WIN_HEIGHT), 0.1f, 100.0f);
player.getTransform().setLocalPosition(glm::vec3(x, y, z));
scene.setMainCamera(cam);

7. Create and add a Script

class CharacterController: public Strake::Script
{
    public:
        using Strake::Script::Script;
        void awake() override {
            transform = getParent().getTransform();
        }
        void update() override {
            const Strake::mouse_t &mouse = Strake::EventHandler::getMouse();
            Strake::Transform &transform = this->transform.value();
            if (Strake::EventHandler::isKeyHeld(Strake::Key::W)) {
                transform.translateLocal(glm::vec3(0.0f, 0.0f, m_speed * Strake::Time::getDeltaTime()));
            } else if (Strake::EventHandler::isKeyHeld(Strake::Key::S)) {
                transform.translateLocal(glm::vec3(0.0f, 0.0f, -m_speed * Strake::Time::getDeltaTime()));
            }
            ...
            float yaw = mouse.x;
            float roll = mouse.y;
            transform.setLocalRotation(glm::vec3(-roll, -yaw, 0.0f));
        }
    private:
        std::optional<std::reference_wrapper<Strake::Transform>> transform;
        const float m_speed = 10.0f;
};
player.addComponent<CharacterController>();

8. Run the Application

app.run();

Screenshot


Roadmap

  • Core Systems:

    • Application: Manages application run state
    • Game Loop: Manage calls for pipelines for each frames
    • Window: Handles display management.
    • Event Handler: Centralized system to manage and dispatch events.
    • Config: Manages OpenGL ans Strake engine versions
    • Dispatcher: Used to wrap engine callbacks
    • Shader Programs and Shaders: Customizable shader pipeline to enhance visual effects.
    • Materials and Textures: Supports materials and textures for customizable appearances.
    • Scenes: Manages hierarchical game objects and components.
    • GameObjects: Core structure for building and organizing entities in the engine.
    • Layer: A system that organizes and groups GameObjects for the purpose of managing rendering.
    • Time: Used to manage frame and delta times.
    • Components:
      • Camera: Fully functional component for rendering scenes.
        • vpMatrix: Use of camera view and projection for rendering.
        • Frustrum: Avoid rendering object outside camera frustrum.
      • Transforms: Supports local and global space transformations.
        • Local Tranform: Update objects in local space
        • World Tranform: Update objects in world space
      • Lights: Includes lightnings
        • Directional Light: manage directional lights
          • Lighting: add lighting on scene objects
          • Shadow Map: add shadows of scene objects
        • Point Light: manage directional lights
          • Lighting: add lighting on scene objects
          • Shadow Map: add shadows of scene objects
        • Spot Light: manage directional lights
          • Lighting: add lighting on scene objects
          • Shadow Map: add shadows of scene objects
      • Meshs: Handles 3D meshes, including default primitives (e.g., cubes) and support for OBJ file loading.
        • MeshFilter: Handle Mesh and allow to load object files.
        • Cube: Default prefab for Cube mesh
        • Sphere: Default prefab for Sphere mesh
      • Renderers: Renders objects on Scenes
        • MeshRenderer: Renders meshes with materials and lighting.
        • WireFrameRenderer: Renders only wire frames from meshes or colliders
      • Scripts: Allows users to attach custom scripts to GameObjects as components.
      • Colliders: Used to detect collisions between GameObjects
        • BoxCollider: Boxed colliders (OBB and AABB)
        • SphereCollider: Spherical Collider with center and radius
    • Managers: system that centralizes control of a specific type of resource or component.
      • PhysicsManager: Manages all physics systems.
        • ColliderManager: - Manages Colliders and handles collision detection.
      • RendererManager: Manages Renderers and their rendering operations.
      • LightManager: - Manages Lights and their influence on the scene.
      • SceneManager: - Manages scene transitions and object hierarchies.
      • TextureManager: - Manages Textures and optimizes their usage.
      • MaterialManager: - Manages Materials, shaders, and surface properties.
      • ScriptManager: - Manages and executes scripts for game logic.
      • LayerManager: - Organizes and manages layers.
  • Loop System:

    • Modular architecture with a game loop that includes the following lifecycle methods:
      • awake(): Called when a component is created or initialized.
      • start(): Called before the first frame update.
      • update(): Runs every frame for dynamic behaviors.
      • fixedUpdate(): Runs at a fixed interval for physics or time-sensitive updates.
      • lateUpdate(): Called after all update() calls, ensuring post-update adjustments.
      • render(): Responsible for rendering components such as meshes and lights each frame.

Upcoming Features

  • Basic Physics Engine: Implement a simple physics engine for rigidbody movement and gravity.
  • CollisionBox: Add collision detection with basic bounding boxes for handling physical interactions.
  • Lighting: Expand lighting system to support shadows for each light types such as point lights and spot lights.
  • Enhanced Transform API: Improve the Transform class to provide better support for world space transformations and related methods.

Milestones

  • v0.1: Initial stable version with Component-Based OOP and basic rendering (pre-release version).
    • 0.6.0 (Beta):
      • Add of Culling Masks
      • Add of Layers
      • Add of LayersManager
      • Add of Plane Mesh
      • Add of Capsules Mesh
    • 0.5.0 (Latest Stable):
      • Use of .env in justfile
      • Fixes in OpenGL/GLFW initialisation
      • Add of WireFrameRenderer
      • Add of Sphere Collider
      • Add of Sphere Mesh
      • Use of Ressources folder in Releases
      • Change of compiler (ninja to CMake)
      • Upgrade Mesh Loader
      • Add of Physics Manager
      • Change of Compoment pipeline
      • Change of Script pipeline
    • 0.4.0:
      • Add of Percentage Closer Filtering for shadows
      • Add of Shadow Maps for Directional Light
      • ...
    • 0.3.0
      • Add of internal event Dispatcher
      • ...

License

Distributed under the MIT License. See LICENSE for more information.

Contact

GitHub: RobinLandraud
LinkedIn: robin-landraud

Acknowledgments

  • OpenGL: For enabling cross-platform graphics rendering.
  • GLEW: For handling OpenGL extensions.
  • GLFW: For managing windows and input.
  • GLM: For providing math utilities for 3D transformations.
  • STB Image: For image loading and texture handling.
  • Assimp: For importing and processing various 3D model formats.
  • CMake: For simplifying the build process across platforms.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published