mirror of
https://github.com/MadeOfJelly/MushMachine.git
synced 2025-06-20 03:36:37 +02:00
initial import, >900commits predate this
This commit is contained in:
36
docs/framework/common_components/common_components.md
Normal file
36
docs/framework/common_components/common_components.md
Normal file
@ -0,0 +1,36 @@
|
||||
(draft)
|
||||
# Common Components
|
||||
|
||||
This is a collection of commonly used (ECS) `Components`.
|
||||
|
||||
Json serialization is provided for all `Components`.
|
||||
|
||||
## Name
|
||||
|
||||
Contains a string. For debugging.
|
||||
|
||||
It's special, since the entity widget will try to get the Name and display it in `ImGui`.
|
||||
|
||||
## Transform
|
||||
|
||||
Contians Positon, Rotation and Scale.
|
||||
2D and 3D variants.
|
||||
|
||||
Might get replaced with a Unity3D style transform system...
|
||||
|
||||
## Velocity
|
||||
|
||||
Contians Velocity(Position and Rotation).
|
||||
2D and 3D variants.
|
||||
|
||||
## View_Dir
|
||||
|
||||
In almost every Project I had the need for this `Component`, so it's here.
|
||||
2D and 3D variants.
|
||||
|
||||
|
||||
## Color
|
||||
|
||||
I use this a lot. I probably shouldn't.
|
||||
Hase 4 color channels.
|
||||
|
75
docs/framework/engine/engine.md
Normal file
75
docs/framework/engine/engine.md
Normal file
@ -0,0 +1,75 @@
|
||||
# Engine
|
||||
|
||||
The Engine is the heart of the MushMachine framework.
|
||||
It holds the Storage of all [`MM::Service`](services.md)s, update callbacks and is responsible for calling them.
|
||||
|
||||
# Usage
|
||||
|
||||
Provides a forwarding header `<mm/engine_fwd.hpp>`.
|
||||
|
||||
## Construction
|
||||
|
||||
The `MM::Engine` provides a Constructor which accepts a time interval, in which `.fixedUpdate()` is called. The Default is 1/60.
|
||||
|
||||
## Starting
|
||||
```cpp
|
||||
#include <mm/engine.hpp>
|
||||
|
||||
MM::Engine engine;
|
||||
|
||||
// add and enable MM::Services here
|
||||
|
||||
engine.run();
|
||||
```
|
||||
|
||||
The `MM::Engine` disables all enabled `MM::Service`s in reverse order on destruction or `.cleanup()`.
|
||||
|
||||
## Managing [`MM::Service`](services.md)s
|
||||
|
||||
### Adding a `MM::Service`
|
||||
|
||||
Before a `MM::Service` can be enabled, it needs to be added to the engine.
|
||||
`.addService<MyService>(my, args)` adds a service and forwards args to its constructor.
|
||||
There is currently no way of removing a `MM::Service`.
|
||||
|
||||
### Getting a `MM::Service`
|
||||
|
||||
You can get a Pointer via `.tryService<MyService>()` and an asserted reference via `.getService<MyService>()`. If the `MM::Service` does not exist, it returns a `nullptr. "Enablement Status" makes no difference.
|
||||
|
||||
### Provide a `MM::Service` (Interfaces)
|
||||
|
||||
`.provide<MyServiceInterface, MyService>()` registers `MyService` also as `MyServiceInterface`, so `MyService` becomes getable via `MyServiceInterface`. `MyService` needs to be added beforehand.
|
||||
|
||||
### Enabling/Disabling a `MM::Service`
|
||||
|
||||
`MM::Service`s can be Enabled/Disabled during `.run()` as a deferred operation (see `.addFixedDefer(...)`)
|
||||
|
||||
* `.enableService<MyService>()` calles the `.enable()` of `MyService`. Also returns `true` on success.
|
||||
* `.disableService<MyService>()` calles the `.disable()` of `MyService`.
|
||||
There are also overloads, which accept a type id.
|
||||
|
||||
## Update / FixedUpdate
|
||||
|
||||
FixedUpdates are called with update interval (default 1/60, set on engine ctr), while Updates are called "as fast as possible". Since Rendering is usually done using Update and blocks on VSync, this is as fast as VSync.
|
||||
|
||||
Since fixedUpdate callbacks don't get a time delta, querying `.getFixedDeltaTime()` is mandatory.
|
||||
|
||||
### adding Update callbacks
|
||||
|
||||
`.addUpdate(MyFn)` and `.addFixedUpdate(MyFn)` add `MyFn` as an update and fixedUpdate respectively and return a `FunctionDataHandle`(ptr) to remove them again.
|
||||
|
||||
### removing Update callbacks
|
||||
|
||||
`.removeUpdate(myHandle)` and `.removeFixedUpdate(myHandle)` remove those callbacks again.
|
||||
|
||||
### `.run()`
|
||||
|
||||
`.run()` is a blocking call, which calles `.fixedUpdate()` in a fixed interval with an accumulator. Inbetween those `.fixedUpdate()`s, `.update()` gets called "as fast as possible".
|
||||
|
||||
You don't need to call `.run()`, instead you can call `.update()` and `.fixedUpdate()` yourself.
|
||||
|
||||
### `.stop()`
|
||||
|
||||
Stops the Engine...
|
||||
Actually quits the loop in `.run()`.
|
||||
|
23
docs/framework/engine/interfaces.md
Normal file
23
docs/framework/engine/interfaces.md
Normal file
@ -0,0 +1,23 @@
|
||||
# Default Shipped Interfaces
|
||||
|
||||
### Index
|
||||
|
||||
* `MM::Services::SceneServiceInterface`
|
||||
|
||||
|
||||
## SceneServiceInterface
|
||||
|
||||
Not very stable. But I use it all over the place.
|
||||
|
||||
It uses [`EnTT`](https://github.com/skypjack/entt).
|
||||
|
||||
### interface
|
||||
|
||||
Use `.getScene()` to get current `MM::Scene`.
|
||||
|
||||
Use `.changeScene(newScene)` to queue `.changeSceneNow(newScene)`.
|
||||
|
||||
Use `.changeSceneNow(newScene)` to change currently held `MM::Scene`.
|
||||
|
||||
Use `.addSystemToScene(fn)` to add a `MM::System` to the `MM::Scene`.
|
||||
|
18
docs/framework/engine/services.md
Normal file
18
docs/framework/engine/services.md
Normal file
@ -0,0 +1,18 @@
|
||||
# Services
|
||||
|
||||
`MM::Service`s are the Components that get added to the `MM::Engine`.
|
||||
|
||||
They need to extend `MM::Service` (included in `<mm/engine.hpp>`) and implement the following Interface:
|
||||
|
||||
* Destructor (since it is virtual)
|
||||
* `bool enable(MM::Engine& engine)`
|
||||
* `void disable(MM::Engine& engine)`
|
||||
|
||||
and optionally
|
||||
|
||||
* `const char* name(void)`
|
||||
|
||||
Not implementing `name()` does not impact functionality, but it is not good practise.
|
||||
|
||||
Update and FixedUpdate callbacks should only be added in `enable()` and should be removed in `disable()`.
|
||||
|
7
docs/framework/filesystem/filesystem.md
Normal file
7
docs/framework/filesystem/filesystem.md
Normal file
@ -0,0 +1,7 @@
|
||||
(draft)
|
||||
# Filesystem
|
||||
|
||||
Provides a Virtual Filesystem. Implemented using [PhysFS](https://icculus.org/physfs/).
|
||||
|
||||
# Usage
|
||||
|
33
docs/framework/logger/logger.md
Normal file
33
docs/framework/logger/logger.md
Normal file
@ -0,0 +1,33 @@
|
||||
# Logger
|
||||
|
||||
The Logger is the [`spdlog`](https://github.com/gabime/spdlog) logging library, with some extras. Like a `Sink` for [`Tracy`](https://github.com/wolfpld/tracy) the Profiler.
|
||||
|
||||
# Usage
|
||||
|
||||
Each "Section" is ment to have its own "Logger".
|
||||
|
||||
To Initialize a section logger with its `sink`s, do `MM::Logger::initSectionLogger("MySection");`.
|
||||
Can be placed in the `.enable()` or even the Constructor of your `Service`s.
|
||||
|
||||
```cpp
|
||||
#include <mm/logger.hpp> // include logger
|
||||
|
||||
// here are the macros
|
||||
#define LOG_CRIT(...) __LOG_CRIT( "MySection", __VA_ARGS__)
|
||||
#define LOG_ERROR(...) __LOG_ERROR("MySection", __VA_ARGS__)
|
||||
#define LOG_WARN(...) __LOG_WARN( "MySection", __VA_ARGS__)
|
||||
#define LOG_INFO(...) __LOG_INFO( "MySection", __VA_ARGS__)
|
||||
#define LOG_DEBUG(...) __LOG_DEBUG("MySection", __VA_ARGS__)
|
||||
#define LOG_TRACE(...) __LOG_TRACE("MySection", __VA_ARGS__)
|
||||
|
||||
// code goes here ......
|
||||
|
||||
// only if in header
|
||||
//#undef LOG_CRIT
|
||||
//#undef LOG_ERROR
|
||||
//#undef LOG_WARN
|
||||
//#undef LOG_INFO
|
||||
//#undef LOG_DEBUG
|
||||
//#undef LOG_TRACE
|
||||
```
|
||||
|
5
docs/framework/opengl_primitives/opengl_primitives.md
Normal file
5
docs/framework/opengl_primitives/opengl_primitives.md
Normal file
@ -0,0 +1,5 @@
|
||||
(draft)
|
||||
## OpenGL Primitives
|
||||
|
||||
Mostly Classes wrapping the OpenGL library.
|
||||
|
7
docs/framework/opengl_renderer/opengl_renderer.md
Normal file
7
docs/framework/opengl_renderer/opengl_renderer.md
Normal file
@ -0,0 +1,7 @@
|
||||
(draft)
|
||||
# OpenGL Renderer
|
||||
|
||||
This is a "Renderer" implementation. It hosts a `OpenGL::RenderTask` list, which get executed in order.
|
||||
|
||||
For `OpenGL::RenderTask`s see the [render_tasks folder](render_tasks/).
|
||||
|
6
docs/framework/opengl_renderer/render_tasks/blit_fb.md
Normal file
6
docs/framework/opengl_renderer/render_tasks/blit_fb.md
Normal file
@ -0,0 +1,6 @@
|
||||
# `OpenGL::RenderTask` Blit FB
|
||||
|
||||
This `RenderTask` Blits(copys) the contents of one `FrameBuffer` to another.
|
||||
|
||||
There are options available for source and destination rectangle, color flags and filter mode.
|
||||
|
6
docs/framework/opengl_renderer/render_tasks/clear.md
Normal file
6
docs/framework/opengl_renderer/render_tasks/clear.md
Normal file
@ -0,0 +1,6 @@
|
||||
# `OpenGL::RenderTask` Clear
|
||||
|
||||
This `RenderTask` calles glClear().
|
||||
|
||||
There are options available for clear color and color mask.
|
||||
|
4
docs/framework/opengl_renderer/render_tasks/imgui.md
Normal file
4
docs/framework/opengl_renderer/render_tasks/imgui.md
Normal file
@ -0,0 +1,4 @@
|
||||
# `OpenGL::RenderTask` ImGuiRT
|
||||
|
||||
This `RenderTask` renders the ImGui render data.
|
||||
|
7
docs/framework/resource_manager/resource_manager.md
Normal file
7
docs/framework/resource_manager/resource_manager.md
Normal file
@ -0,0 +1,7 @@
|
||||
(draft)
|
||||
# Resource Manager
|
||||
|
||||
This is nothing more than a glorified Singelton and will be replace in the future.
|
||||
|
||||
Based on https://github.com/skypjack/entt/blob/master/src/entt/resource/cache.hpp.
|
||||
|
31
docs/framework/screen_director/screen_director.md
Normal file
31
docs/framework/screen_director/screen_director.md
Normal file
@ -0,0 +1,31 @@
|
||||
# Screen Director
|
||||
|
||||
Orchistrates `Screen`s.
|
||||
|
||||
The `Screen Director` lets you define "States"(`Screen`s) which activate/deactivate `MM::Service`s on Entering and Leaving the `Screen`.
|
||||
|
||||
# Usage
|
||||
|
||||
The current implementation is very open and does not really use encapsulation ...
|
||||
|
||||
## Adding `Screen`s
|
||||
|
||||
Due to the open nature of this implementation, one does access members directly:
|
||||
```
|
||||
auto& my_screen = screen_director.screens["my_screen"];
|
||||
|
||||
// filling in start_disable, start_enable, start_provide, end_disable and end_enable
|
||||
// and optionally start_fn and end_fn which are called upon entering and leaving the screen.
|
||||
my_screen.start_enable.push_back(engine.type<MyService>());
|
||||
// [...]
|
||||
```
|
||||
|
||||
## Changing to a Screen
|
||||
|
||||
Changing to a `Screen` can either be done on call with `.changeScreenTo(engine, "my_screen_id")` or qued via `.queueChangeScreenTo("my_screen")`. The former should only be used when the `Engine` is not running or in a `fixedDeferUpdate`.
|
||||
|
||||
## Service Enablement
|
||||
|
||||
Enabling the ScreenDirector causes a queued `Screen` to be started.
|
||||
|
||||
|
9
docs/framework/sdl_service/sdl_service.md
Normal file
9
docs/framework/sdl_service/sdl_service.md
Normal file
@ -0,0 +1,9 @@
|
||||
(draft)
|
||||
## SDL Service
|
||||
|
||||
This is a `Service` which manages Windows, OpenGL Contexts and Events.
|
||||
|
||||
The current implementation limits it to one Window and OpenGL Context.
|
||||
|
||||
Support for Vulkan is planned.
|
||||
|
5
docs/framework/simple_scene/simple_scene.md
Normal file
5
docs/framework/simple_scene/simple_scene.md
Normal file
@ -0,0 +1,5 @@
|
||||
(draft)
|
||||
# Simple Scene
|
||||
|
||||
This is a simple `MM::SceneServiceInterface` implementation.
|
||||
|
Reference in New Issue
Block a user