Skip to main content

More RPS UI interfaces

Five smaller interfaces, each with its own table and header. Acquire each one you use with rpsui::api::acquire, as in getting started. All except Registry take an owner token from the Framework interface.

Focused panels​

FocusedPanel.h, namespace rpsui::api::focused_panel.

registerPanel takes a Framework PanelRegistration and returns a panel handle. A focused panel keeps its submitted world pose, with no automatic separation from other panels, and must set FixedSize. It routes interaction only while the selected visible pointer is inside, and only that hand's stick is captured. A UI button press is drained on exit until release, without capturing the stick or dispatching a click to a different panel. Opening and focus changes require neutral before a click.

Submit poses and read state through the Framework interface, and retire the panel through the Cooperation interface. Contexts must survive CallbackBusy.

Passive panels​

PassivePanel.h, namespace rpsui::api::passive_panel.

registerPanel takes a Framework PanelRegistration and returns a panel handle. The panel is visual only: the host never hit-tests it, captures input for it, resizes it or separates its pose. It must set Transparent and FixedSize and provide a render callback. Submit poses through the Framework interface and retire callbacks through the Cooperation interface's safe unregister calls.

Number overlays​

NumberOverlay.h, namespace rpsui::api::number_overlay. Version 2.1 (RPS UI Framework 2.0.2; 2.1 adds label). A mod built for 2.0 keeps working.

Numbers the host draws itself. There is no consumer render callback or borrowed payload, and the host owns all resources; a render snapshot it already copied may finish after removal.

FunctionContract
registerOverlayCopy overlayId and displayName and return a handle.
submitSend a Presentation: pose in game units with width and height matching kAspect, value over the whole uint32 range, premultiplied opacity, color, open and style.
unregisterOverlayRemove the overlay.

Style::Plain draws one centered value. Style::Hud draws value over a divider over secondaryValue, right aligned in a condensed bold face, like the Fallout HUD ammo counter. Style::HudBracketed adds the HUD's bracket pair.

label (2.1) is a short UTF-8 text, terminated inside its 32 bytes and empty for none, drawn in the numbers' face, color and opacity with digits kLabelScale of the numbers' digit height. In Hud and HudBracketed it shares the column right of the rows with the cartridge: the cartridge stands beside the first row and the label beside the second, on its baseline. In Plain the number shrinks to kPlainLabelNumberFill of the panel height and moves to the panel's left edge, and the cartridge and then the label follow it. A label wider than the panel's remaining width shrinks alone. A 2.0 record (size of kPresentationSize20) has no label and draws as before. A consumer that needs labels requests minor 1; one that also runs with RPS UI Framework 2.0 requests minor 0 and sends labels only when the returned descriptor reports minor 1 or later.

Registry​

Registry.h, namespace rpsui::api::registry.

getPage is read-only discovery of every registered consumer and panel, with the current runtime budgets, and can be called from a control thread before the host is ready. Start both Query cursors at zero, pass the returned nextOwnerToken and nextPanelHandle on the next call, and stop when moreConsumers and morePanels are both zero.

Entries are ordered by monotonically increasing identity, not draw order, and removed identities are never reused. Each page is an atomic advisory copy. registryRevision increases only on registration and removal. If revisions differ between pages, a caller needing one membership census restarts on a later control tick and never spins.

World drawing​

WorldDraw.h, namespace rpsui::api::world_draw.

World drawing for gameplay indicators and developer diagnostics. Every position is game units in world space. Everything is drawn into both eyes after UI panels with the depth test off, so it stays visible through geometry. Text is anchored to a world point; there is no screen-positioned drawing. The host copies every array during the call and owns all GPU resources.

FunctionContract
submitReplace the owner's publication of spheres, lines, text and mesh instances. It stays for leaseFrames rendered frames (1 to kMaxLeaseFrames) unless replaced or cleared; republish every frame for continuous display. A publication above any per-owner capacity is rejected whole.
clearRemove the owner's publication. An empty publication does the same.
registerMeshCopy a triangle list in mesh-local game units. Registering an existing ID replaces its geometry. Instances naming an unknown ID are skipped.
releaseMeshRelease one mesh. Meshes otherwise belong to the owner until it unregisters.
setFrameCallbackReplace the owner's frame callback; null removes it. CallbackBusy means it is still running: retry until Ok before releasing its context.

