Difference between revisions of "SDK 6.3/C++/GFX Engine"

From WowWiki
Jump to navigation Jump to search
(C++ (WASM) and Rust API reference for SDK 6.3 (WowBot))
 
(Restore enriched reference + detailed Scramble/Splashscreen (WowBot))
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{notice|'''Official WOWCube SDK documentation.''' SDK 6.3, C++ (WebAssembly) API. Signatures are extracted from the canonical SDK headers shipped with the WOWCube Development Kit; the headers remain authoritative.}}
+
{{notice|'''Official WOWCube SDK documentation.''' SDK 6.3, C++ (WebAssembly) API. Signatures are extracted from the canonical SDK headers; usage notes and examples come from the official sample projects shipped with the WOWCube Development Kit. The headers remain authoritative.}}
  
 
{{SDK 6.3 nav}}
 
{{SDK 6.3 nav}}
 
  
 
''← [[SDK 6.3]] · C++ / GFX Engine''
 
''← [[SDK 6.3]] · C++ / GFX Engine''
  
The object-oriented retained layer of the C++ SDK (namespace <code>Cubios</code>): a scene graph with sprites, text, backgrounds, sounds and math primitives. It sits on top of the [[SDK 6.3/C++/Native API|native ABI]] and is driven by the [[SDK 6.3/C++/Application|Application framework]]. Public signatures below are extracted from the SDK 6.3 headers.
+
The object-oriented retained layer of the C++ SDK (namespace <code>Cubios</code>): a scene graph with sprites, text, backgrounds, sounds and math primitives. It sits on top of the [[SDK 6.3/C++/Native API|native ABI]] and is driven by the [[SDK 6.3/C++/Application|Application framework]].
  
=== Scene ===
+
== The canonical pattern ==
  
The retained scene graph owned by every <code>Application</code> (field <code>app.Scene</code>). Holds scene objects and renders them per screen.
+
Every official sample follows the same lifecycle:
  
Public interface (<code>Scene.h</code>):
+
# '''Create''' objects once at startup and register them in the application's <code>Scene</code> under integer IDs (usually an <code>enum</code>).
 +
# '''Render''' every frame: for each of the module's three <code>Screen</code>s open a <code>Begin()/End()</code> block and <code>Add()</code> the scene objects you want on that screen, chaining setters.
  
Scene();
+
Resource creation (from the official ''Network/Messaging2'' sample):
virtual ~Scene();
 
uint32_t CreateObject(SceneObject* obj);
 
bool CreateObjectWithID(uint32_t id, SceneObject* obj);
 
uint32_t CreateSound(Sound* obj);
 
bool CreateSoundWithID(uint32_t id, Sound* obj);
 
bool DisposeObjectWithID(uint32_t id);
 
bool DisposeSoundWithID(uint32_t id);
 
void DisposeAllObjects();
 
void Play(uint32_t id, uint8_t volume);
 
  
=== SceneObject ===
+
void Messaging2::InitializeResources()
 +
{
 +
    this->Scene.CreateObjectWithID(GfxObjects::idle, new Sprite("idle.png", Transform(120,120,0)));
 +
    this->Scene[GfxObjects::idle]->Color.Set(0xFFFFFFFF);
 +
    this->Scene.CreateObjectWithID(GfxObjects::background, new Sprite("background.png", Transform(120,120,0)));
 +
    this->SetTimer(Timers::mainTimer, 30);
 +
}
  
Base class of every visual object in the scene graph. Provides position, rotation, scale, opacity, z-order, per-screen placement and lifecycle.
+
Per-frame rendering (from the official ''GFX Engine Sample 1 — Twinkle''):
  
Public interface (<code>SceneObject.h</code>):
+
void Twinkle::on_Render(std::array<Cubios::Screen, 3>& screens)
 +
{
 +
    Background* bkg = (Background*)this->Scene[Sprites::Clear];
 +
    for(auto it = screens.begin(); it != screens.end(); ++it)
 +
    {
 +
        it->Begin(TOPOLOGY_orientation_mode_t::ORIENTATION_MODE_GRAVITY, true);
 +
            it->Add(bkg->SetColor(0xFF000044));
 +
            if(TOPOLOGY_isAssembled()==1)
 +
            {
 +
                switch(it->Position())  // screen's place on the cube face
 +
                {
 +
                    case 0: it->Add(this->Scene[Sprites::MyUfo])->SetPosition(pos.X-280, pos.Y-280); break;
 +
                    case 1: it->Add(this->Scene[Sprites::MyUfo])->SetPosition(pos.X,    pos.Y-280); break;
 +
                    case 2: it->Add(this->Scene[Sprites::MyUfo])->SetPosition(pos.X,    pos.Y);    break;
 +
                }
 +
            }
 +
        it->End();
 +
    }
 +
}
  
SceneObject():Parent(nullptr),ScreenAngle(0),Visible(true),InBegin(false);
+
'''Units and conventions''' (as used across all official samples): screens are 240×240 px; colors are packed '''0xAARRGGBB''' (<code>Math::Color</code>); <code>Transform</code> rotation is in degrees, scale is in percent (100 = 1:1); all <code>Set*</code> methods return <code>SceneObject*</code>, so calls chain: <code>screen.Add(obj)->SetPosition(x,y)->SetAf(0.5f)</code>. To make one logical object span several screens of a face, samples draw it on each screen with a ±280 px offset per screen position (as above).
virtual ~SceneObject();
 
virtual void Render() = 0;
 
SceneObject* SetColor(uint32_t v);
 
SceneObject* SetA(uint8_t a);
 
SceneObject* SetAf(float a);
 
SceneObject* SetAfSafe(float a);
 
SceneObject* SetR(uint8_t r);
 
SceneObject* SetG(uint8_t g);
 
SceneObject* SetB(uint8_t b);
 
SceneObject* SetVisible(bool v);
 
SceneObject* SetTransform(const Math::Transform& t);
 
SceneObject* SetPosition(const Math::Vec2& p);
 
SceneObject* SetPosition(float x, float y);
 
SceneObject* SetRotation(int r);
 
SceneObject* SetMirroring(unsigned int m);
 
SceneObject* SetScale(unsigned int s);
 
SceneObject* SetScale(unsigned int sx, unsigned int sy);
 
SceneObject* SetXScale(unsigned int s);
 
SceneObject* SetYScale(unsigned int s);
 
const Math::Vec2 ScreenPosition();
 
if(this->Parent==nullptr) return pos;
 
switch(ScreenAngle);
 
pos.Set(this->Transform.Position.X,this->Transform.Position.Y);
 
pos.Set(240-this->Transform.Position.Y,this->Transform.Position.X);
 
pos.Set(240-this->Transform.Position.X,240-this->Transform.Position.Y);
 
pos.Set(this->Transform.Position.Y,240-this->Transform.Position.X);
 
SceneObject* Move(const Math::Vec2& v);
 
SceneObject* Move(float dx, float dy);
 
if(this->Parent==nullptr) return this;
 
if(!this->InBegin);
 
