Gondwana Game Engine
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, mobile, and web platforms using SkiaSharp for graphics and NAudio for sound.
Loading...
Searching...
No Matches
Gondwana.Rendering.RenderSurfaceHost< TBackbuffer > Class Template Referencesealed

Hosts a render surface and manages rendering of a scene to a backbuffer of the specified type. Provides coordination between the scene, views, and the underlying UI adapter for efficient rendering and presentation. More...

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

Public Member Functions

RenderSurfaceHost() RenderSurfaceHost (RenderSurfaceAdapterBase renderSurfaceAdapter)
 Initializes a new instance of the RenderSurfaceHost<TBackbuffer> class with the specified render surface adapter.
void Bind (Scene newScene, bool limitCameraToWorldBoundPx=true)
 Binds a scene to this render surface host, replacing any previously bound scene.
void Dispose ()
 Releases all resources used by this RenderSurfaceHost<TBackbuffer> instance.
void Dispose (bool disposing)
 Releases resources used by this RenderSurfaceHost<TBackbuffer> instance.
Public Member Functions inherited from Gondwana.Rendering.RenderSurfaceHostBase
void Dispose ()
 Releases all resources used by this RenderSurfaceHostBase instance.

Properties

override BackbufferBase Backbuffer [get]
 Gets the backbuffer used for off-screen rendering before presentation to the adapter.
override Scene Scene [get]
 Gets the scene currently bound to this render surface host.
override RenderSurfaceAdapterBase RenderSurfaceAdapter [get]
 Gets the platform-specific adapter that provides the underlying rendering surface.
override ViewManager ViewManager [get]
 Gets the view manager that controls camera positions, viewports, and multi-view rendering.
bool RedrawDirtyRectangleOnly = true [get, set]
 Gets or sets a value indicating whether only the dirty (changed) regions of the backbuffer are presented to the adapter each frame.
Properties inherited from Gondwana.Rendering.RenderSurfaceHostBase
BackbufferBase Backbuffer [get]
 Gets the in-memory BackbufferBase associated with the current rendering context.
Scene Scene [get]
 Gets the source Scenes.Scene used for rendering operations.
