PlatformAPI reference
Class HostSurface
Namespace: MicroEngine.Platform
Assembly: MicroEngine.Platform.dll
Guide: The platform host
An ISurface for hosts: it reads its size, density and state from the host’s window when asked, and Pump reports a size change the way the platform contract requires (Resized and the sink’s Resized, once per change).
public sealed class HostSurface : ISurfaceInheritance
Implements
Constructors
HostSurface(nint, Func<(int Width, int Height)>, Func<float>, Func<bool>)
Creates a surface over a host’s window.
public HostSurface(nint nativeWindow, Func<(int Width, int Height)> pixelSize, Func<float> density, Func<bool> minimized)Parameters
nativeWindow nint
The opaque native window, or 0 when there is none.
pixelSize Func<(int Width, int Height)>
Reads the drawable size in pixels, as it is now.
Reads the pixels per logical unit, as it is now.
Reads whether the window is minimised; a zero size counts as minimised anyway.
Exceptions
A reader is null.
Properties
IsMinimized
True while the surface has nothing to present to (minimised, zero size).
public bool IsMinimized { get; }Property Value
NativeWindow
Opaque native window (an SDL_Window* for SDL hosts, raylib’s window handle for raylib); 0 when there is none (headless). Only backends read it.
public nint NativeWindow { get; }Property Value
PixelDensity
Pixels per logical unit.
public float PixelDensity { get; }Property Value
PixelSize
Drawable size in pixels.
public (int Width, int Height) PixelSize { get; }Property Value
Methods
Pump(IEngineEventSink)
Compares the size with the one last reported; when it changed, raises Resized and delivers
Resized to sink. Hosts call it from their event pump.
public bool Pump(IEngineEventSink sink)Parameters
sink IEngineEventSink
Returns
Whether the size changed.
RaiseLost()
Raises Lost: the system destroyed the surface.
public void RaiseLost()Lost
Raised when a mobile surface is destroyed.
public event Action? LostEvent Type
Resized
Raised when PixelSize changes, during the host’s event pump.
public event Action? Resized