SDK 6.3/C++/Graphics

From WowWiki
Revision as of 09:47, 26 July 2026 by WowBot (talk | contribs) (Split C++ Native API into per-module pages with minimal examples (WowBot))
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
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.

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++ Native API / Graphics

Immediate-mode drawing on the module's displays: primitives, images, text, shaders, QR codes and render targets. (The retained alternative is the GFX Engine.)

Shared types, enums and constants are listed on the Native API overview.

Minimal example

From the official HelloWOWCube project — direct drawing in on_Render:

for(auto it = screens.begin(); it != screens.end(); ++it)
{
    GFX_setRenderTarget(it->ID());
    GFX_clear(Colors::black);
    GFX_drawText(120, 100, TEXT_SIZE, 0, text_align_t::TEXT_ALIGN_CENTER, Colors::white, "HELLO");
    GFX_render();
}

Functions

GFX_getAssetId

Syntax:

i32_t GFX_getAssetId(const char* spriteName)

Description:

Get an image ID by the filename.
Usually an application uses image IDs to draw sprites and backgrounds. But
sometimes IDs are unknown, e.g. in common libraries, or they change rapidly
during development. This interface can be used to get an ID of the image by
its filename in the runtime. Maximum asset name length is 15 characters,
remaining symbols are truncated during lookup.

Return values:

The ID of image with a given filename or -1 in case of error.

History:

v5.0 - renamed from GFX_getId() to GFX_getAssetId()
v6.0 - truncate asset name in WASM API

GFX_clear

Syntax:

i32_t GFX_clear(u32_t color)

Description:

Clear a layer with a given color.

History:

v6.0 - changed color format

GFX_drawText

Syntax:

i32_t GFX_drawText(i32_t x, i32_t y, u32_t scale, u32_t angle, u32_t align, u32_t color, const char* text)

Description:

Draw a formatted text by the specified coordinates with a given color,
scale, text align and a rotation angle.

History:

v5.0 - clarified documentation, added GFX_drawTextXY() alias

GFX_drawPoint

Syntax:

i32_t GFX_drawPoint(i32_t x, i32_t y, u32_t color)

Description:

Draw a point specified by its coordinates with a given color.

History:

v5.0 - added GFX_drawPointXY() alias

GFX_drawCircle

Syntax:

i32_t GFX_drawCircle(u32_t x, u32_t y, u32_t radius, u32_t width, u32_t color)

Description:

Draw a circle at the given point with given radius, color and line width.

History:

v5.0 - added GFX_drawCircleXY() alias

GFX_drawSolidCircle

Deprecated. use fill shader intead

Syntax:

i32_t GFX_drawSolidCircle(u32_t x, u32_t y, u32_t radius, u32_t color)

Description:

Draw a solid circle at the given point with given radius and color.

History:

v5.0 - added GFX_drawSolidCircleXY() alias
v6.0 - DEPRECATED, use GFX_setFillShader() instead

GFX_drawArc

Syntax:

i32_t GFX_drawArc(i32_t x, i32_t y, u32_t radius, u32_t width, u32_t angle0, u32_t angle1, u32_t color)

Description:

Draw an arc at the given point with given radius, line width, color and
angles.

History:

v5.0 - added GFX_drawArcXY() alias

GFX_drawSector

Syntax:

i32_t GFX_drawSector(i32_t x, i32_t y, u32_t radius, u32_t angle0, u32_t angle1, u32_t color)

Description:

Draw a filled circular sector, connecting the arc to the circle's center
like a piece of pie.

History:

v5.1 - created

GFX_drawLine

Syntax:

i32_t GFX_drawLine(i32_t x0, i32_t y0, i32_t x1, i32_t y1, u32_t thickness, u32_t color)

Description:

Draw a line with from a given point to another one and given width and
color.

History:

v5.0 - added GFX_drawLineXY() alias

GFX_drawRectangle

Syntax:

i32_t GFX_drawRectangle(i32_t x, i32_t y, i32_t w, i32_t h, u32_t color)

Description:

Draw a solid rectangle at a given position with specified dimensions and a
color.

History:

v5.0 - added GFX_drawRectangleXY() alias

GFX_bakeImage

Syntax:

i32_t GFX_bakeImage(spriteID_t id, u32_t width, u32_t height, GFX_PixelFormat_t format, u32_t overwrite)

Description:

Set an ID of a memory buffer to save next rendering result.
Specifies the image that will be created by combining the group of
graphical primitives used between GFX_bakeImage() and GFS_render()
according their order and taking into account alpha channel in images. HW
has a limitation and can combine no more than 4 layers simultaneously, so
if there are more primitives then they will be combined in a cascade.
Useful for creating complex images like backgrounds for later usage.

History:

v6.0 - added overwrite parameter

GFX_setRenderTarget

Syntax:

i32_t GFX_setRenderTarget(u32_t display)

Description:

