#include <libdragon.h>
#include <t3d/t3dmath.h>
Go to the source code of this file.
|
| enum | TPXCmd {
TPX_CMD_SYNC_T3D = 0x0
, TPX_CMD_DRAW_COLOR = 0x1
, TPX_CMD_MATRIX_STACK = 0x2
, TPX_CMD_SET_DMEM = 0x3
,
TPX_CMD_DRAW_TEXTURE = 0x4
} |
| |
|
|
| aligned (16))) TPXParticle |
| |
| void | tpx_init (TPXInitParams params) |
| | Initializes the tinyPX library.
|
| |
| void | tpx_state_from_t3d () |
| |
| void | tpx_state_set_scale (float scaleX, float scaleY) |
| |
| void | tpx_state_set_base_size (uint16_t baseSize) |
| |
| void | tpx_state_set_tex_params (int16_t offsetX, uint16_t mirrorPoint) |
| |
| void | tpx_particle_draw (TPXParticle *particles, uint32_t count) |
| |
| void | tpx_particle_draw_tex (TPXParticle *particles, uint32_t count) |
| |
| void | tpx_matrix_set (const T3DMat4FP *mat, bool doMultiply) |
| |
| void | tpx_matrix_push (const T3DMat4FP *mat) |
| |
| void | tpx_matrix_pop (int count) |
| |
| void | tpx_matrix_push_pos (int count) |
| |
| static int8_t * | tpx_buffer_get_pos (TPXParticle pt[], int idx) |
| |
| static int8_t * | tpx_buffer_get_size (TPXParticle pt[], int idx) |
| |
| static uint32_t * | tpx_buffer_get_color (TPXParticle pt[], int idx) |
| |
| static uint8_t * | tpx_buffer_get_rgba (TPXParticle pt[], int idx) |
| |
| void | tpx_buffer_swap (TPXParticle pt[], uint32_t idxA, uint32_t idxB) |
| |
| void | tpx_buffer_copy (TPXParticle pt[], uint32_t idxDst, uint32_t idxSrc) |
| |
| void | tpx_destroy () |
| |
- Copyright
- 2024 - Max Bebök @license MIT
◆ tpx_buffer_copy()
| void tpx_buffer_copy |
( |
TPXParticle | pt[], |
|
|
uint32_t | idxDst, |
|
|
uint32_t | idxSrc ) |
Copies a particle into another place in a buffer This will overwrite the destination particle and keep the source particle unchanged.
- Parameters
-
| pt | buffer to copy particles in |
| idxDst | destination index |
| idxSrc | source index |
◆ tpx_buffer_get_color()
| static uint32_t * tpx_buffer_get_color |
( |
TPXParticle | pt[], |
|
|
int | idx ) |
|
inlinestatic |
Returns the pointer to the color (as a u32) of a particle in a buffer
- Parameters
-
| pt | particle buffer |
| idx | particle index |
◆ tpx_buffer_get_pos()
| static int8_t * tpx_buffer_get_pos |
( |
TPXParticle | pt[], |
|
|
int | idx ) |
|
inlinestatic |
Returns the pointer to a position of a particle in a buffer
- Parameters
-
| vert | particle buffer |
| idx | particle index |
◆ tpx_buffer_get_rgba()
| static uint8_t * tpx_buffer_get_rgba |
( |
TPXParticle | pt[], |
|
|
int | idx ) |
|
inlinestatic |
Returns the pointer to the color (as a u8[4]) of a particle in a buffer
- Parameters
-
| pt | particle buffer |
| idx | particle index |
◆ tpx_buffer_get_size()
| static int8_t * tpx_buffer_get_size |
( |
TPXParticle | pt[], |
|
|
int | idx ) |
|
inlinestatic |
Returns the pointer to the size of a particle in a buffer
- Parameters
-
| pt | particle buffer |
| idx | particle index |
◆ tpx_buffer_swap()
| void tpx_buffer_swap |
( |
TPXParticle | pt[], |
|
|
uint32_t | idxA, |
|
|
uint32_t | idxB ) |
Swaps two particles in a buffer
- Parameters
-
| pt | buffer to swap particles in |
| idxA | index of the first particle |
| idxB | index of the second particle |
◆ tpx_destroy()
Destroys the tinyPX library and frees all resources
◆ tpx_init()
Initializes the tinyPX library.
- Parameters
-
| params | settings to configure the library |
◆ tpx_matrix_pop()
| void tpx_matrix_pop |
( |
int | count | ) |
|
Pops the current matrix from the stack.
- Parameters
-
| count | how many matrices to pop |
◆ tpx_matrix_push()
| void tpx_matrix_push |
( |
const T3DMat4FP * | mat | ) |
|
Multiplies a matrix with the current stack position, then pushes it onto the stack.
- Parameters
-
| mat | address to load matrix from |
◆ tpx_matrix_push_pos()
| void tpx_matrix_push_pos |
( |
int | count | ) |
|
Moves the stack pos. without changing a matrix or causing re-calculations. This should only be used in preparation for 'tpx_matrix_set' calls.
E.g. instead of multiple push/pop combis, use:
- 'tpx_matrix_push_pos(1)' once
- then multiple 'tpx_matrix_set'
- finish with 'tpx_matrix_pop'
This is the most efficient way to set multiple matrices at the same level.
- Parameters
-
| count | relative change (matrix count), should usually be 1 |
◆ tpx_matrix_set()
| void tpx_matrix_set |
( |
const T3DMat4FP * | mat, |
|
|
bool | doMultiply ) |
Directly loads a matrix, overwriting the current stack position.
With 'doMultiply' set to false, this lets you completely replace the current matrix. With 'doMultiply' set to true, it serves as a faster version of a pop+push combination.
- Parameters
-
| mat | address to load matrix from |
| doMultiply | if true, the matrix will be multiplied with the previous stack entry |
◆ tpx_particle_draw()
| void tpx_particle_draw |
( |
TPXParticle * | particles, |
|
|
uint32_t | count ) |
Draws a given amount of particles. In contrast to triangles in t3d, this works in a single command. So load, transform and draw happens in one go.
- Parameters
-
| particles | pointer to the particle data |
| count | number of particles to draw |
◆ tpx_particle_draw_tex()
| void tpx_particle_draw_tex |
( |
TPXParticle * | particles, |
|
|
uint32_t | count ) |
Draws a given amount of particles with a texture. In contrast to triangles in t3d, this works in a single command. So load, transform and draw happens in one go. Note: this expects that you already setup textures. It will also always use TILE0 for the rect-commands.
- Parameters
-
| particles | pointer to the particle data |
| count | number of particles to draw |
◆ tpx_state_from_t3d()
| void tpx_state_from_t3d |
( |
| ) |
|
T3D and TPX have separate states and ucodes. This function copies the relevant T3D state to TPX.
Settings that are copied:
- Screen size
- Current MVP matrix
- W-normalization factor
◆ tpx_state_set_base_size()
| void tpx_state_set_base_size |
( |
uint16_t | baseSize | ) |
|
Sets a global base size from which all particles are scaled. This values can later only be scaled down, not up. By default it is set to 128, which should be good enough for most cases. If you notices particles are way too small or large, you can change this value. This may happen if you use large or very small screen sizes, or unusual near/far values.
- Parameters
-
| baseSize | unit-less base size, def.: 128 |
◆ tpx_state_set_scale()
| void tpx_state_set_scale |
( |
float | scaleX, |
|
|
float | scaleY ) |
Sets a global scaling factor applied to all particles Note that you can only scale down, not up.
- Parameters
-
| scaleX | horizontal scaling factor, range: 0.0 - 1.0 |
| scaleY | vertical scaling factor, range: 0.0 - 1.0 |
◆ tpx_state_set_tex_params()
| void tpx_state_set_tex_params |
( |
int16_t | offsetX, |
|
|
uint16_t | mirrorPoint ) |
Sets global params for textured particles. Those can be used to animate particles over time. NOTE: Check out the '19_particles_tex' example for more info.
- Parameters
-
| offsetX | base-offset UV offset in 1/4th pixels.
This refers to the 8x8px base size irrespective of the actual texture size. |
| mirrorPoint | point where the texture should be mirrored
This is in amount of sections of the 8x8px base size.
So if you want to repeat after 32px set it to 4.
If you want no mirroring, set it to 0. |