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.WinForms.Rendering.WinFormGpuRenderSurfaceAdapter Class Referencesealed

Provides a GPU-accelerated render surface adapter for Windows Forms using OpenGL and SKGLControl. More...

Inheritance diagram for Gondwana.WinForms.Rendering.WinFormGpuRenderSurfaceAdapter:
Gondwana.Rendering.RenderSurfaceAdapterBase

Public Member Functions

void RefreshDestinationSize ()
 Refreshes the destination size based on the current client size of the presentation control. A non-positive size marks presentation as unavailable without resizing the logical Backbuffer.
 WinFormGpuRenderSurfaceAdapter (SKGLControl gl)
 Initializes a new instance of the WinFormGpuRenderSurfaceAdapter class.
void SetHost (RenderSurfaceHostBase host)
 Registers the RenderSurfaceHostBase whose scene this adapter should render and wires the GL paint loop to the engine's foreground cycle.
override void Present (SKImage bufferImage, SKRectI bufferRect, SKRect destRect)
 Not used in the GL-thread path. Rendering is driven by SetHost and SKGLControl.PaintSurface. The image is disposed immediately to avoid a leak.
void Dispose ()
 Releases all resources used by the WinFormGpuRenderSurfaceAdapter.
Public Member Functions inherited from Gondwana.Rendering.RenderSurfaceAdapterBase
Point AdapterPxToScreenPx (PointF adapterPx)
 Converts adapter input to logical ScreenPx, retaining outside coordinates for capture/leave.
void DrawImage (SKCanvas canvas, SKImage image, SKColor clearColor)
 Presents a complete image using the same transform as pointer normalization.
void Present (SKImage bufferImage, SKRectI bufferRect, SKRect destRect)
 Presents the specified portion of the Backbuffer image to the destination rectangle on the RenderSurfaceAdapter.

Properties

SKColor ClearColor = SKColors.Black [get, set]
 Gets or sets the color used to clear the surface before rendering.
GRContext? GrContext [get]
 Gets the GL/Skia GPU context that should be shared with the GpuBackbuffer.
Properties inherited from Gondwana.Rendering.RenderSurfaceAdapterBase
PresentationTransform Presentation [get]
 Current immutable aspect-preserving mapping of Backbuffer ScreenPx to adapter pixels.
float PresentationScale [get]
 Current derived presentation scale; adapter resize does not resize the Backbuffer.
int Width [get, protected set]
 Gets the current width of the render surface in pixels.
int Height [get, protected set]
 Gets the current height of the render surface in pixels.

Events

Action< GRContext >? GrContextFirstAvailable
 Raised once, the first time the GRContext becomes available in OnPaintSurface. Subscribe to this event to call GpuBackbuffer.Initialize on the GL thread.
Action< GRContext, int, int >? ResizeRequested
 Raised on the GL thread when the control has been resized and a valid GRContext is available. The arguments are the context and the new width and height in adapter pixels. This event is for presentation resources; it must not be used to resize the logical Backbuffer.
Action< WinFormGpuFrameDiagnostics >? FrameDiagnosticsCalculated
 Occurs after a completed GPU paint callback when a subscriber requests timing diagnostics.
Events inherited from Gondwana.Rendering.RenderSurfaceAdapterBase
Action< RenderSurfaceAdapterResizedEventArgs >? Resized
 Occurs when the render surface adapter is resized.

Additional Inherited Members

Protected Member Functions inherited from Gondwana.Rendering.RenderSurfaceAdapterBase
 RenderSurfaceAdapterBase (int destWidth, int destHeight)
 Initializes a new instance of the RenderSurfaceAdapterBase class with the specified dimensions.
 RenderSurfaceAdapterBase (int destWidth, int destHeight, bool initialSizeAvailable)
 Constructs an adapter whose initial layout may still be pending.
void SetDestinationSize (int destWidth, int destHeight)
 Sets the destination size of the render surface and raises the Resized event if the dimensions have changed.

Detailed Description

Provides a GPU-accelerated render surface adapter for Windows Forms using OpenGL and SKGLControl.

Engine foreground work publishes immutable render snapshots and requests repaint through AfterFrameRender. PaintSurface replays the newest completed recording and presents it with the current GL context. Repaint requests coalesce; intermediate recordings may be replaced without blocking simulation.

Definition at line 18 of file WinFormGpuRenderSurfaceAdapter.cs.

Constructor & Destructor Documentation

