Scripting API

Scripting API

GameDisplay

Class in Abyss.Core, from Abyss.Core.

How the game is shown as it plays, as a settings screen offers it: its window framed or across the screen (GameDisplay.Mode), waiting for the display to refresh before it shows a frame (GameDisplay.VSync), and no more frames a second than GameDisplay.FrameRateCap, among the rates the display refreshes at (GameDisplay.RefreshRates); and how many it is drawing (GameDisplay.FrameRate), as a debug screen shows. World.Display.

public sealed class GameDisplay

Remarks

In a game on its own what is set is applied from the next frame: the window's mode and present mode as Bevy changes a window's, and the cap by holding each frame's end until its share of a second has passed. It starts as the game's Player settings opened the window.

In the editor the game is drawn in the Game panel, whose window and pace are the editor's: what is set is kept and read back, and not applied (GameDisplay.Applies is false), so a settings screen works the same and the editor is left as it is. GameDisplay.FrameRate is counted in both.

On a phone a cap at one of GameDisplay.RefreshRates asks the display to refresh at it, so frames capped at 60 on a display of 90 are each shown once rather than every second one twice; a cap that is none of them, such as 30, asks for the lowest whole multiple of it there is, and no cap leaves the rate to the phone. A game on a phone starts capped at GameDisplay.PhoneFrameRateCap: steady frames, and a cooler phone that lasts longer on its battery than at the most its display refreshes at, which a phone lowers its GPU's clock from as soon as it can and so drops frames at. A desktop's display is the player's to set, and is asked nothing.

Properties

Applies

public bool Applies { get; private set; }

Whether what is set is applied: in a game on its own, and not in the editor, whose window the game's is not.

Mode

public FullscreenMode Mode { get; set; }

Its window framed, or borderless across the screen it is on, the desktop's resolution kept.

Exceptions

  • ArgumentOutOfRangeException: A mode there is none of.

VSync

public bool VSync { get; set; }

Whether it waits for the display to refresh before showing a frame: no tearing, and no more frames than the display shows.

FrameRateCap

public int FrameRateCap { get; set; }

The most frames a second it draws; 0 for as many as it can. On a phone, the rate its display is asked for too, and GameDisplay.PhoneFrameRateCap as the game starts; see the remarks.

Exceptions

FrameRate

public float FrameRate { get; }

How many frames a second are drawn, counted over the last half second.

RefreshRates

public IReadOnlyList<float> RefreshRates { get; }

The refresh rates the display the game is shown on can show at the resolution it shows, in hertz, highest first, each once: what a settings screen offers GameDisplay.FrameRateCap among. Read as it is asked for, as the window may have moved to another monitor; empty where there is no display to read, as in a browser. On a phone 60 is among them whether it lists it or not, as some list a game only their highest rate.

RefreshRate

public float RefreshRate { get; }

The refresh rate the display the game is shown on shows now, in hertz; 0 where it is not known, as in a browser.

Methods

Start

public void Start(FullscreenMode mode, bool vsync, bool applies)

Starts as the window opened — mode, vsync, and on a phone GameDisplay.PhoneFrameRateCap, elsewhere no cap — applied from now on where applies. The player's and the editor's to call, as a game starts or is played.

Parameters

  • mode
  • vsync
  • applies

Constants

MostFrames

public const int MostFrames = 1000

The most frames a second GameDisplay.FrameRateCap can say.

PhoneFrameRateCap

public const int PhoneFrameRateCap = 60

The GameDisplay.FrameRateCap a game on a phone starts at; see the remarks. A game on a desktop starts at none.