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.
public sealed class RaylibPlatform : IPlatform, IPlatformHost, IDisposable, IDisplayControl, IDisplayPacing, IPreciseDelay, IMonotonicClock, IScreenView, IViewCaptureInheritance
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.
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.
public RaylibPlatform(PlatformRequest request)Parameters
request PlatformRequest
Properties
Audio
Plays sound; a silent device when there is no audio.
public IAudioDevice Audio { get; }Property Value
CanBlock
False in a browser, whose page drives the frames; true on desktop.
public bool CanBlock { get; }Property Value
Canvas
The canvas the game draws into, with the 2D batcher’s counts for the last frame.
public DeviceCanvas Canvas { get; }Property Value
Clock
raylib’s timer (the platform is its own clock).
public IMonotonicClock Clock { get; }Property Value
CurrentDisplay
Index in Displays of the display the window is on; -1 when unknown.
public int CurrentDisplay { get; }Property Value
Device
The graphics device the platform draws with (raylib’s OpenGL layer behind the device contract).
public RaylibDevice Device { get; }Property Value
DisplayRate
The monitor’s refresh rate when frames are paced to it (a visible real-time desktop window with VSync); 0 otherwise.
public double DisplayRate { get; }Property Value
Displays
The monitors GLFW reports (none in a browser or on Android); GLFW lists the primary one first.
public IReadOnlyList<DisplayInfo> Displays { get; }Property Value
Graphics
Creates textures.
public IGraphicsDevice Graphics { get; }Property Value
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).
public IInputSource Input { get; }Property Value
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.
public Color Letterbox { get; set; }Property Value
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.
public ISurface MainSurface { get; }Property Value
Now
Seconds since an arbitrary start (the host’s creation); never decreases.
public double Now { get; }Property Value
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.
public static PlatformProfile Profile { get; }Property Value
Suspended
False: a desktop window is never suspended.
public bool Suspended { get; }Property Value
Touch
The touch screen (also the ITouchScreen capability).
public ITouchScreen Touch { get; }Property Value
VSync
Whether frames wait for the display’s refresh.
public bool VSync { get; }Property Value
WindowMode
The window’s current mode.
public WindowMode WindowMode { get; }Property Value
Methods
BeginFrame()
Starts a frame and returns the renderer that draws into the virtual canvas.
public IRenderer BeginFrame()Returns
Delay(double)
Waits with raylib’s timer (a sleep, then a short spin); never offered in a browser, whose page cannot be blocked.
public void Delay(double seconds)Parameters
seconds double
Dispose()
Closes the window and the audio device the platform opened.
public void Dispose()EndFrame()
Finishes the frame and presents it.
public void EndFrame()MoveToDisplay(int)
Moves the window to monitor index (GLFW’s order) on desktop.
public bool MoveToDisplay(int index)Parameters
index int
Returns
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.
public bool PumpEvents(IEngineEventSink sink)Parameters
sink IEngineEventSink
Returns
SaveScreenshot(string)
Writes the canvas as a PNG, opaque (alpha 255 everywhere) as on every backend: the frame is shown on an opaque backdrop.
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.
public bool SetVSync(bool on)Parameters
on bool
Returns
SetWindowMode(WindowMode)
Changes the window’s mode on desktop (raylib’s full screen is exclusive, its borderless mode is Fullscreen).
public bool SetWindowMode(WindowMode mode)Parameters
mode WindowMode
Returns
ToggleFullscreen()
Switches between the window and a borderless full-screen window (exclusive full screen goes back to the window).
public void ToggleFullscreen()TryGetCapability<T>(out T?)
The optional feature of type T this host offers, if it offers one.
public bool TryGetCapability<T>(out T? capability) where T : classParameters
capability T?
Returns
Type Parameters
T