Git Product home page Git Product logo

opfor-engine's Introduction

3D Engine

Game Engine in C++ and OpenGL.

Notable Features: - C++17 - OpenGL - PBR Renderering - Lua Scripting Support

Editor Screenshot 1

Editor Screenshot 2

Editor Screenshot 3

Examples

Creating a Component

#include "ecs/Component.h"

struct MyComponent : ecs::ComponentBase
{
  // Data fields ...
  int Health;
  float Speed;
  // ...
};

Creating an Entity

auto &engine = Engine::Instance();

/// Create an IEntity with components MeshComponent and TransformComponent and returns a non-owning pointer
auto object = engine.CreateEntity<MeshComponent, TransformComponent>();

Modifying an Entity

/// IEntity::GetAll returns a tuple with the components registered in the IEntity
auto [ mesh, transform ] = object->GetAll();

transform.position = glm::vec3(42.0f, 0.0f, 0.0f);
mesh->Set(transform);
// or (without type deduction)
mesh->Set<TransformComponent>(transform);

Creating a System

#include "ecs/System.hpp"

class MySystem : ecs::ComponentSystem
{
public:
  void OnUpdate(float) override
  {
    auto entities = GetEntities<MeshComponent, TransformComponent>();
    // Do your computations here...
  }
};

Instanciating a System

engine.CreateSystem<MySystem>();

Lua Scripting

This engine supports Lua scripting through a LuaScriptComponent you can attach on any entity

#include "components/LuaScriptComponent.hpp"

// [...]

auto myEntity = engine.CreateEntity<LuaScriptComponent>();

auto &luaScript = myEntity->Get<LuaScriptComponent>();
	luaScript.Runtime.Load("scripts/myScript.lua");
-- File: script/myScript.lua

-- This function is called on each frame
function onUpdate(deltaTime)
	io.write("Hello World!\n")
end

Build

Linux, macOS

meson build && ninja -C build

Dependencies

Common

glew
glfw3
FreeType
OpenGL
OpenAL

Linux

x11
xi
xrandr

(Light Bulb icon)[https://icons8.com/icons/set/blunt-bulb] icon by (Icons8)[https://icons8.com]

opfor-engine's People

Contributors

oyagci avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

opfor-engine's Issues

Compilation: Forward declaration mismatches declaration

IWindow is forward declared as a struct in multiple places instead of a class

8>D:\a\opfor-engine\opfor-engine\opfor\src\opfor\renderer\Context.hpp(7,15): warning C4099: 'opfor::IWindow': type name first seen using 'class' now seen using 'struct' (compiling source file src\opfor\renderer\SkyboxRenderer.cpp) [D:\a\opfor-engine\opfor-engine\opfor\opfor.vcxproj]
       D:\a\opfor-engine\opfor-engine\opfor\src\opfor\core\Window.hpp(16): message : see declaration of 'opfor::IWindow' (compiling source file src\opfor\renderer\SkyboxRenderer.cpp) [D:\a\opfor-engine\opfor-engine\opfor\opfor.vcxproj]```

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.