A producer whose data is final only late in the frame, for example after the physics step, registers a frame callback and submits from it. The callback runs on the render thread once per drawn frame, before the host takes its snapshot. It may call submit, clear, registerMesh and releaseMesh for its own owner and must not call other RPS UI functions. Submitting from it with leaseFrames = 1 shows the data for exactly this frame. It must stay brief, because it delays the frame.

Complete public declarations: RPS_UI_Framework/FocusedPanel.h
RPS_UI_Framework/FocusedPanel.h
#pragma once
#include "Framework.h"

// Focused panels preserve the submitted world pose (no automatic separation),
// require FixedSize, and route interaction only while the selected visible
// pointer is inside. Only that hand's stick is captured. A UI button press is
// drained on exit until release, without capturing the stick or dispatching a
// click to a different panel. Opening and focus changes require neutral before
// a click. Use the Framework interface for poses and state and the Cooperation
// interface for safe retirement. Contexts must survive CallbackBusy.
#pragma pack(push, 8)
namespace rpsui::api::focused_panel
{
inline constexpr InterfaceId kInterfaceId = InterfaceId::FocusedPanel;
inline constexpr std::uint32_t kMajor = 2;
inline constexpr std::uint32_t kMinor = 0;

struct Api
{
static constexpr InterfaceId interfaceId = kInterfaceId;
static constexpr std::uint32_t majorVersion = kMajor;
static constexpr std::uint32_t minorVersion = kMinor;

Result(RPSUI_CALL* registerPanel)(std::uint64_t ownerToken, const framework::PanelRegistration* registration,
std::uint64_t* outPanelHandle) noexcept {};
};

static_assert(std::is_standard_layout_v<Api> && sizeof(Api) == 8);
}
#pragma pack(pop)
Complete public declarations: RPS_UI_Framework/PassivePanel.h
RPS_UI_Framework/PassivePanel.h
#pragma once
#include "Framework.h"

// Visual-only panels. The host never hit-tests these panels, captures input for
// them, resizes them or separates their poses. Require Transparent|FixedSize and
// a draw callback. Submit poses through the Framework interface; retire
// callbacks through the Cooperation interface's safe unregister calls.
#pragma pack(push, 8)
namespace rpsui::api::passive_panel
{
inline constexpr InterfaceId kInterfaceId = InterfaceId::PassivePanel;
inline constexpr std::uint32_t kMajor = 2;
inline constexpr std::uint32_t kMinor = 0;

struct Api
{
static constexpr InterfaceId interfaceId = kInterfaceId;
static constexpr std::uint32_t majorVersion = kMajor;
static constexpr std::uint32_t minorVersion = kMinor;

Result(RPSUI_CALL* registerPanel)(std::uint64_t ownerToken, const framework::PanelRegistration* registration,
std::uint64_t* outPanelHandle) noexcept {};
};

static_assert(std::is_standard_layout_v<Api> && sizeof(Api) == 8);
}
#pragma pack(pop)
Complete public declarations: RPS_UI_Framework/NumberOverlay.h
RPS_UI_Framework/NumberOverlay.h
#pragma once
#include "Framework.h"

