Difference between revisions of "API"

From WowWiki
Jump to navigation Jump to search
Line 20: Line 20:
 
  Located at cubios/graphics/tests_g2d.h
 
  Located at cubios/graphics/tests_g2d.h
 
  Contains functions to for debug and testing purposes.
 
  Contains functions to for debug and testing purposes.
 +
 +
1. Measure execution time of foo() method
 +
Example :
 +
 +
G2D_beginMeasure();
 +
foo();
 +
uint32_t time = G2D_endMeasure();
 +
  
 
===Effects===
 
===Effects===

Revision as of 08:14, 27 August 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 to for debug and testing purposes.
1. Measure execution time of foo() method
Example :
G2D_beginMeasure();
foo();
uint32_t time = G2D_endMeasure();


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

Example

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