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
AvaloniaGpuRenderSurfaceAdapter.cs
3using SkiaSharp;
4
6
29public sealed class AvaloniaGpuRenderSurfaceAdapter : RenderSurfaceAdapterBase, IDisposable
30{
31 private Action? _afterFrameRenderHandler;
32 private bool _disposed;
33
37 public SKColor ClearColor { get; set; } = SKColors.Black;
38
44 internal AvaloniaGpuRenderSurfaceAdapter(int initialWidth, int initialHeight)
45 : base(Math.Max(1, initialWidth), Math.Max(1, initialHeight), initialSizeAvailable: false)
46 {
47 }
48
57 internal void UpdateDimensions(int physW, int physH)
58 {
59 if (!_disposed)
60 SetDestinationSize(Math.Max(0, physW), Math.Max(0, physH));
61 }
62
69 internal void AttachToEngine(Action requestRepaint)
70 {
71 _afterFrameRenderHandler = () =>
72 {
73 if (!_disposed)
74 Engine.Instance.UiDispatcher!.Post(requestRepaint);
75 };
76 Engine.Instance.AfterFrameRender += _afterFrameRenderHandler;
77 }
78
85 public override void Present(SKImage bufferImage, SKRectI bufferRect, SKRect destRect)
86 {
87 bufferImage.Dispose();
88 }
89
93 public void Dispose()
94 {
95 if (_disposed) return;
96 _disposed = true;
97
98 if (_afterFrameRenderHandler != null)
99 {
100 Engine.Instance.AfterFrameRender -= _afterFrameRenderHandler;
101 _afterFrameRenderHandler = null;
102 }
103 }
104}
Provides a GPU-accelerated render surface adapter for Avalonia, backed by global::Avalonia....
SKColor ClearColor
Gets or sets the color used to clear the surface before rendering.
override void Present(SKImage bufferImage, SKRectI bufferRect, SKRect destRect)
Not used in the GL-thread path. The image is disposed immediately to avoid a leak.
void Dispose()
Releases all resources used by the AvaloniaGpuRenderSurfaceAdapter.
Represents the core game engine singleton responsible for managing the main update loop,...
Definition Engine.cs:36
static Engine Instance
Gets the singleton instance of the Engine.
Definition Engine.cs:49
IUiDispatcher? UiDispatcher
Gets the UI dispatcher used for marshalling operations to the UI thread.
Definition Engine.cs:791
void SetDestinationSize(int destWidth, int destHeight)
Sets the destination size of the render surface and raises the Resized event if the dimensions have c...
RenderSurfaceAdapterBase(int destWidth, int destHeight)
Initializes a new instance of the RenderSurfaceAdapterBase class with the specified dimensions.
void Post(Action action)
Asynchronously posts an action to be executed on the UI thread. This method queues the action and ret...