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
AvaloniaBitmapRenderSurfaceControl.cs
1using Avalonia;
2using Avalonia.Controls;
3using Avalonia.Media;
4using Avalonia.Media.Imaging;
7
9
17{
18 private WriteableBitmap? _bitmap;
19
24
28 public RenderSurfaceHost<BitmapBackbuffer> Host { get; }
29
34 {
36 Host = new RenderSurfaceHost<BitmapBackbuffer>(Adapter);
37
38 SizeChanged += (_, _) => Adapter.RefreshDestinationSize();
39 }
40
46 internal void SetBitmap(WriteableBitmap bitmap) => _bitmap = bitmap;
47
49 public override void Render(DrawingContext context)
50 {
51 context.FillRectangle(Brushes.Black, new Rect(Bounds.Size));
52 RenderOptions.SetBitmapInterpolationMode(this,
53 Engine.Instance.Configuration.RenderScalingFilter == RenderScalingFilter.NearestNeighbor
54 ? BitmapInterpolationMode.None : BitmapInterpolationMode.LowQuality);
55 var bmp = _bitmap;
56 if (bmp != null)
57 {
58 var fit = PresentationTransform.Fit(bmp.PixelSize.Width, bmp.PixelSize.Height, Adapter.Width, Adapter.Height).DestinationRect;
59 var dest = new Rect(fit.Left, fit.Top, fit.Width, fit.Height);
60 context.DrawImage(bmp, new Rect(bmp.Size), dest);
61 }
62 }
63}
Provides a bitmap (CPU) render surface adapter for Avalonia that presents each frame by copying pixel...
AvaloniaBitmapRenderSurfaceControl()
Initializes a new instance of the AvaloniaBitmapRenderSurfaceControl class.
AvaloniaBitmapRenderSurfaceAdapter Adapter
Gets the render surface adapter used to drive this control.
RenderSurfaceHost< BitmapBackbuffer > Host
Gets the RenderSurfaceHost<T> bound to this control.
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
EngineConfiguration Configuration
Gets the current engine configuration settings.
Definition Engine.cs:928
readonly record struct PresentationTransform(float Scale, SKRect DestinationRect)
Aspect-preserving mapping between logical Backbuffer ScreenPx and adapter pixels.
RenderScalingFilter
Filtering used only when presenting the finished Backbuffer.