Difference between revisions of "API"

From WowWiki
Jump to navigation Jump to search
Line 90: Line 90:
 
====Graphic primitives====
 
====Graphic primitives====
  
====Font drawing functions====
+
=====Font drawing functions=====
=====abi_CMD_TEXT=====
+
======abi_CMD_TEXT======
 
API:
 
API:
 
   abi_CMD_TEXT(const text[], const fontResID, const x, const y, const scale, const angle, const r, const g, const b)
 
   abi_CMD_TEXT(const text[], const fontResID, const x, const y, const scale, const angle, const r, const g, const b)

Revision as of 17:08, 3 September 2020

Template:Notice

Introduction

The main functions of the API are listed here, the features of the work of the environment are described

WOWCube Paradigms

WOWCube executes 8 copies of the byte-code of the script at the same time, providing functions for the interaction of scripts with each other, drawing functions, functions for accessing resources, and other specific functions. Each copy of the script has access to 3 displays. Resource scripts are packed into a package.

Pawn API

Graphic functions

Graphics 2D acceleration (G2D)

WOWCube provides the 2D acceleration interfaces to enhance gaming experience . Basically G2D engine allows to blend up to the 4 image layers at once with a HW acceleration. However there is no limit of layers, they are blended in a cascade. For example, if Pawn script requested 7 layers to be blended then 2 HW blending will occur:

G2D cascading scheme

Result of the blending can be saved as an internal G2D resource or flushed immediately on the specified display. Internal G2D resources can be used as an usual bitmap primitive (abi_CMD_BITMAP) or reused as an input for the next G2D action. Basic coordinate principle:

G2D coordinates sceme

Coordinates are limited from -2048 to 2047. Maximum layers size is 240x240.

abi_CMD_G2D_BEGIN_BITMAP

Syntax:

abi_CMD_G2D_BEGIN_BITMAP(const resID, const width, const height, const bool:replace)

Description:

abi_CMD_G2D_BEGIN_BITMAP and abi_CMD_G2D_END delimits the group of layers to be blended into internal G2D resource. This API is not intended for frequent usage. It is better suited for complex background generation on game initialization or dynamic resource modification triggered by rare game events.

Arguments:

resID
ID of the resource that will be generated from blending layers presented between abi_CMD_G2D_BEGIN_BITMAP and the subsequent abi_CMD_G2D_END. G2D engine can keep up to 3 different resources with IDs: 0, 1 and 2.
width
Width of the resulting resource. G2D engine can keep resource of 240px width maximum.
height
Height of the resulting resource. G2D engine can keep resource of 240px height maximum.
replace
If true, then an existing image will be replaced completely, otherwise it will be overwritten by reusing itself as a background layer.
abi_CMD_G2D_BEGIN_DISPLAY

Syntax:

abi_CMD_G2D_BEGIN_DISPLAY(const display, const bool:replace)

Description:

abi_CMD_G2D_BEGIN_DISPLAY and abi_CMD_G2D_END delimits the group of layers to be blended directly into display framebuffer. Obviously this API is designed for rendering scene on game tick. This API is not limited by layers count as well as abi_CMD_G2D_BEGIN_BITMAP. However it is strictly recommended to blend no more than 4 layers. Otherwise cascade blending will be initiated resulting in some FPS drop.

Arguments:

display
ID of the display which framebuffer will be used for blending. Each module have 3 displays with ID starting from 0.
replace
If true then an existing image will be replaced completely, otherwise it will be overwritten by reusing itself as a background layer.
abi_CMD_G2D_ADD_SPRITE

Syntax:

abi_CMD_G2D_ADD_SPRITE(const resID, const bool:g2d, const x, const y, const alpha, const color, const rotation, const mirror)

Description:

Specifies game resource which will be used as a layer for blending.

Arguments:

resID
ID of the resource to be uses as a layer.
g2d
Indicates if an internal G2D resource is specified or not.
x, y
Coordinates of the bitmap center to place on the layer.
alpha
Layer transparency in range between 0x00 and 0xFF, where 0x00 is a fully transparent layer.
color
Layer's source key - a color in ARGB8888 format to be avoided.
rotation
Clockwise rotation angle in degrees. It is possible to specify free angle, but only right angles have HW acceleration.
mirror
Mirroring variant. Possible values are self-explained: MIRROR_BLANK, MIRROR_X, MIRROR_Y, MIRROR_XY.
abi_CMD_G2D_ADD_RECTANGLE

Syntax:

abi_CMD_G2D_ADD_RECTANGLE(const x, const y, const width, const height, const color)

Description:

Specifies rectangle area which will be used as layer of blending. This API is not intended for frequent usage, i.e. particles generation. It is better suited for changing image background or applying color mask.

Arguments:

x, y
Coordinates of top left rectangle corner.
width
Rectangle width.
height
Rectangle height.
color
Rectangle color in ARGB8888 format.
abi_CMD_G2D_END

Syntax:

abi_CMD_G2D_END()

Description:

abi_CMD_G2D_END() and abi_CMD_G2D_BEGIN_BITMAP/abi_CMD_G2D_BEGIN_DISPLAY delimits the group of layers to be blended. After abi_CMD_G2D_END call final blending will be initiated and results will be stored according to the begin comand.

Graphic primitives

Font drawing functions
abi_CMD_TEXT

API:

 abi_CMD_TEXT(const text[], const fontResID, const x, const y, const scale, const angle, const r, const g, const b)

Description:

Intended for render a system font or a custom font from resources with specified coordinates, scale and rotation at an arbitrary angle.

Arguments:

text
Array of chars.
fontResID
Custom font resource identifier.
x, y
Coordinates of top left rectangle corner.
scale, angle
Percentage scale and clockwise rotation angle in degrees. Max size of font is 200x200 px. (scale = 100%)
'r', 'g', 'b'
Font color in RGB format.

Example:

new text[4] = ['A', 'p', 'p', '\0'];
abi_CMD_TEXT(text, RES_ID_FONT, 90, 160, 16, current_angles[face], 255, 0, 0);