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
WinFormBitmapRenderSurfaceControl.cs
3using SkiaSharp.Views.Desktop;
4
6
10public partial class WinFormBitmapRenderSurfaceControl : UserControl
11{
12 private readonly SKControl _skControl;
13
18
22 public RenderSurfaceHost<BitmapBackbuffer> Host { get; }
23
28 {
29 _skControl = new SKControl { Dock = DockStyle.Fill };
30 Controls.Add(_skControl);
31
32 // Forward mouse events
33 _skControl.MouseDown += (s, e) => OnMouseDown(e);
34 _skControl.MouseUp += (s, e) => OnMouseUp(e);
35 _skControl.MouseMove += (s, e) => OnMouseMove(e);
36 _skControl.MouseClick += (s, e) => OnMouseClick(e);
37 _skControl.MouseWheel += (s, e) => OnMouseWheel(e);
38 _skControl.MouseEnter += (s, e) => OnMouseEnter(e);
39 _skControl.MouseLeave += (s, e) => OnMouseLeave(e);
40
41 // Create the render adapter for the SKControl
43
44 // Create the surface and hook the adapter
45 Host = new RenderSurfaceHost<BitmapBackbuffer>(Adapter);
46
47 // Ensure the adapter re-reads size whenever THIS wrapper changes size
48 SizeChanged += (_, __) => Adapter.RefreshDestinationSize();
49
50 // Fire once after this control is realized
51 HandleCreated += (_, __) => Adapter.RefreshDestinationSize();
52 if (IsHandleCreated)
53 BeginInvoke((Action)Adapter.RefreshDestinationSize);
54 }
55
60 protected override void OnParentChanged(EventArgs e)
61 {
62 base.OnParentChanged(e);
63 if (IsHandleCreated)
64 BeginInvoke((Action)Adapter.RefreshDestinationSize);
65 }
66
71 protected override void Dispose(bool disposing)
72 {
73 if (disposing && (components != null))
74 {
75 components.Dispose();
76 Host?.Dispose();
77 }
78
79 base.Dispose(disposing);
80 }
81}
Provides a render surface adapter for Windows Forms using SKControl and bitmap-based rendering.
override void OnParentChanged(EventArgs e)
Refreshes the render surface size when the control's parent changes.
RenderSurfaceHost< BitmapBackbuffer > Host
Gets the render surface host used for displaying game content.
WinFormBitmapRenderSurfaceAdapter Adapter
Gets the render surface adapter used by this control.
override void Dispose(bool disposing)
Clean up any resources being used.
WinFormBitmapRenderSurfaceControl()
Initializes a new instance of the WinFormBitmapRenderSurfaceControl class.