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.
Loading...
Searching...
No Matches
Gondwana.Rendering.Views.Viewport Class Referencesealed

A rectangular window on the render target with its own zoom and placement. Viewport never moves the world; it only scales and positions the drawing. More...

Public Member Functions

void Resize (int width, int height)
 Updates the viewport size while preserving its current on-screen origin. This is a convenience around TargetRectPx that only changes the width and height.
void SnapZoom (float zoom)
 Instantly sets the zoom level, raising the ZoomChanged event.
void ZoomTo (float targetZoom, float lerpPerSecond)
 Smoothly animates the zoom toward a target level using an exponential lerp rate in "per second" units. Values <= 0 snap immediately.
void ZoomToOverDuration (float targetZoom, float durationSeconds)
 Smoothly animates the zoom so that it reaches ~99% of the target level over approximately the given duration in seconds. Values <= 0 snap.

Properties

Rectangle TargetRectPx [get, set]
 Screen-space rectangle (in SCREEN / RenderSurface pixels) where this view is drawn. This defines the on-screen position and size of the viewport for this view.
float Zoom [get, set]
 Zoom factor applied to the world when rendering this view. Values greater than 1 zoom in, values between 0 and 1 zoom out. Used when converting between screen-space and world-space pixels.
PointF ScreenOffsetPx = PointF.Empty [get, set]
 Optional per-view HUD/safe-area offset in screen pixels.
SizeF VisibleWorldSizePx [get]
 World size visible through this viewport (used for Camera clamping).

Events

Action< ViewportResizedEventArgs >? TargetRectChanged
 Fired whenever TargetRectPx changes (viewport resized or moved). Provides the Viewport instance and the old and new rectangles.
Action< ViewportZoomChangedEventArgs >? ZoomChanged
 Occurs when the zoom level of the viewport changes.

Detailed Description

A rectangular window on the render target with its own zoom and placement. Viewport never moves the world; it only scales and positions the drawing.

Member Function Documentation

◆ Resize()

void Gondwana.Rendering.Views.Viewport.Resize ( int width,
int height )

Updates the viewport size while preserving its current on-screen origin. This is a convenience around TargetRectPx that only changes the width and height.

Parameters
widthNew viewport width in pixels.
heightNew viewport height in pixels.

◆ SnapZoom()

void Gondwana.Rendering.Views.Viewport.SnapZoom ( float zoom)

Instantly sets the zoom level, raising the ZoomChanged event.

◆ ZoomTo()

void Gondwana.Rendering.Views.Viewport.ZoomTo ( float targetZoom,
float lerpPerSecond )

Smoothly animates the zoom toward a target level using an exponential lerp rate in "per second" units. Values <= 0 snap immediately.

◆ ZoomToOverDuration()

void Gondwana.Rendering.Views.Viewport.ZoomToOverDuration ( float targetZoom,
float durationSeconds )

Smoothly animates the zoom so that it reaches ~99% of the target level over approximately the given duration in seconds. Values <= 0 snap.

Property Documentation

◆ ScreenOffsetPx

PointF Gondwana.Rendering.Views.Viewport.ScreenOffsetPx = PointF.Empty
getset

Optional per-view HUD/safe-area offset in screen pixels.

◆ TargetRectPx

Rectangle Gondwana.Rendering.Views.Viewport.TargetRectPx
getset

Screen-space rectangle (in SCREEN / RenderSurface pixels) where this view is drawn. This defines the on-screen position and size of the viewport for this view.

◆ VisibleWorldSizePx

SizeF Gondwana.Rendering.Views.Viewport.VisibleWorldSizePx
get

World size visible through this viewport (used for Camera clamping).

◆ Zoom

float Gondwana.Rendering.Views.Viewport.Zoom
getset

Zoom factor applied to the world when rendering this view. Values greater than 1 zoom in, values between 0 and 1 zoom out. Used when converting between screen-space and world-space pixels.

Event Documentation

◆ TargetRectChanged

Action<ViewportResizedEventArgs>? Gondwana.Rendering.Views.Viewport.TargetRectChanged

Fired whenever TargetRectPx changes (viewport resized or moved). Provides the Viewport instance and the old and new rectangles.

◆ ZoomChanged

Action<ViewportZoomChangedEventArgs>? Gondwana.Rendering.Views.Viewport.ZoomChanged

Occurs when the zoom level of the viewport changes.