Class PointerSurfaceMapping
Maps pointer positions reported against a pointer surface onto the back-buffer viewport, for engine connectors whose pointer surface and presented image differ.
public static class PointerSurfaceMapping
- Inheritance
-
PointerSurfaceMapping
- Inherited Members
Remarks
A pointer device may measure positions against its own surface - for a touch screen, the whole touch area - while the game presents its back buffer aspect-fit and centered on that surface: letterboxed (bars above and below) when the surface is taller than the back buffer, pillarboxed (bars left and right) when it is wider. Stride does this in fullscreen when the back buffer keeps its windowed aspect ratio.
The mapping works on normalized positions and aspect ratios only, so the surface size may be in any unit. When the aspect ratios match (e.g. in windowed mode), it reduces to a plain scale.
Methods
ToViewport(Vector2, SizeF, Size)
Converts a normalized pointer position on a pointer surface into back-buffer pixels, assuming the back buffer is presented aspect-fit and centered on that surface.
public static Point ToViewport(Vector2 normalized, SizeF surfaceSize, Size viewportSize)
Parameters
normalizedVector2The pointer position on the surface, where
(0, 0)is the top-left and(1, 1)the bottom-right corner.surfaceSizeSizeFThe pointer surface size, in any unit.
viewportSizeSizeThe back-buffer size, in physical pixels.
Returns
- Point
The position in back-buffer pixels. Points over the black bars map outside the viewport. A degenerate surface or viewport size falls back to scaling
normalizedbyviewportSize.