LOG_w("SceneObject: Move() can only be called within Begin/End block!\n");
 
  
=== Screen ===
+
== Scene ==
  
One of the three displays of the current module; passed to <code>on_Render()</code> / <code>on_PhysicsTick()</code>. Render target selector.
+
The retained scene graph owned by every <code>Application</code> (field <code>app.Scene</code>). It is an ID-addressed registry of objects and sounds; it owns them and disposes them for you.
  
Public interface (<code>Screen.h</code>):
+
; <code>uint32_t CreateObject(SceneObject* obj);</code>
 +
: Register an object; returns its auto-assigned ID. The scene takes ownership.
 +
; <code>bool CreateObjectWithID(uint32_t id, SceneObject* obj);</code>
 +
: Register under an explicit ID (usually an <code>enum</code> value). Fails (returns <code>false</code>) if the ID is taken. ''The most common way to build a scene in the official samples.''
 +
; <code>uint32_t CreateSound(Sound* obj);</code> / <code>bool CreateSoundWithID(uint32_t id, Sound* obj);</code>
 +
: Same, for [[#Sound and SoundCollection|sounds]].
 +
; <code>SceneObject* operator[](uint32_t);</code>
 +
: Look an object up by ID: <code>this->Scene[Sprites::MyUfo]</code>.
 +
; <code>bool DisposeObjectWithID(uint32_t id);</code> / <code>bool DisposeSoundWithID(uint32_t id);</code> / <code>void DisposeAllObjects();</code>
 +
: Remove and delete objects/sounds.
 +
; <code>void Play(uint32_t id, uint8_t volume);</code>
 +
: Play a registered sound by ID.
  
Screen(uint8_t id);
+
== SceneObject ==
void SetOrientation(TOPOLOGY_orientation_mode_t mode);
 
uint8_t Position() const;
 
TOPOLOGY_orientation_t Direction() const;
 
uint8_t OppositeFace() const;
 
uint8_t Face() const;
 
inline uint8_t ID() const;
 
inline uint32_t Angle() const;
 
SceneObject* Add(SceneObject* obj);
 
SceneObject* AddCopy(SceneObject* obj);
 
void Begin(TOPOLOGY_orientation_mode_t mode = Cubios::ORIENTATION_MODE_MENU,bool autorotation = false);
 
void End();
 
inline bool IsAutorotation();
 
  
=== Object ===
+
Base class of every visual object. Holds a <code>Math::Transform</code>, a <code>Math::Color</code> and a <code>Visible</code> flag. All setters are '''chainable''' (return <code>SceneObject*</code>).
  
Minimal reference-counted base class for engine resources.
+
; <code>virtual void Render() = 0;</code>
 +
: Implemented by each concrete object; called by the engine when the object was <code>Add()</code>-ed to a screen in the current frame.
 +
; <code>SetPosition(float x, float y)</code> / <code>SetPosition(const Math::Vec2&)</code> / <code>SetTransform(const Math::Transform&)</code>
 +
: Place the object (240×240 screen space). ''The most-used call in the official samples.''
 +
; <code>SetRotation(int r)</code>
 +
: Rotation in degrees; normalized into 0–359 (negative values allowed).
 +
; <code>SetScale(unsigned s)</code> / <code>SetScale(sx, sy)</code> / <code>SetXScale(s)</code> / <code>SetYScale(s)</code>
 +
: Scale in percent (100 = original size).
 +
; <code>SetMirroring(unsigned m)</code>
 +
: Mirror mode (<code>GFX_mirror_t</code>: BLANK/X/Y/XY).
 +
; <code>SetColor(uint32_t argb)</code> / <code>SetR/SetG/SetB(uint8_t)</code> / <code>SetA(uint8_t)</code> / <code>SetAf(float)</code> / <code>SetAfSafe(float)</code>
 +
: Tint/opacity. <code>SetAf</code> takes 0.0–1.0; <code>SetAfSafe</code> clamps out-of-range values (added in SDK 5.1).
 +
; <code>SetVisible(bool)</code>
 +
: Hide without removing from the scene.
 +
; <code>const Math::Vec2 ScreenPosition();</code>
 +
: The object's position converted to physical-screen space, taking the screen's current rotation angle (0/90/180/270°) into account.
 +
; <code>Move(float dx, float dy)</code> / <code>Move(const Math::Vec2&)</code>
 +
: Screen-angle-aware relative move. '''Only valid inside a <code>Screen::Begin()/End()</code> block''' — otherwise it logs a warning and does nothing.
  
Public interface (<code>Object.h</code>):
+
Public fields: <code>Math::Transform Transform; Math::Color Color; bool Visible;</code>
  
Object();
+
== Screen ==
virtual ~Object();
 
inline void SetId(int16_t id);
 
  
=== Gfx::Background ===
+
One of the three displays of the current module; an array <code>std::array&lt;Screen, 3&gt;</code> is passed to <code>on_Render()</code> / <code>on_PhysicsTick()</code>.
  
Full-screen background image object.
+
; <code>void Begin(TOPOLOGY_orientation_mode_t mode = ORIENTATION_MODE_MENU, bool autorotation = false);</code> / <code>void End();</code>
 +
: Open/close the frame block for this screen. <code>mode</code> selects the orientation reference (MENU / GRAVITY / SPLASH); with <code>autorotation = true</code> content is auto-rotated as the cube is turned (samples use <code>ORIENTATION_MODE_GRAVITY, true</code>).
 +
; <code>SceneObject* Add(SceneObject* obj);</code>
 +
: Queue a scene object for rendering on this screen this frame; returns the object for chaining.
 +
; <code>SceneObject* AddCopy(SceneObject* obj);</code>
 +
: Queue an independent ''copy'' — the standard way to draw the same object several times with different positions in one frame (heavily used in the samples).
 +
; <code>uint8_t ID();</code>
 +
: Physical display index — pass to native calls such as <code>MS_getFaceAccelX(screen.ID())</code>.
 +
; <code>uint8_t Position();</code>
 +
: The screen's place on its cube face (see the render sample above — used to compute cross-screen offsets).
 +
; <code>uint8_t Face();</code> / <code>uint8_t OppositeFace();</code> / <code>TOPOLOGY_orientation_t Direction();</code>
 +
: Topology of the screen: which face it belongs to, the opposite face, and the facing direction (UP/DOWN/FRONT/…).
 +
; <code>void SetOrientation(TOPOLOGY_orientation_mode_t mode);</code> / <code>uint32_t Angle();</code> / <code>bool IsAutorotation();</code>
 +
: Orientation control and current rotation angle of the content.
  
Public interface (<code>Gfx/Background.h</code>):
+
== Gfx::Sprite ==
  
Background(uint32_t color);
+
Static image sprite bound to an image asset by file name (from the app's packed <code>assets/</code>).
Background(uint8_t R, uint8_t G, uint8_t B);
 
Background(uint8_t R, uint8_t G, uint8_t B, uint8_t A);
 
virtual ~Background();
 
void Render() override;
 
Cubios::SceneObject* SetColor(uint32_t color);
 
Cubios::SceneObject* SetColor(uint8_t R, uint8_t G, uint8_t B);
 
Cubios::SceneObject* SetColor(uint8_t R, uint8_t G, uint8_t B, uint8_t A);
 
 
 
=== Gfx::Sprite ===
 
 
 
Static image sprite bound to an image asset by name.
 
 
 
Public interface (<code>Gfx/Sprite.h</code>):
 
  
 +
Sprite(std::string name);
 +
Sprite(std::string name, float x, float y);
 
  Sprite(std::string name, const Cubios::Math::Transform& t);
 
  Sprite(std::string name, const Cubios::Math::Transform& t);
Sprite(std::string name, float x, float y);
 
Sprite(std::string name);
 
 
  Sprite(const Sprite& sprite);
 
  Sprite(const Sprite& sprite);
virtual ~Sprite();
 
 
  void Render() override;
 
  void Render() override;
  
=== Gfx::AnimatedSprite ===
+
Typical use: <code>new Sprite("idle.png", Transform(120,120,0))</code> — center of a 240×240 screen.
 
 
Frame-animated sprite.
 
  
Public interface (<code>Gfx/AnimatedSprite.h</code>):
+
== Gfx::Background ==
  
AnimatedSprite(std::vector<std::string>& names, const Cubios::Math::Transform& t);
+
Full-screen fill. <code>Background(uint32_t argb)</code> or <code>Background(R,G,B[,A])</code>; recolor at render time via <code>SetColor(...)</code> (see the Twinkle sample above — one shared background object recolored per screen).
AnimatedSprite(std::vector<std::string>& names, float x, float y);
 
AnimatedSprite(std::vector<std::string>& names);
 
AnimatedSprite(std::string name,std::string extension, int16_t firstFrame, int16_t lastFrame, const Cubios::Math::Transform& t);
 
AnimatedSprite(std::string name,std::string extension, int16_t firstFrame, int16_t lastFrame, float x, float y);
 
AnimatedSprite(std::string name,std::string extension, int16_t firstFrame, int16_t lastFrame);
 
AnimatedSprite(const AnimatedSprite& sprite);
 
AnimatedSprite(Cubios::Gfx::SpriteAtlas<Cubios::Gfx::SpriteAtlasElement>* atlas, const Cubios::Math::Transform& t);
 
AnimatedSprite(Cubios::Gfx::SpriteAtlas<Cubios::Gfx::SpriteAtlasElement>* atlas, float x, float y);
 
AnimatedSprite(Cubios::Gfx::SpriteAtlas<Cubios::Gfx::SpriteAtlasElement>* atlas);
 
virtual ~AnimatedSprite();
 
void Render() override;
 
int16_t Tick(uint32_t dt);
 
Cubios::SceneObject* SetFrame(int16_t frameNumber);
 
Cubios::SceneObject* SetPlaybackSpeed(int16_t speed);
 
Cubios::SceneObject* SetPlaybackMode(playbackMode_t mode);
 
int16_t PrevFrame();
 
int16_t NextFrame();
 
  
=== Gfx::SpriteAtlas ===
+
== Gfx::Text ==
  
Sprite atlas: a sheet of sub-images rendered via <code>SpriteAtlasElement</code>. Added in SDK 6.2.
+
Text object.
  
Public interface (<code>Gfx/SpriteAtlas.h</code>):
 
 
SpriteAtlas(std::string name, Cubios::Scene* scene);
 
virtual ~SpriteAtlas();
 
bool AddSprite(uint32_t id, const Cubios::Math::Rect2& rc);
 
bool RemoveSprite(uint32_t id);
 
T* Get(uint32_t ind);
 
inline size_t Count();
 
inline std::vector<uint32_t>* ElementsInsertionOrder();
 
 
=== Gfx::SpriteAtlasElement ===
 
 
One element (sub-rectangle) of a <code>SpriteAtlas</code>.
 
 
Public interface (<code>Gfx/SpriteAtlas.h</code>):
 
 
SpriteAtlasElement(SpriteAtlasBase* host, const Cubios::Math::Rect2& rc);
 
virtual ~SpriteAtlasElement();
 
void Render() override;
 
virtual SpriteAtlasElement* Copy();
 
inline Cubios::Math::Rect2* Rect();
 
 
=== Gfx::Text ===
 
 
Text object with scale, alignment and color.
 
 
Public interface (<code>Gfx/Text.h</code>):
 
 
Text(std::string text, const Cubios::Math::Transform& t, uint32_t fontSize, const Cubios::Math::Color& color, Cubios::text_align_t al = Cubios::text_align_t::TEXT_ALIGN_CENTER);
 
Text(std::string text, const Cubios::Math::Transform& t, uint32_t fontSize = 10, Cubios::text_align_t al = Cubios::text_align_t::TEXT_ALIGN_CENTER);
 
 
  Text(std::string text, float x, float y, uint32_t fontSize = 10);
 
  Text(std::string text, float x, float y, uint32_t fontSize = 10);
  Text(std::string text, float x, float y, uint32_t fontSize, const Cubios::Math::Color& color);
+
  Text(std::string text, float x, float y, uint32_t fontSize, const Math::Color& color);
  virtual ~Text();
+
  Text(std::string text, const Math::Transform& t, uint32_t fontSize, const Math::Color& color,
void Render() override;
+
      text_align_t al = TEXT_ALIGN_CENTER);
Cubios::SceneObject* SetContent(std::string text);
 
Cubios::SceneObject* FormatContent(char const* format,...);
 
Cubios::SceneObject* SetFontSize(uint32_t fontSize);
 
 
 
=== Gfx::QRCode ===
 
 
 
QR-code object rendered on screen. Added in SDK 6.0.
 
 
 
Public interface (<code>Gfx/QRCode.h</code>):
 
 
 
QRCode(std::string data, const Cubios::Math::Transform& t);
 
QRCode(std::string data, float x, float y);
 
QRCode(std::string data, const Cubios::Math::Transform& t, u32_t size);
 
QRCode(std::string data, float x, float y, u32_t size);
 
QRCode(const QRCode& qr);
 
virtual ~QRCode();
 
Cubios::SceneObject* SetSize(u32_t size);
 
Cubios::SceneObject* SetColor(const Math::Color& color);
 
Cubios::SceneObject* SetBackgroundColor(const Math::Color& color);
 
Cubios::SceneObject* SetData(std::string data);
 
void Render() override;
 
 
 
=== Gfx::OffscreenRenderTarget ===
 
 
 
Offscreen render target (baked image) usable as a scene object.
 
 
 
Public interface (<code>Gfx/OffscreenRenderTarget.h</code>):
 
 
 
OffscreenRenderTarget(u32_t width, u32_t height, Cubios::GFX_PixelFormat_t format);
 
virtual ~OffscreenRenderTarget();
 
Cubios::SceneObject* Add(Cubios::SceneObject* obj);
 
Cubios::SceneObject* AddCopy(Cubios::SceneObject* obj);
 
void Begin(bool overwrite=false);
 
void End();
 
void Render() override;
 
virtual void RenderLayer(renderLayerOrder_t order);
 
 
 
=== Sound ===
 
 
 
A sound asset; play, stop and query state.
 
 
 
Public interface (<code>Sound.h</code>):
 
 
 
explicit Sound(const std::string& name);
 
~Sound();
 
void Play(uint8_t volume = 100);
 
static void Stop();
 
static bool IsPlaying();
 
 
 
=== SoundCollection ===
 
 
 
A set of sounds with random playback helpers. Added in SDK 6.2.
 
 
 
Public interface (<code>Sound.h</code>):
 
 
 
SoundCollection(std::vector<std::string>& names);
 
SoundCollection(std::vector<Cubios::Sound*>& sounds);
 
virtual ~SoundCollection();
 
bool PlayRandomSound(uint8_t volume = 100, bool stopCurrent = true);
 
bool RepeatRandomSounds(uint8_t volume, int delayMin, int delayMax, int deltaTime);
 
void Stop();
 
bool IsPlaying();
 
 
 
=== NetworkMessage ===
 
 
 
Bit-packed serializer for inter-module messages (write/read ints, signed ints, floats).
 
 
 
Public interface (<code>NetworkMessage.h</code>):
 
 
 
NetworkMessage(uint8_t* data=NULL,int length=MESSAGE_SIZE_MAX);
 
virtual ~NetworkMessage();
 
void Print();
 
void WriteInt(int value, int bits);
 
void WriteByte(uint8_t value);
 
void WriteSignedInt(int value, int bits);
 
void WriteBool(bool value);
 
void WriteFloat(float value);
 
int ReadInt(int bits);
 
int ReadSignedInt(int bits);
 
uint8_t ReadByte();
 
bool ReadBool();
 
float ReadFloat();
 
uint8_t* GetData(int& length);
 
void SetData(uint8_t* data, int length);
 
inline void Reset(bool zero=false);
 
 
 
=== SaveMessage ===
 
 
 
Serializer for persistent state (used with <code>SaveState()</code> / <code>LoadState()</code>). Added in SDK 6.0.
 
  
Public interface (<code>SaveMessage.h</code>):
+
; <code>SetContent(std::string)</code> / <code>FormatContent(const char* fmt, ...)</code>
 +
: Replace the text; <code>FormatContent</code> is printf-style — handy for scores/counters.
 +
; <code>SetFontSize(uint32_t)</code>
 +
: Change size. Alignment via the public <code>Alignment</code> field (<code>text_align_t</code>, 9 anchors).
  
SaveMessage(uint8_t* data=NULL,int length=GAME_SAVE_SIZE);
+
== Gfx::AnimatedSprite ==
virtual ~SaveMessage();
 
void Print();
 
void WriteInt(int value, int bits);
 
void WriteByte(uint8_t value);
 
void WriteSignedInt(int value, int bits);
 
void WriteBool(bool value);
 
void WriteFloat(float value);
 
int ReadInt(int bits);
 
int ReadSignedInt(int bits);
 
uint8_t ReadByte();
 
bool ReadBool();
 
float ReadFloat();
 
uint8_t* GetData(int& length);
 
void SetData(uint8_t* data, int length);
 
inline void Reset(bool zero=false);
 
  
=== Scramble ===
+
Frame-animated sprite. Three ways to construct: an explicit list of asset names; a name pattern (<code>name + frameNumber + extension</code>) with a first/last frame range; or a [[#Gfx::SpriteAtlas|SpriteAtlas]].
  
Cube-scramble helper. Added in SDK 6.0.
+
; <code>int16_t Tick(uint32_t dt);</code>
 +
: Advance the animation; call from <code>on_Tick(time, dt)</code> for every animated sprite. Returns the current frame.
 +
; <code>SetPlaybackMode(playbackMode_t)</code>
 +
: <code>Loop</code> (wrap around), <code>Bounce</code> (ping-pong), <code>Set</code> (manual frame control).
 +
; <code>SetPlaybackSpeed(int16_t)</code> / <code>SetFrame(int16_t)</code> / <code>NextFrame()</code> / <code>PrevFrame()</code>
 +
: Speed and manual frame stepping.
  
Public interface (<code>Scramble.h</code>):
+
== Gfx::SpriteAtlas ==
  
Scramble();
+
A sprite sheet: one image asset cut into sub-rectangles, each rendered by a <code>SpriteAtlasElement</code> registered in the scene. Added in SDK 6.2 — saves memory versus per-frame images.
~Scramble();
 
void StartScramble(uint8_t twistsCount);
 
void VirtualTwist(uint8_t screen, uint8_t direction);
 
virtual void on_BeforeTwist() = 0;
 
virtual void on_MappingChanged(uint8_t moduleTo, uint8_t screenTo, uint8_t moduleFrom, uint8_t screenFrom) = 0;
 
virtual void on_Twist(const Cubios::TOPOLOGY_twistInfo_t twist) = 0;
 
  
=== Splashscreen ===
+
SpriteAtlas<SpriteAtlasElement> atlas("sheet.png", &this->Scene);
 +
atlas.AddSprite(MyIds::run0, Math::Rect2(0,  0, 64, 64));
 +
atlas.AddSprite(MyIds::run1, Math::Rect2(64,  0, 64, 64));
  
Standard splash screen with leaderboard support (reworked in SDK 6.2).
+
; <code>bool AddSprite(uint32_t id, const Math::Rect2& rc);</code>
 +
: Create an element for sub-rectangle <code>rc</code> and register it in the scene under <code>id</code> (fails if the ID is taken).
 +
; <code>T* Get(uint32_t)</code> / <code>T* operator[](uint32_t)</code> / <code>size_t Count()</code> / <code>ElementsInsertionOrder()</code>
 +
: Element access. <code>SpriteAtlasElement</code> itself is a normal <code>SceneObject</code> (position/scale/color) plus <code>Rect()</code> and <code>Copy()</code>. An atlas can also feed an [[#Gfx::AnimatedSprite|AnimatedSprite]].
  
Public interface (<code>Splashscreen.h</code>):
+
== Gfx::OffscreenRenderTarget ==
  
Splashscreen(Cubios::Application *app, SplsParms::e_LeadersDataType dataType);
+
Render-to-texture: draw objects into an offscreen buffer once, then use the result as a single scene object (a "baked image").
~Splashscreen();
 
virtual void Render(Cubios::Screen* screen);
 
virtual void Tick(uint32_t currentTime, uint32_t deltaTime);
 
uint32_t GetPersonalBest();
 
void SetRecord(uint32_t value);
 
void SetNamedValue(uint8_t idx, std::string name, uint32_t value, SplsParms::e_LeadersDataType type = SplsParms::e_LeadersDataType::typeNumber);
 
void SetSeparator(std::string s);
 
void SetLabel(SplsParms::e_LabelTypes idx, std::string text);
 
void SetApplicationName(std::string name);
 
void SetLeaderBoardTable(SplsParms::e_LeaderBoardType type);
 
void SetLeaderBoardTable(uint32_t (&lbTable)[TOPOLOGY_FACES_MAX][TOPOLOGY_POSITIONS_MAX]);
 
void SetPlaybackSpeed(SplsParms::e_LabelTypes idx, uint32_t speed);
 
void SetQRCodeLink(std::string link);
 
void SetColors(Cubios::Math::Color key, Cubios::Math::Color base);
 
void SetTopology(uint8_t screen, Cubios::TOPOLOGY_place_t p);
 
void GetTopology(TOPOLOGY_orientation_mode_t mode, bool replaceFaceToOrientation);
 
virtual void RenderUserDefinedScreen(uint8_t type);
 
  
=== Math::Vec2 ===
+
OffscreenRenderTarget(u32_t width, u32_t height, GFX_PixelFormat_t format);
  
2D float vector.
+
; <code>void Begin(bool overwrite = false);</code> / <code>void End();</code> / <code>Add()</code> / <code>AddCopy()</code>
 +
: Same block pattern as <code>Screen</code>, but drawing goes into the buffer. <code>overwrite=true</code> re-bakes.
 +
; <code>virtual void RenderLayer(renderLayerOrder_t)</code>
 +
: Hook to inject drawing <code>BeforeQueue</code>/<code>AfterQueue</code>. Pixel formats: RGB565 / ARGB6666 / ARGB8888.
  
Public interface (<code>Math/Vec2.h</code>):
+
== Gfx::QRCode ==
  
Vec2();
+
QR-code scene object (SDK 6.0+). <code>QRCode(std::string data, x, y[, size])</code>; <code>SetData()</code>, <code>SetSize()</code>, <code>SetColor()</code> / <code>SetBackgroundColor()</code> (fields <code>ColorOnes</code>/<code>ColorZeros</code>). Used by system apps to link the cube with the mobile app.
Vec2(const float _x, const float _y);
 
Vec2(const Vec2& vec);
 
Vec2(const float* p);
 
void Set(const float _x, const float _y);
 
void Set(const Vec2& vec);
 
void Set(const float* p);
 
float Len() const;
 
void Norm();
 
bool IsEqual(const Vec2& v, const float tol) const;
 
int Compare(const Vec2& v, float tol) const;
 
  
=== Math::Vec2i ===
+
== Sound and SoundCollection ==
  
2D integer vector.
+
; <code>Sound(const std::string& name);</code> → <code>void Play(uint8_t volume = 100);</code>
 +
: One sound asset. <code>static Stop()</code> / <code>static bool IsPlaying()</code> control the playback channel.
 +
; <code>SoundCollection(std::vector&lt;std::string&gt;&)</code> or <code>(std::vector&lt;Sound*&gt;&)</code>
 +
: A set of sounds (SDK 6.2+):
 +
:; <code>bool PlayRandomSound(uint8_t volume = 100, bool stopCurrent = true);</code>
 +
:: Play a random one — the idiom behind varied game SFX.
 +
:; <code>bool RepeatRandomSounds(uint8_t volume, int delayMin, int delayMax, int deltaTime);</code>
 +
:: Keep playing random sounds with a random delay in [min,max]; call it periodically passing the tick delta.
 +
:; <code>Stop()</code> / <code>IsPlaying()</code>
  
Public interface (<code>Math/Vec2.h</code>):
+
== NetworkMessage and SaveMessage ==
  
Vec2i();
+
Two identical bit-packing serializers with different buffers: <code>NetworkMessage</code> (max <code>MESSAGE_SIZE_MAX</code>) for inter-module packets, <code>SaveMessage</code> (max <code>GAME_SAVE_SIZE</code>) for persistent state (SDK 6.0+).
Vec2i(const int16_t _x, const int16_t _y);
 
Vec2i(const Vec2i& vec);
 
Vec2i(const int16_t* p);
 
void Set(const int16_t _x, const int16_t _y);
 
void Set(const Vec2i& vec);
 
void Set(const int16_t* p);
 
float Len() const;
 
void Norm();
 
bool IsEqual(const Vec2i& v, const float tol) const;
 
int Compare(const Vec2i& v, float tol) const;
 
  
=== Math::Transform ===
+
; <code>WriteInt(int value, int bits)</code> / <code>WriteSignedInt(int value, int bits)</code> (signed added in 5.1) / <code>WriteByte</code> / <code>WriteBool</code> / <code>WriteFloat</code>
 +
: Append a value using exactly <code>bits</code> bits — pack a whole game state into one packet.
 +
; <code>ReadInt(int bits)</code> / <code>ReadSignedInt</code> / <code>ReadByte</code> / <code>ReadBool</code> / <code>ReadFloat</code>
 +
: Read back '''in the same order'''.
 +
; <code>GetData(int& length)</code> / <code>SetData(uint8_t*, int)</code> / <code>Reset(bool zero = false)</code>
 +
: Raw buffer access and cursor reset.
  
Position + rotation + mirroring transform of a scene object.
+
Canonical flow: master module packs → <code>SendNetworkMessage(type, &msg)</code> → other modules unpack in <code>on_Message()</code>. For saves: pack → <code>SaveState(&msg)</code>; restore via <code>LoadState(&id, &msg)</code>.
  
Public interface (<code>Math/Transform.h</code>):
+
== Scramble ==
  
Transform():Position(0,0),Rotation(0),Mirroring(0),ScaleX(100),ScaleY(100);
+
Cube-scramble helper (SDK 6.0+) for puzzle titles: it performs a given number of virtual twists from the current topology and lets the game track how the mapping changes. Subclass it and implement the callbacks.
Transform(float x, float y): Position(x,y),Rotation(0),Mirroring(0),ScaleX(100),ScaleY(100);
 
Transform(float x, float y, unsigned int a): Position(x,y),Rotation(a),Mirroring(0),ScaleX(100),ScaleY(100);
 
Transform(float x, float y, unsigned int a, unsigned int sx, unsigned int sy ): Position(x,y),Rotation(a),Mirroring(0),ScaleX(sx),ScaleY(sy);
 
Transform(float x, float y, unsigned int a, unsigned int m): Position(x,y),Rotation(a),Mirroring(m),ScaleX(100),ScaleY(100);
 
Transform(float x, float y, unsigned int a, unsigned int sx, unsigned int sy, unsigned int m): Position(x,y),Rotation(a),Mirroring(m),ScaleX(sx),ScaleY(sy);
 
Transform(const Transform& t): Position(t.Position),Rotation(t.Rotation),Mirroring(t.Mirroring),ScaleX(t.ScaleX),ScaleY(t.ScaleY);
 
int SafeRotation();
 
  
=== Math::Color ===
+
; <code>void StartScramble(uint8_t twistsCount);</code>
 +
: Run a scramble of <code>twistsCount</code> random virtual twists.
 +
; <code>void VirtualTwist(uint8_t screen, uint8_t direction);</code>
 +
: Apply one virtual twist programmatically.
 +
; <code>virtual void on_BeforeTwist() = 0;</code>
 +
: Called before each scramble twist.
 +
; <code>virtual void on_MappingChanged(uint8_t moduleTo, uint8_t screenTo, uint8_t moduleFrom, uint8_t screenFrom) = 0;</code>
 +
: Called for every facelet remapped by the twist — move your game state accordingly.
 +
; <code>virtual void on_Twist(const TOPOLOGY_twistInfo_t twist) = 0;</code>
 +
: Called after the twist with its description. Used across the official ''Topology'' samples.
  
RGBA color with float/byte accessors (see also <code>Gfx/Colors.h</code> named constants).
+
== Splashscreen ==
  
Public interface (<code>Math/Color.h</code>):
+
Standard splash screen with leaderboard integration (SDK 6.0+, reworked in 6.2): title screen, personal best, points table and control hints, rendered from your own sprite assets.
  
Color():_R(255),_G(255),_B(255),_A(255),_Value(0xFFFFFFFF);
+
; <code>Splashscreen(Application* app, SplsParms::e_LeadersDataType dataType);</code>
Color(uint8_t r, uint8_t g, uint32_t b):_R(r),_G(g),_B(b),_A(255);
+
: Create for an app; <code>dataType</code> selects how values are displayed (number, time, ).
Color(uint8_t r, uint8_t g, uint32_t b, uint8_t a):_R(r),_G(g),_B(b),_A(a);
+
; <code>InitSplashScreenSprites(background, mainImage, gameName, QRcode, leaderboardIcon, resultsIcon, twistIcon_1, twistIcon_2, tapIcon_1, tapIcon_2, borderYou)</code>
Color(uint32_t v):_Value(v);
+
: Bind your sprite IDs to the standard slots (pass −1 to skip a slot).
this->_B = (v & 0x000000ff);
+
; <code>void Render(Screen* screen);</code> / <code>void Tick(uint32_t currentTime, uint32_t deltaTime);</code>
this->_G = (v & 0x0000ff00) >> 8;
+
: Drive it from <code>on_Render</code> / <code>on_Tick</code> while the splash is active.
this->_R = (v & 0x00ff0000) >> 16;
+
; <code>uint32_t GetPersonalBest();</code> / <code>void SetRecord(uint32_t value);</code>
this->_A = (v & 0xff000000) >> 24;
+
: Personal best score.
void Set(uint8_t r, uint8_t g, uint32_t b, uint8_t a);
+
; <code>SetNamedValue(idx, name, value, type)</code> / <code>SetLabel(idx, text)</code> / <code>SetApplicationName(name)</code> / <code>SetSeparator(s)</code>
void Set(uint8_t r, uint8_t g, uint32_t b);
+
: Texts and values shown on the splash.
void Set(uint32_t v);
+
; <code>SetLeaderBoardTable(e_LeaderBoardType)</code> / <code>SetLeaderBoardTable(lbTable[FACES][POSITIONS])</code>
inline void SetA(uint8_t a);
+
: Leaderboard source — built-in or your own table.
inline void SetAf(float a);
+
; <code>SetQRCodeLink(link)</code> / <code>SetColors(key, base)</code> / <code>SetPlaybackSpeed(idx, speed)</code>
inline void SetAfSafe(float a);
+
: QR link, color theme, label animation speed.
inline void SetR(uint8_t r);
+
; <code>virtual void RenderUserDefinedScreen(uint8_t type)</code>
inline void SetG(uint8_t g);
+
: Override to add custom splash screens.
inline void SetB(uint8_t b);
 
inline uint8_t A();
 
inline float Af();
 
inline uint8_t R();
 
inline uint8_t G();
 
inline uint8_t B();
 
inline uint32_t Value();
 
  
=== Math::Rect2 ===
+
== Math ==
  
2D rectangle.
+
; <code>Math::Vec2</code> / <code>Math::Vec2i</code>
 +
: 2D float/int vectors with arithmetic.
 +
; <code>Math::Transform</code>
 +
: <code>{ Vec2 Position; int Rotation; unsigned ScaleX, ScaleY; unsigned Mirroring; }</code> — rotation in degrees (<code>SafeRotation()</code> normalizes), scale in percent (100 = 1:1). Constructors: <code>(x,y)</code>, <code>(x,y,angle)</code>, <code>(x,y,angle,sx,sy)</code>, <code>(x,y,angle,mirror)</code>, <code>(x,y,angle,sx,sy,mirror)</code>.
 +
; <code>Math::Color</code>
 +
: ARGB color; <code>Set(0xAARRGGBB)</code>, per-channel <code>SetA/R/G/B</code>, float alpha <code>SetAf</code>/<code>SetAfSafe</code>. Named constants in <code>Gfx/Colors.h</code> (<code>Colors::black</code>, <code>Colors::white</code>, …).
 +
; <code>Math::Rect2</code>
 +
: 2D rectangle — used for [[#Gfx::SpriteAtlas|atlas]] sub-rectangles.
  
Public interface (<code>Math/Rect2.h</code>):
+
== Where to see it all together ==
  
Rect2();
+
The Development Kit ships complete buildable projects using every class above: ''Basics'' (1–4), ''Rendering'', ''Topology'', ''Network'' (messaging between modules), and ''GFX Engine Sample Projects'' (1–3: Twinkle, SnotFlow, …) — create them via the [https://marketplace.visualstudio.com/items?itemName=cubios-inc.WOWCubeSDK WOWCube SDK extension for VS Code].
Rect2(const Vec2i& topLeft, const Vec2i& bottomRight);
 
Rect2(int16_t x, int16_t y, int16_t width, int16_t height);
 
void Set(const Vec2i& topLeft, const Vec2i& bottomRight);
 
bool IsInside(const Vec2i& p) const;
 
Vec2i Midpoint() const;
 
  
 
[[Category:SDK 6.3]]
 
[[Category:SDK 6.3]]
 
[[Category:C++ API]]
 
[[Category:C++ API]]

Latest revision as of 09:39, 26 July 2026

Official WOWCube SDK documentation. SDK 6.3, C++ (WebAssembly) API. Signatures are extracted from the canonical SDK headers; usage notes and examples come from the official sample projects shipped with the WOWCube Development Kit. The headers remain authoritative.

SDK 6.3 · PAWN API: Core · Graphics · Topology · Sound · Motion Sensor · Leaderboard · Splash Screen · Physics · Network · Save · Scramble · Logging
C++: Native API · Application · GFX Engine  ·  Rust: Rust API (experimental)  ·  Changelog

SDK 6.3 · C++ / GFX Engine

The object-oriented retained layer of the C++ SDK (namespace Cubios): a scene graph with sprites, text, backgrounds, sounds and math primitives. It sits on top of the native ABI and is driven by the Application framework.

The canonical pattern

Every official sample follows the same lifecycle:

  1. Create objects once at startup and register them in the application's Scene under integer IDs (usually an enum).
  2. Render every frame: for each of the module's three Screens open a Begin()/End() block and Add() the scene objects you want on that screen, chaining setters.

Resource creation (from the official Network/Messaging2 sample):

void Messaging2::InitializeResources()
{
    this->Scene.CreateObjectWithID(GfxObjects::idle, new Sprite("idle.png", Transform(120,120,0)));
    this->Scene[GfxObjects::idle]->Color.Set(0xFFFFFFFF);
    this->Scene.CreateObjectWithID(GfxObjects::background, new Sprite("background.png", Transform(120,120,0)));
    this->SetTimer(Timers::mainTimer, 30);
}

Per-frame rendering (from the official GFX Engine Sample 1 — Twinkle):

void Twinkle::on_Render(std::array<Cubios::Screen, 3>& screens)
{
    Background* bkg = (Background*)this->Scene[Sprites::Clear];
    for(auto it = screens.begin(); it != screens.end(); ++it)
    {
        it->Begin(TOPOLOGY_orientation_mode_t::ORIENTATION_MODE_GRAVITY, true);
            it->Add(bkg->SetColor(0xFF000044));
            if(TOPOLOGY_isAssembled()==1)
            {
                switch(it->Position())   // screen's place on the cube face
                {
                    case 0: it->Add(this->Scene[Sprites::MyUfo])->SetPosition(pos.X-280, pos.Y-280); break;
                    case 1: it->Add(this->Scene[Sprites::MyUfo])->SetPosition(pos.X,     pos.Y-280); break;
                    case 2: it->Add(this->Scene[Sprites::MyUfo])->SetPosition(pos.X,     pos.Y);     break;
                }
            }
        it->End();
    }
}

Units and conventions (as used across all official samples): screens are 240×240 px; colors are packed 0xAARRGGBB (Math::Color); Transform rotation is in degrees, scale is in percent (100 = 1:1); all Set* methods return SceneObject*, so calls chain: screen.Add(obj)->SetPosition(x,y)->SetAf(0.5f). To make one logical object span several screens of a face, samples draw it on each screen with a ±280 px offset per screen position (as above).

Scene

The retained scene graph owned by every Application (field app.Scene). It is an ID-addressed registry of objects and sounds; it owns them and disposes them for you.

uint32_t CreateObject(SceneObject* obj);
Register an object; returns its auto-assigned ID. The scene takes ownership.
bool CreateObjectWithID(uint32_t id, SceneObject* obj);
Register under an explicit ID (usually an enum value). Fails (returns false) if the ID is taken. The most common way to build a scene in the official samples.
uint32_t CreateSound(Sound* obj); / bool CreateSoundWithID(uint32_t id, Sound* obj);
Same, for sounds.
SceneObject* operator[](uint32_t);
Look an object up by ID: this->Scene[Sprites::MyUfo].
bool DisposeObjectWithID(uint32_t id); / bool DisposeSoundWithID(uint32_t id); / void DisposeAllObjects();
Remove and delete objects/sounds.
void Play(uint32_t id, uint8_t volume);
Play a registered sound by ID.

SceneObject

Base class of every visual object. Holds a Math::Transform, a Math::Color and a Visible flag. All setters are chainable (return SceneObject*).

virtual void Render() = 0;
Implemented by each concrete object; called by the engine when the object was Add()-ed to a screen in the current frame.
SetPosition(float x, float y) / SetPosition(const Math::Vec2&) / SetTransform(const Math::Transform&)
Place the object (240×240 screen space). The most-used call in the official samples.
SetRotation(int r)
Rotation in degrees; normalized into 0–359 (negative values allowed).
SetScale(unsigned s) / SetScale(sx, sy) / SetXScale(s) / SetYScale(s)
Scale in percent (100 = original size).
SetMirroring(unsigned m)
Mirror mode (GFX_mirror_t: BLANK/X/Y/XY).
SetColor(uint32_t argb) / SetR/SetG/SetB(uint8_t) / SetA(uint8_t) / SetAf(float) / SetAfSafe(float)
Tint/opacity. SetAf takes 0.0–1.0; SetAfSafe clamps out-of-range values (added in SDK 5.1).
SetVisible(bool)
Hide without removing from the scene.
const Math::Vec2 ScreenPosition();
The object's position converted to physical-screen space, taking the screen's current rotation angle (0/90/180/270°) into account.
Move(float dx, float dy) / Move(const Math::Vec2&)
Screen-angle-aware relative move. Only valid inside a Screen::Begin()/End() block — otherwise it logs a warning and does nothing.

Public fields: Math::Transform Transform; Math::Color Color; bool Visible;

Screen

One of the three displays of the current module; an array std::array<Screen, 3> is passed to on_Render() / on_PhysicsTick().

void Begin(TOPOLOGY_orientation_mode_t mode = ORIENTATION_MODE_MENU, bool autorotation = false); / void End();
Open/close the frame block for this screen. mode selects the orientation reference (MENU / GRAVITY / SPLASH); with autorotation = true content is auto-rotated as the cube is turned (samples use ORIENTATION_MODE_GRAVITY, true).
SceneObject* Add(SceneObject* obj);
Queue a scene object for rendering on this screen this frame; returns the object for chaining.
SceneObject* AddCopy(SceneObject* obj);
Queue an independent copy — the standard way to draw the same object several times with different positions in one frame (heavily used in the samples).
uint8_t ID();
Physical display index — pass to native calls such as MS_getFaceAccelX(screen.ID()).
uint8_t Position();
The screen's place on its cube face (see the render sample above — used to compute cross-screen offsets).
uint8_t Face(); / uint8_t OppositeFace(); / TOPOLOGY_orientation_t Direction();
Topology of the screen: which face it belongs to, the opposite face, and the facing direction (UP/DOWN/FRONT/…).
void SetOrientation(TOPOLOGY_orientation_mode_t mode); / uint32_t Angle(); / bool IsAutorotation();
Orientation control and current rotation angle of the content.

Gfx::Sprite

Static image sprite bound to an image asset by file name (from the app's packed assets/).

Sprite(std::string name);
Sprite(std::string name, float x, float y);
Sprite(std::string name, const Cubios::Math::Transform& t);
Sprite(const Sprite& sprite);
void Render() override;

Typical use: new Sprite("idle.png", Transform(120,120,0)) — center of a 240×240 screen.

Gfx::Background

Full-screen fill. Background(uint32_t argb) or Background(R,G,B[,A]); recolor at render time via SetColor(...) (see the Twinkle sample above — one shared background object recolored per screen).

Gfx::Text

Text object.

Text(std::string text, float x, float y, uint32_t fontSize = 10);
Text(std::string text, float x, float y, uint32_t fontSize, const Math::Color& color);
Text(std::string text, const Math::Transform& t, uint32_t fontSize, const Math::Color& color,
     text_align_t al = TEXT_ALIGN_CENTER);
SetContent(std::string) / FormatContent(const char* fmt, ...)
Replace the text; FormatContent is printf-style — handy for scores/counters.
SetFontSize(uint32_t)
Change size. Alignment via the public Alignment field (text_align_t, 9 anchors).

Gfx::AnimatedSprite

Frame-animated sprite. Three ways to construct: an explicit list of asset names; a name pattern (name + frameNumber + extension) with a first/last frame range; or a SpriteAtlas.

int16_t Tick(uint32_t dt);
Advance the animation; call from on_Tick(time, dt) for every animated sprite. Returns the current frame.
SetPlaybackMode(playbackMode_t)
Loop (wrap around), Bounce (ping-pong), Set (manual frame control).
SetPlaybackSpeed(int16_t) / SetFrame(int16_t) / NextFrame() / PrevFrame()
Speed and manual frame stepping.

Gfx::SpriteAtlas

A sprite sheet: one image asset cut into sub-rectangles, each rendered by a SpriteAtlasElement registered in the scene. Added in SDK 6.2 — saves memory versus per-frame images.

SpriteAtlas<SpriteAtlasElement> atlas("sheet.png", &this->Scene);
atlas.AddSprite(MyIds::run0, Math::Rect2(0,   0, 64, 64));
atlas.AddSprite(MyIds::run1, Math::Rect2(64,  0, 64, 64));
bool AddSprite(uint32_t id, const Math::Rect2& rc);
Create an element for sub-rectangle rc and register it in the scene under id (fails if the ID is taken).
T* Get(uint32_t) / T* operator[](uint32_t) / size_t Count() / ElementsInsertionOrder()
Element access. SpriteAtlasElement itself is a normal SceneObject (position/scale/color) plus Rect() and Copy(). An atlas can also feed an AnimatedSprite.

Gfx::OffscreenRenderTarget

Render-to-texture: draw objects into an offscreen buffer once, then use the result as a single scene object (a "baked image").

OffscreenRenderTarget(u32_t width, u32_t height, GFX_PixelFormat_t format);
void Begin(bool overwrite = false); / void End(); / Add() / AddCopy()
Same block pattern as Screen, but drawing goes into the buffer. overwrite=true re-bakes.
virtual void RenderLayer(renderLayerOrder_t)
Hook to inject drawing BeforeQueue/AfterQueue. Pixel formats: RGB565 / ARGB6666 / ARGB8888.

Gfx::QRCode

QR-code scene object (SDK 6.0+). QRCode(std::string data, x, y[, size]); SetData(), SetSize(), SetColor() / SetBackgroundColor() (fields ColorOnes/ColorZeros). Used by system apps to link the cube with the mobile app.

Sound and SoundCollection

Sound(const std::string& name);void Play(uint8_t volume = 100);
One sound asset. static Stop() / static bool IsPlaying() control the playback channel.
SoundCollection(std::vector<std::string>&) or (std::vector<Sound*>&)
A set of sounds (SDK 6.2+):
bool PlayRandomSound(uint8_t volume = 100, bool stopCurrent = true);
Play a random one — the idiom behind varied game SFX.
bool RepeatRandomSounds(uint8_t volume, int delayMin, int delayMax, int deltaTime);
Keep playing random sounds with a random delay in [min,max]; call it periodically passing the tick delta.
Stop() / IsPlaying()

NetworkMessage and SaveMessage

Two identical bit-packing serializers with different buffers: NetworkMessage (max MESSAGE_SIZE_MAX) for inter-module packets, SaveMessage (max GAME_SAVE_SIZE) for persistent state (SDK 6.0+).

WriteInt(int value, int bits) / WriteSignedInt(int value, int bits) (signed added in 5.1) / WriteByte / WriteBool / WriteFloat
Append a value using exactly bits bits — pack a whole game state into one packet.
ReadInt(int bits) / ReadSignedInt / ReadByte / ReadBool / ReadFloat
Read back in the same order.
GetData(int& length) / SetData(uint8_t*, int) / Reset(bool zero = false)
Raw buffer access and cursor reset.

Canonical flow: master module packs → SendNetworkMessage(type, &msg) → other modules unpack in on_Message(). For saves: pack → SaveState(&msg); restore via LoadState(&id, &msg).

Scramble

Cube-scramble helper (SDK 6.0+) for puzzle titles: it performs a given number of virtual twists from the current topology and lets the game track how the mapping changes. Subclass it and implement the callbacks.

void StartScramble(uint8_t twistsCount);
Run a scramble of twistsCount random virtual twists.
void VirtualTwist(uint8_t screen, uint8_t direction);
Apply one virtual twist programmatically.
virtual void on_BeforeTwist() = 0;
Called before each scramble twist.
virtual void on_MappingChanged(uint8_t moduleTo, uint8_t screenTo, uint8_t moduleFrom, uint8_t screenFrom) = 0;
Called for every facelet remapped by the twist — move your game state accordingly.
virtual void on_Twist(const TOPOLOGY_twistInfo_t twist) = 0;
Called after the twist with its description. Used across the official Topology samples.

Splashscreen

Standard splash screen with leaderboard integration (SDK 6.0+, reworked in 6.2): title screen, personal best, points table and control hints, rendered from your own sprite assets.

Splashscreen(Application* app, SplsParms::e_LeadersDataType dataType);
Create for an app; dataType selects how values are displayed (number, time, …).
InitSplashScreenSprites(background, mainImage, gameName, QRcode, leaderboardIcon, resultsIcon, twistIcon_1, twistIcon_2, tapIcon_1, tapIcon_2, borderYou)
Bind your sprite IDs to the standard slots (pass −1 to skip a slot).
void Render(Screen* screen); / void Tick(uint32_t currentTime, uint32_t deltaTime);
Drive it from on_Render / on_Tick while the splash is active.
uint32_t GetPersonalBest(); / void SetRecord(uint32_t value);
Personal best score.
SetNamedValue(idx, name, value, type) / SetLabel(idx, text) / SetApplicationName(name) / SetSeparator(s)
Texts and values shown on the splash.
SetLeaderBoardTable(e_LeaderBoardType) / SetLeaderBoardTable(lbTable[FACES][POSITIONS])
Leaderboard source — built-in or your own table.
SetQRCodeLink(link) / SetColors(key, base) / SetPlaybackSpeed(idx, speed)
QR link, color theme, label animation speed.
virtual void RenderUserDefinedScreen(uint8_t type)
Override to add custom splash screens.

Math

Math::Vec2 / Math::Vec2i
2D float/int vectors with arithmetic.
Math::Transform
{ Vec2 Position; int Rotation; unsigned ScaleX, ScaleY; unsigned Mirroring; } — rotation in degrees (SafeRotation() normalizes), scale in percent (100 = 1:1). Constructors: (x,y), (x,y,angle), (x,y,angle,sx,sy), (x,y,angle,mirror), (x,y,angle,sx,sy,mirror).
Math::Color
ARGB color; Set(0xAARRGGBB), per-channel SetA/R/G/B, float alpha SetAf/SetAfSafe. Named constants in Gfx/Colors.h (Colors::black, Colors::white, …).
Math::Rect2
2D rectangle — used for atlas sub-rectangles.

Where to see it all together

The Development Kit ships complete buildable projects using every class above: Basics (1–4), Rendering, Topology, Network (messaging between modules), and GFX Engine Sample Projects (1–3: Twinkle, SnotFlow, …) — create them via the WOWCube SDK extension for VS Code.