RenderSurfaceAdapterBaseRenderSurfaceAdapter [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.

Events

EventHandler< RenderSurfaceHostBindEventArgs >? BindToScene
 Occurs when a scene is bound to or unbound from this render surface host.
Action RenderBackbufferBegin
 Occurs at the beginning of the backbuffer rendering process.
Action RenderBackbufferEnd
 Occurs at the end of the backbuffer rendering process.
Action RenderBackbufferNoOp
 Occurs when a backbuffer render operation is skipped because the scene is not dirty.

Additional Inherited Members

Protected Member Functions inherited from Gondwana.Rendering.RenderSurfaceHostBase
 RenderSurfaceHostBase ()
 Initializes a new instance of the RenderSurfaceHostBase class and registers it with the RenderSurfaceHostRegistry.

Detailed Description

Hosts a render surface and manages rendering of a scene to a backbuffer of the specified type. Provides coordination between the scene, views, and the underlying UI adapter for efficient rendering and presentation.

RenderSurfaceHost<TBackbuffer> is responsible for managing the lifecycle of the backbuffer, handling scene binding, and coordinating redraws based on scene and view changes. It supports partial or full redraws depending on the state of the scene and the RedrawDirtyRectangleOnly property. Thread safety is not guaranteed; all interactions should occur on the UI thread associated with the render surface adapter.

Template Parameters
TBackbufferThe type of backbuffer used for rendering. Must inherit from BackbufferBase.
Type Constraints
TBackbuffer :BackbufferBase 

Member Function Documentation

◆ Bind()

void Gondwana.Rendering.RenderSurfaceHost< TBackbuffer >.Bind ( Scene newScene,
bool limitCameraToWorldBoundPx = true )

Binds a scene to this render surface host, replacing any previously bound scene.

Parameters
newSceneThe scene to bind. Must not be null.
limitCameraToWorldBoundPxtrue to constrain all view cameras to the scene's world bounds; false to allow cameras to move freely beyond the scene boundaries.
Exceptions
ArgumentNullExceptionThrown when newScene is null.

Binding a scene unregisters event handlers from the previous scene (if any), registers handlers with the new scene, and triggers a full refresh on the next frame. The BindToScene event fires after the binding operation completes.

If the specified scene is already bound, this method returns immediately without performing any operations.

◆ Dispose() [1/2]

void Gondwana.Rendering.RenderSurfaceHost< TBackbuffer >.Dispose ( )

Releases all resources used by this RenderSurfaceHost<TBackbuffer> instance.

This method releases managed resources including the backbuffer. It does not unregister from the scene; that should be handled by the scene's disposal logic.

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

◆ Dispose() [2/2]

void Gondwana.Rendering.RenderSurfaceHost< TBackbuffer >.Dispose ( bool disposing)
virtual

Releases resources used by this RenderSurfaceHost<TBackbuffer> instance.

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

When disposing is true, this method releases the backbuffer and clears the reference. Derived classes should override this method to release additional resources.

Reimplemented from Gondwana.Rendering.RenderSurfaceHostBase.

◆ RenderSurfaceHost()

RenderSurfaceHost() Gondwana.Rendering.RenderSurfaceHost< TBackbuffer >.RenderSurfaceHost ( RenderSurfaceAdapterBase renderSurfaceAdapter)

Initializes a new instance of the RenderSurfaceHost<TBackbuffer> class with the specified render surface adapter.

Parameters
renderSurfaceAdapterThe platform-specific adapter that provides the underlying rendering surface.
Exceptions
ArgumentNullExceptionThrown if renderSurfaceAdapter is null.
InvalidOperationExceptionThrown if the adapter has non-positive dimensions.

Property Documentation

◆ Backbuffer

override BackbufferBase Gondwana.Rendering.RenderSurfaceHost< TBackbuffer >.Backbuffer
get

Gets the backbuffer used for off-screen rendering before presentation to the adapter.

The BackbufferBase instance managing the render target canvas and dirty-rectangle tracking.

The backbuffer holds the rendered frame content and tracks which regions have changed since the last presentation. All rendering operations are performed on the backbuffer's canvas before being copied to the UI adapter during presentation.

◆ RedrawDirtyRectangleOnly

bool Gondwana.Rendering.RenderSurfaceHost< TBackbuffer >.RedrawDirtyRectangleOnly = true
getset

Gets or sets a value indicating whether only the dirty (changed) regions of the backbuffer are presented to the adapter each frame.

true to present only dirty regions (default); false to present the entire backbuffer every frame.

Enabling dirty-rectangle-only presentation improves performance by reducing the amount of data transferred to the UI adapter. Disable this when troubleshooting rendering issues or when the adapter does not support partial updates.

◆ RenderSurfaceAdapter

override RenderSurfaceAdapterBase Gondwana.Rendering.RenderSurfaceHost< TBackbuffer >.RenderSurfaceAdapter
get

Gets the platform-specific adapter that provides the underlying rendering surface.

The RenderSurfaceAdapterBase instance representing the UI control or window where rendered content is displayed.

The adapter handles platform-specific presentation details and provides size/resize notifications. The backbuffer dimensions are synchronized with the adapter's size.

◆ Scene

override Scene Gondwana.Rendering.RenderSurfaceHost< TBackbuffer >.Scene
get

Gets the scene currently bound to this render surface host.

The Scene instance being rendered, or Scene.Empty if no scene is bound.

The scene contains all layers, sprites, and direct drawings that are rendered each frame. Use Bind to change the active scene.

◆ ViewManager

override ViewManager Gondwana.Rendering.RenderSurfaceHost< TBackbuffer >.ViewManager
get

Gets the view manager that controls camera positions, viewports, and multi-view rendering.

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

Use the view manager to create, configure, and remove views. Each view defines a viewport rectangle on the backbuffer, a camera position in the scene, and zoom/parallax settings. Views enable split-screen, picture-in-picture, and minimap rendering.

Event Documentation

◆ BindToScene

EventHandler<RenderSurfaceHostBindEventArgs>? Gondwana.Rendering.RenderSurfaceHost< TBackbuffer >.BindToScene

Occurs when a scene is bound to or unbound from this render surface host.

This event fires after the scene binding operation completes. Event handlers receive information about the previously bound scene (if any) and the newly bound scene. Use this event to respond to scene changes, such as updating UI elements or resetting state that depends on the active scene.

◆ RenderBackbufferBegin

Action Gondwana.Rendering.RenderSurfaceHost< TBackbuffer >.RenderBackbufferBegin

Occurs at the beginning of the backbuffer rendering process.

◆ RenderBackbufferEnd

Action Gondwana.Rendering.RenderSurfaceHost< TBackbuffer >.RenderBackbufferEnd

Occurs at the end of the backbuffer rendering process.

◆ RenderBackbufferNoOp

Action Gondwana.Rendering.RenderSurfaceHost< TBackbuffer >.RenderBackbufferNoOp

Occurs when a backbuffer render operation is skipped because the scene is not dirty.