// Numbers the host draws itself. No consumer render callback or borrowed
// payload: the host owns all resources; an already copied render snapshot may
// finish after removal. Uses a Framework owner token.
#pragma pack(push, 8)
namespace rpsui::api::number_overlay
{
inline constexpr InterfaceId kInterfaceId = InterfaceId::NumberOverlay;
inline constexpr std::uint32_t kMajor = 2;
inline constexpr std::uint32_t kMinor = 1;
inline constexpr float kAspect = 1024.0f / 480.0f;

// How the host lays out an overlay's numbers.
enum class Style : std::uint8_t
{
// One value in the default face, centered.
Plain = 0,
// The Fallout HUD ammo counter: value over a divider over
// secondaryValue, right aligned, in a condensed bold face.
Hud = 1,
// Hud inside the HUD's bracket pair: a top bar with end ticks down and
// a bottom bar with end ticks up.
HudBracketed = 2,
};

// 2.1: the label's digits are kLabelScale of the numbers' digit height.
// Plain with a label draws its number kPlainLabelNumberFill of the panel
// height (the share 2.0 Plain fills with 0.85), left aligned.
inline constexpr float kLabelScale = 0.62f;
inline constexpr float kPlainLabelNumberFill = 0.42f;

// A cartridge beside the number, in every style, for a consumer that knows
// what a weapon's chamber holds.
enum class ChamberMarker : std::uint8_t
{
None = 0,
// Hollow and dim: no round in the chamber.
Empty = 1,
// Solid: a round in the chamber.
Chambered = 2,
};

struct Registration
{
std::uint32_t size{ sizeof(Registration) };
std::uint32_t version{ kRecordVersion };
char overlayId[64]{};
char displayName[96]{};
};

struct Presentation
{
std::uint32_t size{ sizeof(Presentation) };
std::uint32_t version{ kRecordVersion };
std::uint64_t sequence{};
framework::PanelPose pose{}; // Game units. Width/height must match kAspect.
std::uint32_t value{}; // Entire uint32 range, including zero; no leading padding.
float opacity{ 0.55f }; // Premultiplied, 0..1; transparent background.
std::uint8_t open{};
std::uint8_t reservedBytes[3]{};
float color[3]{ 1.0f, 1.0f, 1.0f }; // Digit and frame color, 0..1 each.
std::uint32_t secondaryValue{}; // Hud styles only: the number below the divider.
Style style{ Style::Plain };
ChamberMarker chamber{ ChamberMarker::None };
std::uint8_t reservedStyle[2]{};
// 2.1: a short text drawn with the numbers in their face and color,
// UTF-8, terminated inside the array; empty for none. Hud styles: the
// label shares the chamber column right of the rows, beside the second
// row on its baseline, and the cartridge takes the first row only.
// Plain: the label follows the number (and cartridge) on its baseline.
// A label wider than the panel's remaining width shrinks alone; the
// numbers keep their size. A 2.0 record ends before this field.
char label[32]{};
};
inline constexpr std::uint32_t kPresentationSize20 = 104;

struct Api
{
static constexpr InterfaceId interfaceId = kInterfaceId;
static constexpr std::uint32_t majorVersion = kMajor;
static constexpr std::uint32_t minorVersion = kMinor;

Result(RPSUI_CALL* registerOverlay)(std::uint64_t ownerToken, const Registration* registration,
std::uint64_t* outHandle) noexcept {};
Result(RPSUI_CALL* submit)(std::uint64_t ownerToken, std::uint64_t handle, const Presentation* presentation) noexcept {};
Result(RPSUI_CALL* unregisterOverlay)(std::uint64_t ownerToken, std::uint64_t handle) noexcept {};
};

static_assert(std::is_standard_layout_v<Registration> && sizeof(Registration) == 168);
static_assert(std::is_standard_layout_v<Presentation> && sizeof(Presentation) == 136);
static_assert(offsetof(Presentation, value) == 72 && offsetof(Presentation, style) == 100 &&
offsetof(Presentation, chamber) == 101 && offsetof(Presentation, label) == kPresentationSize20);
static_assert(std::is_standard_layout_v<Api> && sizeof(Api) == 24);
}
#pragma pack(pop)
Complete public declarations: RPS_UI_Framework/Registry.h
RPS_UI_Framework/Registry.h
#pragma once
#include "Cooperation.h"

