DEKI/ENGINE docs
manual api reference
Deki 0.40.1
Modular C++ engine with a visual editor, for 2D and 3D
Loading...
Searching...
No Matches
Deki::IDisplay Class Referenceabstract

What a display package implements: setup, presenting frames, events and UI overlays. More...

#include <deki/providers/IDisplay.h>

Public Member Functions

virtual ~IDisplay ()=default
virtual void ClearActiveUIOverlay ()=0
virtual void * CreateUIOverlay (int32_t width, int32_t height)=0
virtual void DestroyUIOverlay (void *overlay)=0
virtual ColorFormat GetColorFormat () const =0
 The pixel format this display takes.
virtual void GetDisplaySize (int32_t *width, int32_t *height) const =0
virtual bool GetFramesShown (uint64_t *frames, uint64_t *lastShownUs) const
 How many frames the panel has shown so far, and when the latest one went up (microseconds on the display's own monotonic clock), for a frame-rate counter: frames shown over the time between two readings is the rate the player sees, which timing the game's loop is not (the loop may run a frame ahead and its frames take uneven times).
virtual uint32_t GetRefreshPeriodUs () const
 Microseconds between the panel's refreshes when each frame waits for one, so it is shown whole; 0 when frames are shown as they come.
virtual uint8_t * GetRenderBuffer (int32_t *width, int32_t *height)
 A buffer the display owns that the renderer can draw into directly, such as a DMA-capable buffer in fast internal RAM, saving a copy in Present.
virtual bool Initialize (int32_t width, int32_t height)=0
virtual bool IsInitialized () const =0
virtual void Present (const uint8_t *framebuffer, int width, int height, ColorFormat format)=0
 Shows the whole framebuffer.
virtual void PresentRegions (const uint8_t *framebuffer, int width, int height, ColorFormat format, const Rect *rects, int32_t count)
 Shows only rects of the framebuffer: framebuffer pixels, half-open, already clipped, possibly overlapping.
virtual bool ProcessEvents ()=0
 Handles platform events (window close, resize, ...).
virtual void RequestFullRefresh ()=0
 Makes the next present redraw the whole screen.
virtual void SetActiveUIOverlay (void *overlay)=0
virtual void SetBacklight (bool on)
 Turns the backlight on or off.
virtual void SetRefreshesPerFrame (uint32_t refreshes)
 How many refreshes each frame stays on screen: 1 at the panel's rate, 2 at half of it.
virtual void Shutdown ()=0
virtual bool SupportsPartialPresent () const
 True when PresentRegions() sends only the rectangles it is given.
virtual bool UpdateUIOverlay (void *overlay, int32_t x, int32_t y, int32_t width, int32_t height, const uint32_t *pixels)=0
virtual bool UpdateUIOverlayRGB565A8 (void *overlay, int32_t x, int32_t y, int32_t width, int32_t height, const uint8_t *rgb565a8Pixels)=0

Detailed Description

What a display package implements: setup, presenting frames, events and UI overlays.

The platform package loaded at runtime registers its display with Engine::SetDisplay(this, name); the engine holds only the pointer.

Constructor & Destructor Documentation

◆ ~IDisplay()

virtual Deki::IDisplay::~IDisplay ( )
virtualdefault

Member Function Documentation

◆ ClearActiveUIOverlay()

virtual void Deki::IDisplay::ClearActiveUIOverlay ( )
pure virtual

◆ CreateUIOverlay()

virtual void * Deki::IDisplay::CreateUIOverlay ( int32_t width,
int32_t height )
pure virtual

◆ DestroyUIOverlay()

virtual void Deki::IDisplay::DestroyUIOverlay ( void * overlay)
pure virtual

◆ GetColorFormat()

virtual ColorFormat Deki::IDisplay::GetColorFormat ( ) const
pure virtual

The pixel format this display takes.

With GetDisplaySize, it sets the framebuffer's size and format when the display is registered, so every target renders in its own screen's format and Present never converts.

◆ GetDisplaySize()

virtual void Deki::IDisplay::GetDisplaySize ( int32_t * width,
int32_t * height ) const
pure virtual

◆ GetFramesShown()

virtual bool Deki::IDisplay::GetFramesShown ( uint64_t * frames,
uint64_t * lastShownUs ) const
inlinevirtual

How many frames the panel has shown so far, and when the latest one went up (microseconds on the display's own monotonic clock), for a frame-rate counter: frames shown over the time between two readings is the rate the player sees, which timing the game's loop is not (the loop may run a frame ahead and its frames take uneven times).

False from a display that does not see its frames go up; a counter then has only the loop to time, and should say so.

◆ GetRefreshPeriodUs()

virtual uint32_t Deki::IDisplay::GetRefreshPeriodUs ( ) const
inlinevirtual

Microseconds between the panel's refreshes when each frame waits for one, so it is shown whole; 0 when frames are shown as they come.

The main loop then times frames to a whole number of refreshes: a game clock a little off the panel's (60.0 frames a second on a 60.2 Hz panel) would show a frame twice every few seconds, a stutter. Each frame also moves the game on by its whole number of refreshes, not the time the loop measured, so motion steps exactly with the panel.

◆ GetRenderBuffer()

virtual uint8_t * Deki::IDisplay::GetRenderBuffer ( int32_t * width,
int32_t * height )
inlinevirtual

A buffer the display owns that the renderer can draw into directly, such as a DMA-capable buffer in fast internal RAM, saving a copy in Present.

nullptr when there is none.

◆ Initialize()

virtual bool Deki::IDisplay::Initialize ( int32_t width,
int32_t height )
pure virtual

◆ IsInitialized()

virtual bool Deki::IDisplay::IsInitialized ( ) const
pure virtual

◆ Present()

virtual void Deki::IDisplay::Present ( const uint8_t * framebuffer,
int width,
int height,
ColorFormat format )
pure virtual

Shows the whole framebuffer.

Use FrameBufferBytes(format, ...) for its size rather than working out bytes per pixel.

◆ PresentRegions()

virtual void Deki::IDisplay::PresentRegions ( const uint8_t * framebuffer,
int width,
int height,
ColorFormat format,
const Rect * rects,
int32_t count )
inlinevirtual

Shows only rects of the framebuffer: framebuffer pixels, half-open, already clipped, possibly overlapping.

count 0 means nothing changed since the last present: a windowed display still redraws its window from the texture it holds, an LCD does nothing. The default sends the whole frame.

◆ ProcessEvents()

virtual bool Deki::IDisplay::ProcessEvents ( )
pure virtual

Handles platform events (window close, resize, ...).

Returns false when the application should exit.

◆ RequestFullRefresh()

virtual void Deki::IDisplay::RequestFullRefresh ( )
pure virtual

Makes the next present redraw the whole screen.

◆ SetActiveUIOverlay()

virtual void Deki::IDisplay::SetActiveUIOverlay ( void * overlay)
pure virtual

◆ SetBacklight()

virtual void Deki::IDisplay::SetBacklight ( bool on)
inlinevirtual

Turns the backlight on or off.

IPower calls it around sleep: off in OnBeforeSleep so the panel draws no current while the CPU is paused, on in OnScreenOn after waking. Displays without one (desktop windows) keep the default, which does nothing.

◆ SetRefreshesPerFrame()

virtual void Deki::IDisplay::SetRefreshesPerFrame ( uint32_t refreshes)
inlinevirtual

How many refreshes each frame stays on screen: 1 at the panel's rate, 2 at half of it.

The main loop sets it from the target frame rate, for a display that reports its refresh period. A display that shows frames on its own thread holds each one that long, so a frame finished a little early is not shown early and then followed by a long one, which is judder at a steady average. The default ignores it.

◆ Shutdown()

virtual void Deki::IDisplay::Shutdown ( )
pure virtual

◆ SupportsPartialPresent()

virtual bool Deki::IDisplay::SupportsPartialPresent ( ) const
inlinevirtual

True when PresentRegions() sends only the rectangles it is given.

A display that can address part of its panel or texture returns true and implements PresentRegions; otherwise the engine never calls it.

◆ UpdateUIOverlay()

virtual bool Deki::IDisplay::UpdateUIOverlay ( void * overlay,
int32_t x,
int32_t y,
int32_t width,
int32_t height,
const uint32_t * pixels )
pure virtual

◆ UpdateUIOverlayRGB565A8()

virtual bool Deki::IDisplay::UpdateUIOverlayRGB565A8 ( void * overlay,
int32_t x,
int32_t y,
int32_t width,
int32_t height,
const uint8_t * rgb565a8Pixels )
pure virtual

The documentation for this class was generated from the following file: