mirror of
https://github.com/AlexMacocian/MonoGame.Extended.git
synced 2026-07-24 03:56:31 +00:00
46 lines
1.3 KiB
C#
46 lines
1.3 KiB
C#
using System;
|
|
using Microsoft.Xna.Framework;
|
|
using Microsoft.Xna.Framework.Graphics;
|
|
|
|
namespace MonoGame.Extended.ViewportAdapters
|
|
{
|
|
public abstract class ViewportAdapter : IDisposable
|
|
{
|
|
protected ViewportAdapter(GraphicsDevice graphicsDevice)
|
|
{
|
|
GraphicsDevice = graphicsDevice;
|
|
}
|
|
|
|
public virtual void Dispose()
|
|
{
|
|
}
|
|
|
|
public GraphicsDevice GraphicsDevice { get; }
|
|
public Viewport Viewport => GraphicsDevice.Viewport;
|
|
|
|
public abstract int VirtualWidth { get; }
|
|
public abstract int VirtualHeight { get; }
|
|
public abstract int ViewportWidth { get; }
|
|
public abstract int ViewportHeight { get; }
|
|
|
|
public Rectangle BoundingRectangle => new Rectangle(0, 0, VirtualWidth, VirtualHeight);
|
|
public Point Center => BoundingRectangle.Center;
|
|
public abstract Matrix GetScaleMatrix();
|
|
|
|
public Point PointToScreen(Point point)
|
|
{
|
|
return PointToScreen(point.X, point.Y);
|
|
}
|
|
|
|
public virtual Point PointToScreen(int x, int y)
|
|
{
|
|
var scaleMatrix = GetScaleMatrix();
|
|
var invertedMatrix = Matrix.Invert(scaleMatrix);
|
|
return Vector2.Transform(new Vector2(x, y), invertedMatrix).ToPoint();
|
|
}
|
|
|
|
public virtual void Reset()
|
|
{
|
|
}
|
|
}
|
|
} |