Gondwana Game Engine Development (master) - 2.6.1
Gondwana is a cross-platform 2.5D game and rendering engine written in C#/.NET 8. It provides fine-grained control over rendering, timing, and scene composition, with built-in support for parallax, z-ordering, pixel overhang, collision detection, and particle effects. Gondwana targets desktop and web platforms using SkiaSharp for graphics and pluggable audio backends for desktop and browser targets.
Loading...
Searching...
No Matches
Gondwana.Rendering.RenderSurfaceHostBase Class Referenceabstract

Represents a base class for hosting a render surface, providing functionality for managing rendering operations, backbuffer access, and integration with platform-specific adapters. More...

Inheritance diagram for Gondwana.Rendering.RenderSurfaceHostBase:
Gondwana.Rendering.RenderSurfaceHost< TBackbuffer >

Public Member Functions

SKImage? GlRenderAndSnapshot ()
 Renders the current scene frame on the active GL/WebGL thread and returns a snapshot of the GPU backbuffer ready to be drawn to the platform surface.
bool GlRenderToCanvas (SKCanvas destinationCanvas)
 Renders the current scene frame and draws the GPU backbuffer surface directly to another GPU canvas. Linear scaling uses a scoped GPU texture snapshot because direct surface drawing does not support sampling options. No CPU pixel transfer is performed.
bool GlDrawCurrentFrameToCanvas (SKCanvas destinationCanvas)
 Draws the existing GPU backbuffer surface directly to another GPU canvas without rendering a new scene frame. Linear scaling uses a scoped GPU texture snapshot without CPU pixel transfer.
SKImage? GlSnapshotCurrentFrame ()
 Returns a snapshot of the current GPU backbuffer without rendering a new scene frame.
void Dispose ()
 Releases all resources used by this RenderSurfaceHostBase instance.

Protected Member Functions

 RenderSurfaceHostBase ()
 Initializes a new instance of the RenderSurfaceHostBase class and registers it with the RenderSurfaceHostRegistry.
virtual void Dispose (bool disposing)
 Releases resources used by this RenderSurfaceHostBase instance and unregisters it from the RenderSurfaceHostRegistry.

Properties

Diagnostics.? TelemetrySource Telemetry [get, set]
 Neutral session-local measurements for this host; null when source capacity is exhausted or the shared collector is disposed.
BackbufferBase Backbuffer [get]
 Gets the in-memory BackbufferBase associated with the current rendering context.
float PresentationScale [get]
 Actual scale used to fit this Backbuffer into its current adapter.
Scene Scene [get]
 Gets the source Scenes.Scene used for rendering operations.
RenderSurfaceAdapterBase? RenderSurfaceAdapter [get]
 Gets the platform-specific RenderSurfaceAdapterBase responsible for rendering the image from the Backbuffer.
ViewManager ViewManager [get]
 Gets the view manager that controls camera positions, viewports, and multi-view rendering for this render surface host.
EffectsManager Effects [get]
 Gets the manager that owns presentation effects for this render surface.

Events

Action< GpuRenderSynchronizationDiagnostics >? GpuRenderSynchronizationDiagnosticsCalculated
 Occurs after a GPU render/snapshot call when a subscriber requests timing for the shared render-state synchronization gate.

Detailed Description

Represents a base class for hosting a render surface, providing functionality for managing rendering operations, backbuffer access, and integration with platform-specific adapters.

Definition at line 14 of file RenderSurfaceHostBase.cs.

Constructor & Destructor Documentation

◆ RenderSurfaceHostBase()

Gondwana.Rendering.RenderSurfaceHostBase.RenderSurfaceHostBase ( )
protected

Initializes a new instance of the RenderSurfaceHostBase class and registers it with the RenderSurfaceHostRegistry.

Registration ensures the render surface host is tracked for lifecycle management and can be enumerated by other system components.

Definition at line 30 of file RenderSurfaceHostBase.cs.

Member Function Documentation

◆ Dispose() [1/2]

void Gondwana.Rendering.RenderSurfaceHostBase.Dispose ( )

Releases all resources used by this RenderSurfaceHostBase instance.

This method unregisters the render surface host from the RenderSurfaceHostRegistry and releases any managed resources. Derived classes should override Dispose(bool) to release additional resources specific to their implementation.

After calling Dispose(), this instance should not be used. Calling Dispose() multiple times is safe and has no additional effect.

Definition at line 420 of file RenderSurfaceHostBase.cs.

◆ Dispose() [2/2]

virtual void Gondwana.Rendering.RenderSurfaceHostBase.Dispose ( bool disposing)
protectedvirtual

Releases resources used by this RenderSurfaceHostBase instance and unregisters it from the RenderSurfaceHostRegistry.

Parameters
disposingtrue to release both managed and unmanaged resources; false to release only unmanaged resources (called from finalizer).

This method always unregisters the instance from the registry. Derived classes should override this method to release additional resources but must call the base implementation to ensure proper unregistration.

Reimplemented in Gondwana.Rendering.RenderSurfaceHost< TBackbuffer >.

Definition at line 440 of file RenderSurfaceHostBase.cs.

◆ GlDrawCurrentFrameToCanvas()

bool Gondwana.Rendering.RenderSurfaceHostBase.GlDrawCurrentFrameToCanvas ( SKCanvas destinationCanvas)

Draws the existing GPU backbuffer surface directly to another GPU canvas without rendering a new scene frame. Linear scaling uses a scoped GPU texture snapshot without CPU pixel transfer.