// Read-only discovery of every registered consumer and panel, with the current
// runtime budgets.
//
// Entries are ordered by monotonically increasing identity, not draw order.
// Start both cursors at zero; pass the returned cursors on the next call.
// Stop when both more flags are zero. Removed identities never get reused.
// Each page is an atomic advisory copy. If revisions differ, a caller needing
// one membership census restarts on a later control tick (never spin).
// Pose and input may change between pages even with identical revisions.
#pragma pack(push, 8)
namespace rpsui::api::registry
{
inline constexpr InterfaceId kInterfaceId = InterfaceId::Registry;
inline constexpr std::uint32_t kMajor = 2;
inline constexpr std::uint32_t kMinor = 0;
inline constexpr std::size_t kPageConsumers = 16;
inline constexpr std::size_t kPagePanels = 32;

struct Query
{
std::uint32_t size{ sizeof(Query) };
std::uint32_t version{ kRecordVersion };
std::uint64_t afterOwnerToken{}, afterPanelHandle{};
};

struct Page
{
std::uint32_t size{ sizeof(Page) };
std::uint32_t version{ kRecordVersion };
std::uint32_t consumerCapacity{}, panelCapacity{};
std::uint32_t inputSubscriberCapacity{}, reserved{};
std::uint32_t totalConsumers{}, totalPanels{};
std::uint32_t consumerCount{}, panelCount{};
// Increases only on registration/removal, not pose/input changes.
std::uint64_t registryRevision{};
std::uint64_t nextOwnerToken{}, nextPanelHandle{};
std::uint8_t moreConsumers{}, morePanels{};
std::uint8_t reservedBytes[6]{};
cooperation::ConsumerDirectoryEntry consumers[kPageConsumers]{};
cooperation::PanelDirectoryEntry panels[kPagePanels]{};
};

struct Api
{
static constexpr InterfaceId interfaceId = kInterfaceId;
static constexpr std::uint32_t majorVersion = kMajor;
static constexpr std::uint32_t minorVersion = kMinor;

// Callable from a control thread, including before host readiness.
Result(RPSUI_CALL* getPage)(const Query* query, Page* page) noexcept {};
};

static_assert(std::is_standard_layout_v<Query> && sizeof(Query) == 24);
static_assert(std::is_standard_layout_v<Page>);
static_assert(std::is_standard_layout_v<Api> && sizeof(Api) == 8);
}
#pragma pack(pop)
Complete public declarations: RPS_UI_Framework/WorldDraw.h
RPS_UI_Framework/WorldDraw.h
#pragma once
#include "Abi.h"

