![]() |
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.
|
Represents a base class for managing a graphical backbuffer, and is the in-memory surface where rendering operations are performed before being presented to the display. More...
Public Member Functions | |
| virtual byte[] | ToByteArray (SKEncodedImageFormat format=SKEncodedImageFormat.Png, int quality=100) |
| Converts the current image to a byte array in the specified format and quality. | |
| virtual void | Dispose () |
| Releases all resources used by the BackbufferBase instance. | |
Protected Member Functions | |
| BackbufferBase (int width, int height) | |
| Initializes a new instance of the BackbufferBase class with the specified dimensions. | |
| void | UpdateSize (int width, int height) |
| Updates the stored backbuffer dimensions and raises the SizeChanged event. | |
Protected Attributes | |
| readonly SKPaint | _fillPaint |
| Paint used to fill cleared regions of the backbuffer with the current ClearColor. | |
Properties | |
| SKCanvas | Canvas [get] |
| Gets the SkiaSharp canvas used for drawing operations on this backbuffer. | |
| SKPaint | FogPaint [get, set] |
| Gets or sets the paint object used to render fog effects. | |
| SKPaint | GridLinePaint [get, set] |
| Gets or sets the paint settings used to render grid lines. | |
| SKPaint | CollisionBoxPaint [get, set] |
| Gets or sets the paint settings used to render collision boxes. | |
| int | Width [get] |
| Gets the current Backbuffer width in a thread-safe manner. | |
| int | Height [get] |
| Gets the current Backbuffer height in a thread-safe manner. | |
| SKColor | ClearColor [get, set] |
| Gets or sets the color used to clear the drawing surface. | |
| virtual bool | IsGlThreadRendered [get] |
| Gets a value indicating whether this backbuffer is rendered on the GL thread rather than the engine's background render thread. | |
Represents a base class for managing a graphical backbuffer, and is the in-memory surface where rendering operations are performed before being presented to the display.
This abstract class serves as the foundation for backbuffer implementations, offering methods and properties to facilitate rendering, manage graphical state, and interact with graphical elements such as tiles. Derived classes must implement the Canvas, DrawTileFrame(Tile, RectangleF), and Snapshot members to define specific rendering behavior.
Definition at line 19 of file BackbufferBase.cs.
|
protected |
Initializes a new instance of the BackbufferBase class with the specified dimensions.
| width | The width of the backbuffer in pixels. |
| height | The height of the backbuffer in pixels. |
This constructor establishes the initial size of the backbuffer. Derived classes can override RequestResize to implement dynamic resizing behavior if needed.
Definition at line 36 of file BackbufferBase.cs.
|
virtual |
Releases all resources used by the BackbufferBase instance.
This method disposes of managed resources including paint objects used for fog effects, grid lines, collision boxes, and fill operations. Derived classes can override this method to dispose of additional resources but should call the base implementation to ensure proper cleanup of base class resources.
After disposal, the backbuffer should not be used for further rendering operations.
Reimplemented in Gondwana.Rendering.Backbuffers.BitmapBackbuffer, and Gondwana.Rendering.Backbuffers.GpuBackbuffer.
Definition at line 529 of file BackbufferBase.cs.
|
virtual |
Converts the current image to a byte array in the specified format and quality.
This method creates a snapshot of the current image and encodes it into the specified format. The resulting byte array can be used for saving the image to a file, transmitting it over a network, or other purposes requiring a binary representation of the image.
| format | The format to encode the image in. The default is SKEncodedImageFormat.Png. |
| quality | The quality of the encoded image, ranging from 0 (lowest quality) to 100 (highest quality). This parameter is ignored for formats that do not support quality settings. The default is 100. |
Definition at line 496 of file BackbufferBase.cs.
|
protected |
Updates the stored backbuffer dimensions and raises the SizeChanged event.
| width | The new width in pixels. |
| height | The new height in pixels. |
This method should be called by derived classes after successfully resizing the backbuffer to ensure that the Width and Height properties are updated in a thread-safe manner and subscribers are notified of the size change.
The method uses volatile writes to ensure visibility across threads and raises the SizeChanged event with the new dimensions.
Definition at line 252 of file BackbufferBase.cs.
|
protected |
Paint used to fill cleared regions of the backbuffer with the current ClearColor.
Definition at line 271 of file BackbufferBase.cs.
|
getabstract |
Gets the SkiaSharp canvas used for drawing operations on this backbuffer.
An SKCanvas instance that provides the drawing surface for rendering operations.
Derived classes must implement this property to provide access to the underlying drawing canvas. All rendering operations, including tiles, sprites, and direct drawing instances, are performed on this canvas.
The canvas should be configured with appropriate coordinate transformations, clipping regions, and rendering states before drawing operations begin.
Definition at line 60 of file BackbufferBase.cs.
|
getset |
Gets or sets the color used to clear the drawing surface.
Definition at line 282 of file BackbufferBase.cs.
|
getset |
Gets or sets the paint settings used to render collision boxes.
Definition at line 175 of file BackbufferBase.cs.
|
getset |
Gets or sets the paint object used to render fog effects.
Definition at line 156 of file BackbufferBase.cs.
|
getset |
Gets or sets the paint settings used to render grid lines.
Definition at line 165 of file BackbufferBase.cs.
|
get |
Gets the current Backbuffer height in a thread-safe manner.
Definition at line 190 of file BackbufferBase.cs.
|
get |
Gets a value indicating whether this backbuffer is rendered on the GL thread rather than the engine's background render thread.
When true, bitmap dirty-region rendering is skipped. Desktop GPU hosts record immutable snapshots during foreground work; the platform GL callback replays and presents them via RenderSurfaceHostBase.GlRenderAndSnapshot. Browser GPU hosts retain synchronous full-viewport rendering.
Definition at line 513 of file BackbufferBase.cs.
|
get |
Gets the current Backbuffer width in a thread-safe manner.
Definition at line 185 of file BackbufferBase.cs.