Wiki

Clone wiki

Fairlight / Virtual Display

Various screen resolutions

One problem of cross platform development is to keep in mind that your application will be executed on a wide variety of hardware devices with different screen resolutions.

To solve this problem Fairlight offers you the VirtualDisplay-Concept.

VirtualDisplay

The VirtualDisplay-Class is responsible setup a render matrix to scale the app in a way you want it to automatically.

  1. You should define your virtual application resolution
  2. Define if you want to scale it on the x- and y-axis or if you want to keep your display ratio.
  3. Register the VirtualDisplay component at your EventManager.
  4. Enjoy!

The VirtualDisplay-Class also offser methods to translate x/y coordinates from real-space to virtual-space. This is for example important if you read out the Mouse-Coordinates. This is the reason why you can attach the VirtualDisplay-Instance to the Mouse-Controller. The Controller will then translate the x/y position automatically so you, as developer, don't have to translate the coordinates yourself if you listen to Touch- or MouseEvents.

Important

Don't call the AutoFit() and AutoFitAndKeepRatio()-Methods before OnCreate of the Mojo-Application is called. On some platforms the DeviceWidth and DeviceHeight isn't set yet, an so will set a wrong zoom factor.

You can use the Bootstrapping-Concept to set it up if you don't want to create your own Application-class.

Updated