Skip to content
This repository was archived by the owner on Sep 8, 2023. It is now read-only.

Framework

Noel Berry edited this page Feb 28, 2020 · 5 revisions

~~ Work in Progress and missing links ~~

Table of Contents

The App class is the central component of the Framework. It handles all the Modules as well as Startup, Shutdown, and Update events.

The only parts you generally need to worry about are adding and getting Modules, and starting the Application:

// Registers a new Module of the given ModuleType
App.Modules.Register<ModuleType>();

// Starts running the Application
App.Start("Title", 1280, 720);

To get Modules that have been registered, simply call App.Modules.Get<ModuleType>, or use one of the existing getters for core modules:

var system = App.System; // shortcut for App.Modules.Get<System>();
var graphics = App.Graphics; // shortcut for App.Modules.Get<Graphics>();
var input = App.Input; // shortcut for App.Modules.Get<System>().Input;
var audio = App.Audio; // shortcut for App.Modules.Get<Audio>();

Modules plug into the App and have event callbacks. You can inherit from Module.cs to implement your own, which can then be registered to the App through App.Modules.Register.

There are a set of special Modules call AppModule which receive a few extra events (ApplicationStarted and FirstWindowCreated).

A simple implementation that logs output during the Update event could look like this:

public class MyModule : Module
{
    protected override void Update() 
    {
         Console.WriteLine(Time.DeltaTime);
    }
}

The System Module handles all Windowing and Input. The default System implementation can be accessed through App.System.

You can instantiate a new Window at any time from the Main thread, if System.SupportsMultipleWindows is true.

By default there is always one Window created at Startup, and it can be accessed through App.Window. Further Windows can be accessed through System.Windows, once they're created.

var window = new Window("Title", 1920, 1080);
window.OnRender += MyRenderMethod;
window.Fullscreen = true;

Note that unlike FrameBuffers, Windows can only be drawn to during their OnRender callback.

Monitors represent Desktop Monitors. They cannot be created or added, but can be accessed through System.Monitors

The contents of the core Graphics Module, used for drawing things to the screen using the GPU. Not all of the classes are listed here, but the important ones for rendering are.

Class Details
Graphics The Graphics Module
Texture A 2D Texture used for drawing. This can be loaded from a file and written to, or used within a Frame Buffer
Mesh A Mesh which can be provided Vertices, Indices, and Instanced data. A Mesh is required in order to submit data to the Graphics for Rendering
FrameBuffer A 2D Frame Buffer to draw to. It can hold multiple Texture's within it for Color data, Depth buffers, etc
Shader A Shader used in rendering
Material A Material used in rendering. It references a Shader and can set Uniform values (Parameters)
VertexFormat A VertexFormat used when submitting Vertices to a Mesh. An example of this can be seen in the Batch2D class
RenderPass A struct that details a single draw call, and which is passed to Graphics.Render in order to draw things

The API implements several classes to handle 2D Drawing:

Class Details
SpriteFont Used to render Bitmap Fonts. This can be created from a Font class, but it also has constructors to create fonts on the fly from font files.
Batch2D A 2D Sprite Batcher, used for drawing shapes, images, and text.
Atlas A simple Atlas implementation that uses Subtextures
Subtexture An object which points to a specific rectangle within a Texture

There are 2 Font classes, which use STB_TrueType to load Fonts from File or Stream:

Class Details
Font Loads Font Files and parses their data
FontSize Takes a given Font and is able to render each Character at a given size

General utility functions for loading and parsing Images and image-related data:

Class Details
Aseprite Parses Aseprite Images
Bitmap An Image represented in an array of Color[] data, not held on the GPU
Images A static class for loading various Image formats
PNG A PNG Parser
Packer A Texture Packer. This can be provided source images and it will pack them into single Textures

General utility functions for loading and parsing 3D Models

Class Details
WavefrontObj Parses Wavefront .obj files

Implemented but not documented here yet.

Input State

Implemented but not documented here yet.

Virtual Input

Implemented but not documented here yet.

Audio

Not yet implemented

Class Details
Calc Used for various Math and helper methods
Ease Easing methods
Log Logging System that can output errors if the Application fails
Mask Generic bit mask helper struct
Rand Random Number utilities
Time Static Time utilities, used for tracking Delta Time, Application up-time, etc.

Clone this wiki locally