◆ WinFormGpuRenderSurfaceAdapter()

Gondwana.WinForms.Rendering.WinFormGpuRenderSurfaceAdapter.WinFormGpuRenderSurfaceAdapter ( SKGLControl gl)

Initializes a new instance of the WinFormGpuRenderSurfaceAdapter class.

Parameters
glThe SKGLControl to use as the render target and presentation control.

Definition at line 96 of file WinFormGpuRenderSurfaceAdapter.cs.

Member Function Documentation

◆ Dispose()

void Gondwana.WinForms.Rendering.WinFormGpuRenderSurfaceAdapter.Dispose ( )

Releases all resources used by the WinFormGpuRenderSurfaceAdapter.

Definition at line 323 of file WinFormGpuRenderSurfaceAdapter.cs.

◆ Present()

override void Gondwana.WinForms.Rendering.WinFormGpuRenderSurfaceAdapter.Present ( SKImage bufferImage,
SKRectI bufferRect,
SKRect destRect )

Not used in the GL-thread path. Rendering is driven by SetHost and SKGLControl.PaintSurface. The image is disposed immediately to avoid a leak.

Parameters
bufferImageThe rendered image to present.
bufferRectThe source rectangle within the rendered image.
destRectThe destination rectangle on the render surface.

Definition at line 167 of file WinFormGpuRenderSurfaceAdapter.cs.

◆ RefreshDestinationSize()

void Gondwana.WinForms.Rendering.WinFormGpuRenderSurfaceAdapter.RefreshDestinationSize ( )

Refreshes the destination size based on the current client size of the presentation control. A non-positive size marks presentation as unavailable without resizing the logical Backbuffer.

Definition at line 79 of file WinFormGpuRenderSurfaceAdapter.cs.

◆ SetHost()

void Gondwana.WinForms.Rendering.WinFormGpuRenderSurfaceAdapter.SetHost ( RenderSurfaceHostBase host)

Registers the RenderSurfaceHostBase whose scene this adapter should render and wires the GL paint loop to the engine's foreground cycle.

After this call all rendering is driven from PaintSurface on the GL thread. Invalidate() is posted to the UI thread via Engine.UiDispatcher at the end of each Engine.DoForegroundTasks call (via Engine.AfterFrameRender), so the frame rate is governed entirely by Gondwana.Configuration.EngineConfiguration.TargetFPS.

Parameters
hostThe render surface host to render each frame.

Definition at line 141 of file WinFormGpuRenderSurfaceAdapter.cs.

Property Documentation

◆ ClearColor

SKColor Gondwana.WinForms.Rendering.WinFormGpuRenderSurfaceAdapter.ClearColor = SKColors.Black
getset

Gets or sets the color used to clear the surface before rendering.

Definition at line 48 of file WinFormGpuRenderSurfaceAdapter.cs.

◆ GrContext

GRContext? Gondwana.WinForms.Rendering.WinFormGpuRenderSurfaceAdapter.GrContext
get

Gets the GL/Skia GPU context that should be shared with the GpuBackbuffer.

Definition at line 53 of file WinFormGpuRenderSurfaceAdapter.cs.

Event Documentation

◆ FrameDiagnosticsCalculated

Action<WinFormGpuFrameDiagnostics>? Gondwana.WinForms.Rendering.WinFormGpuRenderSurfaceAdapter.FrameDiagnosticsCalculated

Occurs after a completed GPU paint callback when a subscriber requests timing diagnostics.

Definition at line 73 of file WinFormGpuRenderSurfaceAdapter.cs.

◆ GrContextFirstAvailable

Action<GRContext>? Gondwana.WinForms.Rendering.WinFormGpuRenderSurfaceAdapter.GrContextFirstAvailable

Raised once, the first time the GRContext becomes available in OnPaintSurface. Subscribe to this event to call GpuBackbuffer.Initialize on the GL thread.

Definition at line 60 of file WinFormGpuRenderSurfaceAdapter.cs.

◆ ResizeRequested

Action<GRContext, int, int>? Gondwana.WinForms.Rendering.WinFormGpuRenderSurfaceAdapter.ResizeRequested

Raised on the GL thread when the control has been resized and a valid GRContext is available. The arguments are the context and the new width and height in adapter pixels. This event is for presentation resources; it must not be used to resize the logical Backbuffer.

Definition at line 68 of file WinFormGpuRenderSurfaceAdapter.cs.