![]() |
Gondwana Game Engine
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, mobile, and web platforms using SkiaSharp for graphics and NAudio for sound.
|
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 |
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. | |
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 operations, 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.
|
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.
|
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.
|
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. |
|
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.
|
protected |
|
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.
|
getset |
Gets or sets the color used to clear the drawing surface.
|
getset |
Gets or sets the paint settings used to render collision boxes.
|
getset |
Gets or sets the paint object used to render fog effects.
|
getset |
Gets or sets the paint settings used to render grid lines.
|
get |
Gets the current Backbuffer height in a thread-safe manner.
|
get |
Gets the current Backbuffer width in a thread-safe manner.