Rendering Overview
Mibo.Raylib uses a deferred, layer-sorted rendering pipeline. Instead of calling raylib draw functions directly, you build a list of commands each frame, and the renderer sorts and executes them in one pass.
The Pipeline
- Your view function builds
IRenderCommand2Dcommands and adds them to aRenderBuffer2D - The renderer sorts commands by
Layer(ascending) - The renderer executes commands in order
- raylib auto-batches GPU draw calls; optional post-processing passes run after
Why Deferred Rendering?
- Separation of concerns: Your view doesn't have to worry about draw order, batching, or GPU state.
- Lighting: Commands can be interleaved with light commands for 2D lighting (see Lighting).
- Post-processing: Screen-space shader passes run after the scene is rendered.
- Predictable ordering: Every command declares its layer explicitly.
2D Rendering
The 2D pipeline is built on Renderer2D<'Model> in the Mibo.Elmish.Graphics2D namespace. See:
- 2D Rendering Overview — What, Why, When
- Buffer & Commands — Building and issuing draw commands
- Lighting & Shadows — 2D lights and soft shadows
- Particles — Batched particle rendering
- Custom Commands —
IRenderCommand2Dand escape hatches - Performance — Writing performant 2D rendering code
- Camera — Cameras and coordinate systems
- Culling — Visibility testing
3D Rendering
The 3D pipeline is built on Renderer3D<'Model> in the Mibo.Elmish.Graphics3D namespace. It uses a pluggable IRenderPipeline3D that interprets Command3D values — draw meshes, billboards, lights, shadows, and post-processing passes.
- 3D Rendering Overview — What, Why, When
- Camera —
Camera3DConfig, split-screen, overlay cameras
Multi-Renderer Compositing
You can combine 2D and 3D renderers in the same program. The 3D scene renders first, then the 2D renderer composites on top (HUD, menus, debug overlays).
Program.mkProgram init update
|> Program.withRenderer (fun () ->
Renderer3D.create pipeline view3D)
|> Program.withRenderer (fun () ->
Renderer2D.create view2D)
The 2D renderer uses Renderer2DConfig.noClear to skip clearing the background, preserving the 3D scene underneath. Per-camera clear control is also available via Camera3DConfig and Camera2DConfig.
See also: Camera for multi-camera patterns.
Mibo.Raylib