Skip to content

PlatformAPI reference

Class RaylibPlatform

Namespace: MicroEngine.Raylib
Assembly: MicroEngine.Raylib.dll
Guide: Backends and platforms

raylib-backed platform. Games draw into a virtual-resolution render texture which is scaled to the window by the largest integer factor that fits (letterboxed), keeping pixel art crisp. A desktop platform (the second implementation of the platform contract beside SDL); browsers run the SDL platform. Its capabilities (TryGetCapability``1): IDisplayControl, IDisplayPacing, ITouchScreen and IPreciseDelay.

C#
public sealed class RaylibPlatform : IPlatform, IPlatformHost, IDisposable, IDisplayControl, IDisplayPacing, IPreciseDelay, IMonotonicClock, IScreenView, IViewCapture

Inheritance

object ← RaylibPlatform

Implements

IPlatform, IPlatformHost, IDisposable, IDisplayControl, IDisplayPacing, IPreciseDelay, IMonotonicClock, IScreenView, IViewCapture

Constructors

RaylibPlatform(GameSettings, DesktopOptions)

Opens the raylib window (and audio device unless the options say otherwise) for settings. Hosts usually go through Profile instead.

C#
public RaylibPlatform(GameSettings settings, DesktopOptions options)

Parameters

settings GameSettings

options DesktopOptions

RaylibPlatform(PlatformRequest)

Opens the raylib window for request: its window options, its audio device or raylib’s own (unless muted or silent), and its extra input sources read with raylib’s.

C#
public RaylibPlatform(PlatformRequest request)

Parameters

request PlatformRequest

Properties

Audio

Plays sound; a silent device when there is no audio.

C#
public IAudioDevice Audio { get; }

Property Value

IAudioDevice

CanBlock

False in a browser, whose page drives the frames; true on desktop.

C#
public bool CanBlock { get; }

Property Value

bool

Canvas

The canvas the game draws into, with the 2D batcher’s counts for the last frame.

C#
public DeviceCanvas Canvas { get; }

Property Value

DeviceCanvas

Clock

raylib’s timer (the platform is its own clock).

C#
public IMonotonicClock Clock { get; }

Property Value

IMonotonicClock

CurrentDisplay

Index in Displays of the display the window is on; -1 when unknown.

C#
public int CurrentDisplay { get; }

Property Value

int

Device

The graphics device the platform draws with (raylib’s OpenGL layer behind the device contract).

C#
public RaylibDevice Device { get; }

Property Value

RaylibDevice

DisplayRate

The monitor’s refresh rate when frames are paced to it (a visible real-time desktop window with VSync); 0 otherwise.

C#
public double DisplayRate { get; }

Property Value

double

Displays

The monitors GLFW reports (none in a browser or on Android); GLFW lists the primary one first.

C#
public IReadOnlyList<DisplayInfo> Displays { get; }

Property Value

IReadOnlyList<DisplayInfo>

Graphics

Creates textures.

C#
public IGraphicsDevice Graphics { get; }

Property Value

IGraphicsDevice

Input

raylib’s keyboard, gamepads and mouse as a polled source, read together with the request’s extra sources. The engine reads raylib’s input as events instead (the IInputBackend capability).

C#
public IInputSource Input { get; }

Property Value

IInputSource

Letterbox

Colour of the window around the frame. Starts as Letterbox; the start screen sets its own colour while it shows. Platforms without a window keep it and ignore it.

C#
public Color Letterbox { get; set; }

Property Value

Color

MainSurface

The window, or the page’s canvas in a browser: its size is the canvas’s as it is now, never the size requested at creation.

C#
public ISurface MainSurface { get; }

Property Value

ISurface

Now

Seconds since an arbitrary start (the host’s creation); never decreases.

C#
public double Now { get; }

Property Value

double

Profile

The raylib platform as a catalog entry. raylib has no iOS platform; its own audio device is not opened when the request supplies another one.

C#
public static PlatformProfile Profile { get; }

Property Value

PlatformProfile

Suspended

False: a desktop window is never suspended.

C#
public bool Suspended { get; }

Property Value

bool

Touch

The touch screen (also the ITouchScreen capability).

C#
public ITouchScreen Touch { get; }

Property Value

ITouchScreen

VSync

Whether frames wait for the display’s refresh.

C#
public bool VSync { get; }

Property Value

bool

WindowMode

The window’s current mode.

C#
public WindowMode WindowMode { get; }

Property Value

WindowMode

Methods

BeginFrame()

Starts a frame and returns the renderer that draws into the virtual canvas.

C#
public IRenderer BeginFrame()

Returns

IRenderer

Delay(double)

Waits with raylib’s timer (a sleep, then a short spin); never offered in a browser, whose page cannot be blocked.

C#
public void Delay(double seconds)

Parameters

seconds double

Dispose()

Closes the window and the audio device the platform opened.

C#
public void Dispose()

EndFrame()

Finishes the frame and presents it.

C#
public void EndFrame()

MoveToDisplay(int)

Moves the window to monitor index (GLFW’s order) on desktop.

C#
public bool MoveToDisplay(int index)

Parameters

index int

Returns

bool

PumpEvents(IEngineEventSink)

Reads what raylib collected at the end of the last frame and delivers the engine’s events: a hidden page’s suspension (browsers), the window’s close request (desktop, once while it stays asked), focus changes and size changes of the window or canvas.

C#
public bool PumpEvents(IEngineEventSink sink)

Parameters

sink IEngineEventSink

Returns

bool

SaveScreenshot(string)

Writes the canvas as a PNG, opaque (alpha 255 everywhere) as on every backend: the frame is shown on an opaque backdrop.

C#
public void SaveScreenshot(string path)

Parameters

path string

SetVSync(bool)

Turns VSync on or off on a visible desktop window that may wait for the display; browsers and Android follow the display.

C#
public bool SetVSync(bool on)

Parameters

on bool

Returns

bool

SetWindowMode(WindowMode)

Changes the window’s mode on desktop (raylib’s full screen is exclusive, its borderless mode is Fullscreen).

C#
public bool SetWindowMode(WindowMode mode)

Parameters

mode WindowMode

Returns

bool

ToggleFullscreen()

Switches between the window and a borderless full-screen window (exclusive full screen goes back to the window).

C#
public void ToggleFullscreen()

TryGetCapability<T>(out T?)

The optional feature of type T this host offers, if it offers one.

C#
public bool TryGetCapability<T>(out T? capability) where T : class

Parameters

capability T?

Returns

bool

Type Parameters

T