1. Application Structure & Game Loop
At the heart of every GFX-Next application is the Game base class.
A typical project derives from it:
public class MyGame : Game
{
public override void LoadContent(AssetManager assets) { }
public override void Initialize(IRenderDevice renderer) { }
public override void Update(float deltaTime) { }
public override void Render() { }
}
Lifecycle Overview
The application lifecycle is explicitly split into stages:
- LoadContent
Load and register assets using the AssetManager. - Initialize
Upload GPU resources and initialize runtime systems. - Update
Advance game logic, physics, animations, and input. - Render
Perform all rendering steps in a fully explicit order.
This separation ensures that:
- Asset loading is deterministic
- GPU resource ownership is explicit
- Editor and runtime can share the same core logic
2. Asset Management & Resource Lifetime
All assets in GFX-Next are managed through the AssetManager.
_lionModel = assets.Load<StaticMeshModel>("Ressources/Lion/Lion.gltf");
_defaultMaterial = assets.Add(new SGMaterial("DefaultMaterial", color));
_cubeMesh = assets.Add("CubeMesh", Cube.GetMesh(_defaultMaterial));
Key Principles
- Assets are registered explicitly
- Ownership lies with the user, not the engine
- CPU and GPU resources are handled separately
- Assets can be shared across multiple game elements
This design avoids implicit loading, background magic, or hidden caches.
3. Meshes, Primitives & Geometry
GFX-Next distinguishes between geometry and instances.
Meshes
A Mesh represents raw geometry data:
- vertices
- indices
- optional default material
Meshes are assets and can be shared freely.
_cubeMesh = assets.Add("CubeMesh", Cube.GetMesh(_defaultMaterial));
Primitives
A Primitive is a renderable scene element that references a mesh.
var ground = new Primitive("Ground", _cubeMesh);
var debugCube = new Primitive("DebugCube", _cubeMesh, _debugMaterial);
Key points:
- Multiple primitives can reference the same mesh
- Materials can be overridden per instance
- No geometry duplication occurs
This enables efficient instancing and clean separation between data and usage.
4. Scenes, GameElements & Hierarchies
All world objects live inside a Scene.
this.Scene = new Scene3D();
Scene.AddGameElement(ground);
GameElements
A GameElement is the base unit of a scene:
- has a transform
- can have children
- can contain behaviors
Player = new Empty("Player", position);
Player.AddChild(new StaticModel("ViewModel", _viewModelMesh));
This allows hierarchical transformations and clean scene graphs.
5. Components & Behaviors
Behavior logic is attached via behaviors, not inheritance.
var rigidbody = Player.AddBehavior(new CapsuleRigidBody(PhysicsHandler));
var controller = Player.AddBehavior(new FPSController());
Benefits:
- Clear separation of data and logic
- Reusable behavior components
- No deep inheritance chains
This approach keeps game elements lightweight and flexible.
6. Physics Integration
Physics is integrated explicitly through a PhysicsHandler.
this.PhysicsHandler = new PhysicsHandler3D(gravity);
Scene.PhysicsHandler = this.PhysicsHandler;
Colliders and rigid bodies are added via behaviors:
var collider = ground.AddBehavior(new BoxCollider(PhysicsHandler));
collider.CreateCollider(0);
Debug visualization is opt-in and configurable.
7. Rendering Pipeline & Post Processing
Rendering in GFX-Next is fully explicit.
Scene.RenderShadowMaps(Viewport, RenderDevice, Camera);
Scene.Render(Viewport, RenderDevice, Camera);
Post-processing is handled through a stack:
_postProcessStack.Apply(RenderDevice, renderTarget.TextureId);
RenderDevice.DrawRenderTarget(_postProcessStack.RenderTarget, GLRenderer.Backbuffer);
There is no implicit “final pass” — the user controls:
- when render targets are drawn
- how UI and scene rendering are composed
- which effects are applied
8. UI & HUD Rendering
2D UI rendering is handled separately using Canvas2D.
HUD.Render(Viewport, RenderDevice);
RenderDevice.DrawRenderTarget(HUD.RenderTarget, GLRenderer.Backbuffer);
This allows:
- clean separation between 3D and 2D rendering
- flexible composition
- editor overlays and debug tools
Summary
The core concepts of GFX-Next revolve around:
- Explicit control instead of hidden behavior
- Clear ownership of assets and resources
- Separation of data, logic, and rendering
- A shared core for runtime and editor usage
Understanding these principles makes the rest of the engine predictable, flexible, and easy to extend.