Download Now

    Reference TSceneHost

    Declared in Codebot.Render.Scenes.pas on line 77

    TSceneHost runs scenes and provides what they share. A host makes itself current on its render thread with SetSceneHost, and scenes created on that thread use it. All of its properties are used from the render thread.
    A host calls PlatformDispatch from Codebot.Platform once a frame before updating its scene, so dialogs executed by the scene deliver their OnClose events on the render thread.
      TSceneHost = class(TComponent)
      protected
        FCanvas: ICanvas;
        FFont: IFont;
        FTimer: IStopwatch;
        FTime: Double;
        FFrameRate: Integer;
        FMouseX: Float;
        FMouseY: Float;
        FWindow: IWindow;
        FVSync: Boolean;
        { The clipboard is PlatformClipboard unless a host overrides it }
        function GetClipboard: string; virtual;
        procedure SetClipboard(const Value: string); virtual;
        { Hosts which own an OpenGL context apply VSync to it }
        function GetVSync: Boolean; virtual;
        procedure SetVSync(Value: Boolean); virtual;
      public
        { The canvas used for vector graphics, sharing Ctx with the scenes }
        property Canvas: ICanvas read FCanvas;
        { The default font, which may be nil if it could not be loaded }
        property Font: IFont read FFont;
        { The timer shared by all scenes, calculated once at the start of a frame }
        property Timer: IStopwatch read FTimer;
        { The time of the current frame }
        property Time: Double read FTime;
        { Frames rendered in the last second }
        property FrameRate: Integer read FFrameRate;
        { The position of the last mouse event }
        property MouseX: Float read FMouseX;
        property MouseY: Float read FMouseY;
        { Text on the clipboard, read and written from the render thread }
        property Clipboard: string read GetClipboard write SetClipboard;
        { The window showing the scenes, which may be nil if the host has none }
        property Window: IWindow read FWindow;
        { When VSync is True each frame waits for the vertical sync of the display.
          It is used from the render thread. }
        property VSync: Boolean read GetVSync write SetVSync;
      end;

    See also

    Float in Codebot.System.pas
    ICanvas in Codebot.Render.Graphics.pas
    IFont in Codebot.Render.Graphics.pas
    IStopwatch in Codebot.System.pas
    IWindow in Codebot.Platform.pas