Call only from the active GPU paint callback while both surfaces share the current GRContext. This is intended for presentation loops that run more frequently than Gondwana's configured foreground/render cadence.

Parameters
destinationCanvasThe active platform GPU canvas.
Returns
true when the current GPU surface was drawn; otherwise false.

Definition at line 327 of file RenderSurfaceHostBase.cs.

◆ GlRenderAndSnapshot()

SKImage? Gondwana.Rendering.RenderSurfaceHostBase.GlRenderAndSnapshot ( )

Renders the current scene frame on the active GL/WebGL thread and returns a snapshot of the GPU backbuffer ready to be drawn to the platform surface.

This method is intended to be called from the platform GPU paint callback while its GRContext is current. It is the GPU equivalent of the engine loop's RenderToBackbuffer + PresentBackbufferToAdapter pair; rendering and snapshot creation happen synchronously on the GPU-owning thread, with no CPU pixel transfer.

The returned SKImage is a lightweight GPU-backed view of the backbuffer texture. The caller must dispose it after drawing (typically with a using statement), and must do so within the same GPU paint callback to avoid aliasing with the next frame's rendering pass.

Returns null when BackbufferBase.IsGlThreadRendered is false (i.e. this is not a GPU-rendered surface).

Returns
A GPU-backed SKImage snapshot of the rendered frame, or null if this surface does not use GL-thread rendering.

Definition at line 114 of file RenderSurfaceHostBase.cs.

◆ GlRenderToCanvas()

bool Gondwana.Rendering.RenderSurfaceHostBase.GlRenderToCanvas ( SKCanvas destinationCanvas)

Renders the current scene frame and draws the GPU backbuffer surface directly to another GPU canvas. Linear scaling uses a scoped GPU texture snapshot because direct surface drawing does not support sampling options. No CPU pixel transfer is performed.

Call only from the active GPU paint callback while both surfaces share the current GRContext. The destination is drawn at the origin using the destination canvas's current transform, followed by the adapter's aspect-preserving presentation transform.

Parameters
destinationCanvasThe active platform GPU canvas.
Returns
true when a GPU surface was rendered and drawn; otherwise false.

Definition at line 278 of file RenderSurfaceHostBase.cs.

◆ GlSnapshotCurrentFrame()

SKImage? Gondwana.Rendering.RenderSurfaceHostBase.GlSnapshotCurrentFrame ( )

Returns a snapshot of the current GPU backbuffer without rendering a new scene frame.

This is intended for GPU presentation loops that run more frequently than Gondwana's configured foreground/render cadence. It allows the platform surface to re-blit the most recently rendered backbuffer while preserving Gondwana.Configuration.EngineConfiguration.TargetFPS.

Call only from the active GPU paint callback while the backbuffer's GRContext is current. The returned SKImage must be disposed before that callback returns.

Returns
A GPU-backed snapshot of the current backbuffer, or null when the surface does not use GL-thread rendering.

Definition at line 385 of file RenderSurfaceHostBase.cs.

Property Documentation

◆ Backbuffer

BackbufferBase Gondwana.Rendering.RenderSurfaceHostBase.Backbuffer
getabstract

Gets the in-memory BackbufferBase associated with the current rendering context.

Definition at line 45 of file RenderSurfaceHostBase.cs.

◆ Effects

EffectsManager Gondwana.Rendering.RenderSurfaceHostBase.Effects
get

Gets the manager that owns presentation effects for this render surface.

Definition at line 80 of file RenderSurfaceHostBase.cs.

◆ PresentationScale

float Gondwana.Rendering.RenderSurfaceHostBase.PresentationScale
get

Actual scale used to fit this Backbuffer into its current adapter.

Definition at line 48 of file RenderSurfaceHostBase.cs.

◆ RenderSurfaceAdapter

RenderSurfaceAdapterBase? Gondwana.Rendering.RenderSurfaceHostBase.RenderSurfaceAdapter
getabstract

Gets the platform-specific RenderSurfaceAdapterBase responsible for rendering the image from the Backbuffer.

Definition at line 62 of file RenderSurfaceHostBase.cs.

◆ Scene

Scene Gondwana.Rendering.RenderSurfaceHostBase.Scene
getabstract

Gets the source Scenes.Scene used for rendering operations.

Definition at line 56 of file RenderSurfaceHostBase.cs.

◆ Telemetry

Diagnostics.? TelemetrySource Gondwana.Rendering.RenderSurfaceHostBase.Telemetry
getset

Neutral session-local measurements for this host; null when source capacity is exhausted or the shared collector is disposed.

Definition at line 17 of file RenderSurfaceHostBase.cs.

◆ ViewManager

ViewManager Gondwana.Rendering.RenderSurfaceHostBase.ViewManager
getabstract

Gets the view manager that controls camera positions, viewports, and multi-view rendering for this render surface host.

The ViewManager instance managing all views associated with this render surface host.

The view manager enables split-screen, picture-in-picture, and minimap rendering by managing multiple views with independent cameras and viewports.

Definition at line 75 of file RenderSurfaceHostBase.cs.

Event Documentation

◆ GpuRenderSynchronizationDiagnosticsCalculated

Action<GpuRenderSynchronizationDiagnostics>? Gondwana.Rendering.RenderSurfaceHostBase.GpuRenderSynchronizationDiagnosticsCalculated

Occurs after a GPU render/snapshot call when a subscriber requests timing for the shared render-state synchronization gate.

Definition at line 86 of file RenderSurfaceHostBase.cs.