Giter Club home page Giter Club logo

elvenengine's Introduction

Elven Engine

Build CodeQL License Codacy Badge

Elven Engine is primarily a 2D/3D game engine that is being developed from scratch.

Features

  • Logging system
  • Event system (non-blocking event queue-based system, described architecture in the article)
  • Custom 3D math library (lia)
  • Renderer Core
    • RHI (Render Hardware Interface): Buffers, Shader, Texture, Render Target
    • Graphics API agnostic Renderer API
    • Modern OpenGL (with Direct State Access) specific Renderer API implementation
    • Shader loading
    • Async texture loading
    • Camera (orthographic, perspective)
    • Render Passes based on Render Targets
  • 2D Renderer
    • Quad rendering
    • Texture rendering
    • Batch rendering (quad and texture)
    • Text Rendering
    • Spritesheet animation
  • 3D Renderer (WIP)
    • Phong/Blinn-Phong Lighting
    • Multiple light casters: spotlight, directional, and point light
    • Mesh-Material system (Static mesh support with one material slot per mesh/submesh for now)
    • Primitives: cube, sphere, plane
    • Async 3D model loading and async material textures loading
    • Render Target
    • MSAA (Multisample anti-alising)
    • Post-processor: blur with custom mask texture building algorithms
    • Uniform buffer
    • Cubemap
    • Shadows
  • ECS (investigated different techniques and my particular architecture in the article)
    • Data-oriented cache-friendly components system architecture
    • In-Engine components: Transform, Sprite, Text, Quad, StaticMesh, Camera, UITransform, AABB, Tag, Sound, PointLight/DirectionalLight/SpotLight.
    • Components serialization
    • Behavior component as the entity brain
    • Optional Systems for usability
  • Scene
    • Interface to work with ECS
    • Scene Graph based on SceneNodeComponent
    • Scene serialization (not all of the components now)
  • Data-driven architecture
    • Load/Save engine settings from/to JSON files
  • Sound engine
    • Support formats: mp3, wav, ogg, flac etc.
    • Add/Play/Pause/Stop/Loop functionality
  • In-engine editor (WIP; based on ImGui)
    • Editor Camera (holding RMB): WASD movement, QE up/down, ZX rotation
    • Scene hierarchy panel
    • Context menu to add/delete entity
    • Properties panel:
      • Components: Transform, Static Mesh with material, Point/Directional/Spot light, UI transform, Text, Sprite
      • "Add component" button
      • Component settings context menu
    • Settings panel: fullscreen, VSync, MSAA
    • Telemetry: performance panel
    • Graphics stats
  • Just cool stuff
    • Fullscreen switch support
    • Orthographic camera controller (OrthographicCameraController), that can be used if needed
    • Fly(FPS-like) 3D camera support (CameraController)
  • Multithreading support
    • async resources loading: texture, mesh
    • Thread pool

Demo

3D rendering

Demo video on youtube (click on image):

2D Rendering

Space Invaders full demo

Invaders_demo.mp4
Space Invades TRON
Ping Pong Quad and texture batch rendering (20000 wizards)

Getting Started

Windows platform only support for now (Linux and MacOS platforms are for future support)

You can clone the repository using git (--recursive is required to fetch all of the submodules):

git clone --recursive https://github.com/kryvytskyidenys/ElvenEngine

Firstly you need to install cmake 3.10+ version (3.21+ for VS 2022 support).

Windows

  1. Configure and build third-party libraries: scripts/setup-vendor.bat
  2. Configure Visual Studio solution for the Engine and Game/Example projects: scripts/configure-vs2022.
  3. Build a solution using one of the following ways:
    • cmake-based script scripts/build.bat (pass Debug/Release as an argument)
    • Visual Studio (ElvenEngine.sln file is placed in the build directory).

CMake build options

You can modify configure file to enable/disable the following cmake options:

  • BUILD_SANDBOX (default ON): Enable Sandbox2D and Sandbox3D projects build
  • BUILD_GAMES (default ON): Enable Games build
  • PROFILE_MODE (default ON): Enable Profiling (PROFILE_MODE preprocessor definition will be added)
  • MODULE_EDITOR_ENABLED (default ON): Enable Editor (MODULE_EDITOR_ENABLED preprocessor definition will be defined)
  • MODULE_3D_ENABLED (default ON): Enable 3D module and Assimp library for 3D model loading (MODULE_3D_ENABLED preprocessor definition will be defined). IMPORTANT: ON - only Sandbox3D project will be configured, OFF - only Sandbox2D and Games projects will be configured.
  • MODULE_SOUND_ENABLED (default ON): Enable sound module (MODULE_SOUND_ENABLED preprocessor definition will be defined)

Third-party libraries

Lib
cmake build system
spdlog header-only logging library
GLFW windows, OpenGL contexts and handle input
glad 2 OpenGL loader
lia my custom math library
ImGui library using for GUI (visual-editor)
stb image image loader
json json lib for serialization and data-driven architecture
irrKlang sound library
fmt formatting library
freetype fonts rendering
assimp 3D model loading

elvenengine's People

Contributors

denyskryvytskyi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

elvenengine's Issues

3D Renderer introduced

  • Fly camera (FPS like)
  • Test 3D scene
  • Phong Lighting
  • Multiple light casters: spotlight, directional, and point light
  • Mesh-Material system
  • Model loading (Assimp)
  • Primitives: cube, sphere, plane

Suggestion: Switch to FetchContent for third-party dependencies