// World drawing for gameplay indicators and developer diagnostics. Every
// position is game units in world space. Everything is drawn into both eyes
// after UI panels, with the depth test off, so it stays visible through
// geometry. Text is anchored to a world point; there is no screen-positioned
// drawing. Uses a Framework owner token. The host copies every array during the
// call and owns all GPU resources; nothing is borrowed.
//
// A producer whose data is only final late in the frame (for example after the
// physics step) registers a frame callback and submits from it.
#pragma pack(push, 8)
namespace rpsui::api::world_draw
{
inline constexpr InterfaceId kInterfaceId = InterfaceId::WorldDraw;
inline constexpr std::uint32_t kMajor = 2;
inline constexpr std::uint32_t kMinor = 0;

// Per-owner capacities. A publication above any capacity is rejected whole.
inline constexpr std::uint32_t kMaxSpheres = 256;
inline constexpr std::uint32_t kMaxLines = 32768;
inline constexpr std::uint32_t kMaxTexts = 256;
inline constexpr std::uint32_t kMaxMeshInstances = 2048;
inline constexpr std::uint32_t kMaxMeshes = 4096;
inline constexpr std::uint32_t kMaxMeshVertices = 65535;
inline constexpr std::uint32_t kMaxMeshIndices = 393216;
inline constexpr std::uint64_t kMaxMeshBytes = 64ull * 1024 * 1024;
inline constexpr std::uint32_t kMaxLeaseFrames = 120;
inline constexpr std::uint32_t kTextCapacity = 128;

enum class Fill : std::uint32_t
{
Solid = 0,
Wire = 1,
};

struct Sphere
{
float center[3]{};
float radius{ 1.0f };
float color[4]{ 1.0f, 1.0f, 1.0f, 1.0f };
Fill fill{ Fill::Solid };
std::uint32_t reserved[3]{};
};

struct Line
{
float start[3]{};
float end[3]{};
float color[4]{ 1.0f, 1.0f, 1.0f, 1.0f };
};

// 5x7 block glyphs: A-Z, 0-9 and - + = . , : / ( ). Lower case draws as
// upper case; other characters leave a blank cell. Each eye projects the
// anchor and draws the glyphs at that point, offset and sized in eye-texture
// pixels, kept inside the eye.
struct Text
{
char text[kTextCapacity]{};
float anchor[3]{};
float offsetPixels[2]{ 20.0f, 0.0f };
float pixelSize{ 3.0f };
float color[4]{ 1.0f, 1.0f, 1.0f, 1.0f };
};

// transform uses the row-vector convention (position * transform), with the
// translation in elements 12..14, as DirectX::XMFLOAT4X4 stores it.
struct MeshInstance
{
std::uint64_t meshId{ 0 };
float transform[16]{ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 };
float color[4]{ 1.0f, 1.0f, 1.0f, 1.0f };
Fill fill{ Fill::Wire };
std::uint32_t reserved{};
};

// Triangle list in mesh-local game units. positions holds vertexCount xyz
// triples; every index must be below vertexCount.
struct Mesh
{
std::uint32_t size{ sizeof(Mesh) };
std::uint32_t version{ kRecordVersion };
const float* positions{ nullptr };
std::uint32_t vertexCount{ 0 };
std::uint32_t indexCount{ 0 };
const std::uint32_t* indices{ nullptr };
};

// Replaces the owner's previous publication. It stays visible for
// leaseFrames rendered frames (1..kMaxLeaseFrames) unless it is replaced or
// cleared; republish every frame for continuous display. An empty
// publication clears.
struct Publication
{
std::uint32_t size{ sizeof(Publication) };
std::uint32_t version{ kRecordVersion };
std::uint32_t leaseFrames{ 2 };
std::uint32_t sphereCount{ 0 };
std::uint32_t lineCount{ 0 };
std::uint32_t textCount{ 0 };
std::uint32_t meshInstanceCount{ 0 };
std::uint32_t reserved{ 0 };
const Sphere* spheres{ nullptr };
const Line* lines{ nullptr };
const Text* texts{ nullptr };
const MeshInstance* meshInstances{ nullptr };
};

// Called on the render thread once per drawn frame, before the host takes
// its snapshot. The callback may call submit, clear, registerMesh and
// releaseMesh for its own owner; it must not call other RPS UI functions.
// Submitting from it with leaseFrames = 1 shows the data for exactly this
// frame. It must stay brief: it delays the frame.
using FrameCallback = void(RPSUI_CALL*)(void* context, std::uint64_t frame) noexcept;

struct Api
{
static constexpr InterfaceId interfaceId = kInterfaceId;
static constexpr std::uint32_t majorVersion = kMajor;
static constexpr std::uint32_t minorVersion = kMinor;

Result(RPSUI_CALL* submit)(std::uint64_t ownerToken, const Publication* publication) noexcept {};
Result(RPSUI_CALL* clear)(std::uint64_t ownerToken) noexcept {};
// Meshes belong to the owner until released or the owner unregisters.
// Registering an existing id replaces its geometry. Instances naming an
// unknown id are skipped.
Result(RPSUI_CALL* registerMesh)(std::uint64_t ownerToken, std::uint64_t meshId, const Mesh* mesh) noexcept {};
Result(RPSUI_CALL* releaseMesh)(std::uint64_t ownerToken, std::uint64_t meshId) noexcept {};
// Replaces the owner's frame callback; null removes it. After the call
// returns the previous callback is not started again. CallbackBusy
// means it is still running: retry until Ok before releasing its
// context. An owner with a callback must unregister until Ok as well.
Result(RPSUI_CALL* setFrameCallback)(std::uint64_t ownerToken, FrameCallback callback, void* context) noexcept {};
};

static_assert(std::is_standard_layout_v<Sphere> && sizeof(Sphere) == 48);
static_assert(std::is_standard_layout_v<Line> && sizeof(Line) == 40);
static_assert(std::is_standard_layout_v<Text> && sizeof(Text) == 168);
static_assert(std::is_standard_layout_v<MeshInstance> && sizeof(MeshInstance) == 96);
static_assert(std::is_standard_layout_v<Mesh> && sizeof(Mesh) == 32);
static_assert(std::is_standard_layout_v<Publication> && sizeof(Publication) == 64);
static_assert(std::is_standard_layout_v<Api> && sizeof(Api) == 40);
}
#pragma pack(pop)