Skip to content

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).

C#
public sealed class HostSurface : ISurface

Inheritance

object ← HostSurface

Implements

ISurface

Constructors

HostSurface(nint, Func<(int Width, int Height)>, Func<float>, Func<bool>)

Creates a surface over a host’s window.

C#
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.

density Func<float>

Reads the pixels per logical unit, as it is now.

minimized Func<bool>

Reads whether the window is minimised; a zero size counts as minimised anyway.

Exceptions

ArgumentNullException

A reader is null.

Properties

IsMinimized

True while the surface has nothing to present to (minimised, zero size).

C#
public bool IsMinimized { get; }

Property Value

bool

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.

C#
public nint NativeWindow { get; }

Property Value

nint

PixelDensity

Pixels per logical unit.

C#
public float PixelDensity { get; }

Property Value

float

PixelSize

Drawable size in pixels.

C#
public (int Width, int Height) PixelSize { get; }

Property Value

(int Width, int Height)

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.

C#
public bool Pump(IEngineEventSink sink)

Parameters

sink IEngineEventSink

Returns

bool

Whether the size changed.

RaiseLost()

Raises Lost: the system destroyed the surface.

C#
public void RaiseLost()

Lost

Raised when a mobile surface is destroyed.

C#
public event Action? Lost

Event Type

Action?

Resized

Raised when PixelSize changes, during the host’s event pump.

C#
public event Action? Resized

Event Type

Action?