Table of Contents

Class SubViewportDrawContext

Namespace
Thunder.MonoGame.Avalonia.Controls
Assembly
MonoGame.Framework.dll

Context passed to the Draw delegate once per render frame. Contains the viewport rectangle the sub-view occupies, in game backbuffer coordinates. The game should set GraphicsDevice.Viewport (and optionally ScissorRectangle) to this rectangle before drawing sub-view content.

public record SubViewportDrawContext : IEquatable<SubViewportDrawContext>
Inheritance
SubViewportDrawContext
Implements
Inherited Members

Constructors

SubViewportDrawContext(Rectangle)

Creates a draw context for the specified viewport bounds. The viewport value comes from MonoGameControl's render loop, which converts each SubViewGameControl's Bounds (logical pixels) to physical pixels before constructing this record.

public SubViewportDrawContext(Rectangle viewport)

Parameters

viewport Rectangle

Properties

Viewport

The rectangle, in game backbuffer coordinates, that this sub-view occupies. Pass this directly to GraphicsDevice.Viewport before issuing draw calls for this sub-viewport.

public Rectangle Viewport { get; init; }

Property Value

Rectangle

Examples

var ctx = new SubViewportDrawContext(new Rectangle(0, 0, 640, 480));
Assert.That(ctx.Viewport.Width,  Is.EqualTo(640));
Assert.That(ctx.Viewport.Height, Is.EqualTo(480));
latest ▼