Set a screen which will be used to display next rendering result.
Cube module is a special device which has 3 independent screens to display
graphics. GFX_setRenderTarget() specifies a screen number which will be
used to display a next rendering result. Graphics primitives used in
between GFX_setRenderTarget() and GFX_render() calls will be combined
together according their order and taking into account alpha channel in
images. Resulting image will be immediately flushed onto the given screen.
HW has a limitation and can combine no more than 4 layers simultaneously,
so if there are more primitives then they will be combined in a cascade. To
display anything on the screen GFX_setRenderTarget() has to be always
called.

History:

v5.0 - renamed from GFX_updateDisplay() to GFX_setRenderTarget()

GFX_drawImage

Syntax:

i32_t GFX_drawImage(spriteID_t id, i32_t x, i32_t y, u32_t opacity, u32_t colorKey, u32_t scale_x, u32_t scale_y, u32_t angle, u32_t mirror)

Description:

Draw an image from application assets at a specified position and with
given transformations.

History:

v5.0 - added GFX_drawImageXY() alias, color argument clarified
v6.0 - added scale parameters

GFX_drawBakedImage

Syntax:

i32_t GFX_drawBakedImage(i32_t x, i32_t y, u32_t opacity, u32_t colorKey, u32_t scale_x, u32_t scale_y, u32_t angle, u32_t mirror, spriteID_t id)

Description:

Draw a previously baked image at a specified position and with given
transformations.

History:

v5.0 - added GFX_drawBakedImageXY() alias, color argument clarified
v6.0 - added scale parameters

GFX_drawQrCode

Syntax:

i32_t GFX_drawQRCode(i32_t x, i32_t y, u32_t size, u32_t color0, u32_t color1, u32_t angle, u32_t id, const char *text)

Description:

Generate and draw QR-code for a given text string.
Supported version 2 which is limited by 32 characters of input.

History:

v6.0 - added

GFX_render

Syntax:

i32_t GFX_render()

Description:

Start rendering process.

GFX_clearCache

Syntax:

i32_t GFX_clearCache()

Description:

Clear all cached images.
Oldest accessed image cache will be automatically freed if there is not
enough memory to cache a new image. This function forces this process, e.g.
when switch game levels.

GFX_removeBakedImage

Syntax:

i32_t GFX_removeBakedImage(spriteID_t id)

Description:

Remove specified baked image from cache.
Baked images do not automatically invalidate. This function allows to
remove any baked image from cache to save some space.

History:

v6.0 - added

GFX_cacheImages

Syntax:

i32_t GFX_cacheImages(spriteID_t* spriteIDs, u32_t count)

Description:

Force platform to cache application images.
Platform automatically reads and caches images from flash when the
application draws an image. Flash operations are synchronous and may cause
delays especially when reading large portions of data. To prevent the
application from lags it is possible to cache image data in advance.
However if application requests to draw a non-cached image and there is not
enough memory then oldest accessed images will be removed from cache. Also
there is a limit of 256 for a total number of cached images.

Return values:

Number of cached images or negative value if an error happened. Error
codes:
* -1 invalid function arguments count
* -2 invalid imageList array

History:

v5.0 - moved from appCtrl module to graphics

GFX_setFpsWindow

Syntax:

i32_t GFX_setFpsWindow(u32_t size)

Description:

Set the averaging window (in frames) used by the on-screen FPS counter (see Application::ShowFPSCounter()).

GFX_getAssetsCount

Syntax:

i32_t GFX_getAssetsCount()

Description:

Get the total count of graphic assets.

Return values:

Number of graphic assets.

History:

v6.0 - added

GFX_setFillShader

Syntax:

i32_t GFX_setFillShader(u32_t color)

Description:

Fill next primitives with specified color.

History:

v6.0 - added primitives shading

GFX_setLinearGradientShader

Syntax:

i32_t GFX_setLinearGradientShader(u32_t x0, u32_t y0, u32_t x1, u32_t y1, u32_t color0, u32_t color1)

Description:

Fill next primitives with linear gradient from a given point / color to
another one.

History:

v6.0 - added primitives shading

GFX_setRadialGradientShader

Syntax:

i32_t GFX_setRadialGradientShader(u32_t x0, u32_t y0, u32_t radius, u32_t color0, u32_t color1)

Description:

Fill next primitives with radial gradient from a given point with radius
and from a given color to another one.

History:

v6.0 - added primitives shading

GFX_removeShader

Syntax:

i32_t GFX_removeShader()

Description:

Do not use shading in next primitives.

History:

v6.0 - added primitives shading

GFX_drawSubImage

Syntax:

i32_t GFX_drawSubImage(spriteID_t id,i32_t x,i32_t y,u32_t rect_x,u32_t rect_y,u32_t rect_w,u32_t rect_h,u32_t opacity,u32_t colorKey,u32_t scale_x, u32_t scale_y,u32_t angle, u32_t mirror)

Description:

Draw a sub window of an image from application assets at a specified
position and with given transformations.

History:

v6.2 - added