Difference between revisions of "API"

From WowWiki
Jump to navigation Jump to search
Line 19: Line 19:
 
====tests_g2d.h====
 
====tests_g2d.h====
 
  Located at cubios/graphics/tests_g2d.h
 
  Located at cubios/graphics/tests_g2d.h
  Contains functions to for debug and testing purposes.
+
  Contains functions for debug and testing purposes.
  
 
Examples
 
Examples
Line 27: Line 27:
 
  foo();
 
  foo();
 
  uint32_t time = G2D_endMeasure();
 
  uint32_t time = G2D_endMeasure();
 +
 +
 +
====tile.h====
 +
Tile engine allows effectively render tiles - repeated fragments of 2-color images(or monochrome images with transparent).
 +
    Located at cubios/tile.h
 +
    Contains methods for load tile map from resources and render tiles.
  
  
Line 68: Line 74:
  
 
====Font drawing functions====
 
====Font drawing functions====
 +
API:
 +
  abi_CMD_TEXT(const text[], const fontResID, const x, const y, const scale, const angle, const r, const g, const b)
  
 
+
Example:
Example
 
 
  new text[4] = ['A', 'p', 'p', '\0'];
 
  new text[4] = ['A', 'p', 'p', '\0'];
  abi_CMD_TEXT(text, 90, 160, 4, current_angles[face], 255, 0, 0);
+
  abi_CMD_TEXT(text, RES_ID_FONT, 90, 160, 16, current_angles[face], 255, 0, 0);

Revision as of 16:56, 2 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.

Firmware API

Common Libraries

math_g2d.h

Located at cubios/graphics/math_g2d.h
Contains functions to work with fixed point, vectors, matrix, quaternion and colors.


tests_g2d.h

Located at cubios/graphics/tests_g2d.h
Contains functions for debug and testing purposes.

Examples

Measure execution time of foo() method
G2D_beginMeasure();
foo();
uint32_t time = G2D_endMeasure();


tile.h

Tile engine allows effectively render tiles - repeated fragments of 2-color images(or monochrome images with transparent).

   Located at cubios/tile.h
   Contains methods for load tile map from resources and render tiles.


Effects

Cube 3D

Located at cubios/graphics/effects_cube3d.h

General purpose to use this effect comes from requirements to menu item groups.

Effect allows to draw 3d cube with properties

- border width ( in fixed32_t units from 0 to 1 )
- border color ( in rgb565 format )
- clip rect    ( rectangle in the buffer to draw cube)
- buffer       ( start address of custom buffer to draw )
- pitch        ( pitch of the buffer - used to calculate address in memory for next 'line' in buffer  address(x,y) = startAddress + x + y * pitch
- textures     ( array of pointer to custom textures to draw )
- texturesIds[24]  ( index of texture must be show on cube face, each face contains 4 cells ( 0 top-left, 1 top-right, 2 bottom-left, 3 bottom-right)  
                     index = faceId * 4 + cellIndex  
                    for example we need set 1st texture to 3rd face and top-right cell = 3 * 4 + 1 = 13  :
                          texuresIds[13] = 1; 
                          texuresIds[13] = 0; zero will mean that there must be empty cell
                    )

To find live example of usage look at the function effect_cube3d_render_test(framebuffer_t fb, uint32_t currentTime) There implemented animation of two cubes flying around screen center



Pawn API

Graphic functions

G2D acceleration is implemented as a separate task which handles all communication with G2D accelerator. It has mailbox for requests and it also provides utility functions to fill up this mail box for other tasks. Communication is done in OpenGL style, any other task can ask to prepare layers blending, add some layers to blend and initiate blending process.]] Currently result is stored in 3 internal buffers (one for each modules face) and ADD_BITMAP command is modified to access buffers in a primitive way. It is also supposed to render directly into display framebuffer (TBD). There is a way to wait until rendering is complete for other tasks. Task is implemented as a NFA

G2D acceleration paradigm

Graphic primitives

Font drawing functions

API:

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

Example:

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