Most (if not all) dependencies for ElvenEngine are available as public repositories, and therefore, can be added to the project using FetchContent CMake module.
This would allow:

  • Get rid of submodules or including the source code for dependencies right away in the ElvenEngine repository
  • Get rid of Windows-specific .bat script
  • Allow to explicitly use a specific version of each dependency by specifying needed tag in the CMakeLists FetchContent command
  • Automatically introduce cross-platform dependencies setup

This suggestion comes intially from my attempt to get ElvenEngine running on MacOS, and in that case, setting up dependencies and specifying their paths in CMake GUI was a bit of unneeded manual work.

Let me know if you have any objections about it.

P.S. - the only exception I guess would be GLAD, but it's pretty easy to include in project, as compared to other fully-featured libraries

Event System introduced

Brief overview

Implemented using Observer pattern without separate classes for Observer/Subject.
There is global EventManager object to transfer our events to receivers.
There is event queue that will be processed at the end on the game loop to avoid blocking events.

You can subsribe/unsubscribe to any event:
Events::Subscribe<WindowCloseEvent>(EVENT_CALLBACK(Application::OnWindowClose));
Events::Unsubscribe<WindowCloseEvent>(EVENT_CALLBACK(Application::OnWindowClose));

Where Applciation::OnWindowClose is the member function with Derived from Event parameter:
bool Application::OnWindowClose(const Events::WindowCloseEvent& e)

Benefits

  • event queue;
  • we don't use dependency injection, that can be turn to very deep and dangerous callstack of OnEvent function calls;
  • simple subscription model using just callback function with particular Event.

Add error checking to OpenGL renderer

Right now most of OpenGL code is called as-is:

glCreateBuffers(1, &m_id);
glNamedBufferStorage(m_id, size, nullptr, GL_DYNAMIC_STORAGE_BIT);

However, in theory, each of these calls may result in some error in the OpenGL state machine, which is not checked right now and may result in very painful debugging.

I would suggest adding a glCheck macro, like there: https://github.com/SFML/SFML/blob/master/src/SFML/Graphics/GLCheck.hpp

which calls glGetError after each call.

Which then will eventually wrap each OpenGL call:

glCheck(glCreateBuffers(1, &m_id);

For start, it may just log the error rightaway to stderr, I guess.

Text Renderer

  • integrate freetype libarary
  • make Text renderer core class with capabilities:
    • LoadFont
    • RenderText

Suggestion: Add 3D physics support using Jolt Physics

Although I am not sure on your exact plans for the project and whether 3D-based games would be the main target for the Elven, I would suggest experimenting adding a 3D Physics engine at some point of time, aside from Box2D for 2D.

And for that I would suggest: Jolt Physics which is open-source C++ physics engine with a ton of features. Initially it was created as in-house engine for Horizon: Forbidden West, which I think is a good marker too.

I have personally created simple simulations with it and enjoyed it a lot, a bit more compared to Bullet or PhysX. Aside from built-in multithreaded support, it also supports double-precision simulations and even determinstic simulations. The documentation is fine and even if something is missing - the maintainer helps you quite fast in the Discussions section.

I understand that this can be a pretty broad and complex feature, but here I am just suggesting one of possible solutions to consider in future. Feel free to share your opinion on that.

2D Renderer introduced

  • Shader Manager (shader files loading)
  • VAO, VBO, EBO API abstraction
  • Shader, Texture abstraction
  • orthographic camera
  • 2D Renderer
    • Quad
    • Sprites
    • Quads and sprites batching
    • Circle and line

3D Renderer development

  • Render Target (Framebuffer)
  • Render Passes based on Render Target with MSAA support
  • Post Processor with blur setting
  • Uniform buffer
  • Cubemap

Editor introduced

The core features for now should be:

  • Components support
  • ImguiGizmo
  • Scene loading/saving

Unit Testing

Add doctest or gest lib for unit testing.
Write tests for:

  • math lib
  • ecs

Audio Engine

  • Integrate irrKlang sound library
  • Support next functionality:
    • Add;
    • Play(optional looped);
    • Pause;
    • Stop;
    • SetVolume.

Job system

Implement thread pool with context dependencies.

Enitity-Component-System introduced

  • Entity is just integer.
  • Component - structs with data and minimal logic (all logic is in systems), but logic like serialization may be exist in components.
  • Generic ComponentPool
  • Generic ComponentSystem
  • For the case when unique Component need extra logic, that isn't covered in the ComponentSystem, then there is a BehaviorsSystem. As I've decided to avoid scripting in my engine, Behavior's system is useful for the case when scripts would be used.

Game scene introduced

Make scene mananer and current active scene, that processes all ECS entitiesm components and systems.

Allocators

  • Stack-based (simple and double-ended)
  • Pool allocator
  • Aligned allocations
  • Single-Frame and Double-Buffered Memory Allocators

Renderer API introduced

  • Shader Manager (shader files loading)
  • Renderer API (VAO, VBO, Shader, Texture abstractions)
  • Camera (orthographic, perspective)
  • DSA OpenGL renderer api implementation

[Renderer] Investigate issue with rendering trasparent/semi-transparent objects with different z-order

Investigate issue with rendering trasparent/semi-transparent objects with different z-order.
Possible solutions:
For 2D Renderer (with disabled depth testing):

  • (PRIMARY OPTION) Layers system
  • Just render in the correct order (sorting) according to Sprite Z position before rendering.

For 3D Renderer:

  • Make next rendering order:
    • Draw all opaque objects first.
    • Sort all the transparent objects.
    • Draw all the transparent objects in sorted order
  • Order independent transparency technique. Good explanation here

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.