libdragon
Data Fields
rdpq_trifmt_t Struct Reference

Format descriptor of a triangle. More...

#include <rdpq_tri.h>

Data Fields

int pos_offset
 Index of the position component within the vertex arrays. More...
 
int shade_offset
 Index of the shade component within the vertex arrays. More...
 
bool shade_flat
 If true, draw the triangle with flat shading (instead of gouraud shading). More...
 
int tex_offset
 Index of the texture component within the vertex arrays. More...
 
rdpq_tile_t tex_tile
 RDP tile descriptor that describes the texture (0-7). More...
 
int tex_mipmaps
 Number of mipmaps to use for the texture. More...
 
int z_offset
 Index of the depth component within the vertex array. More...
 

Detailed Description

Format descriptor of a triangle.

This structure holds the parameters required to draw triangles. It contains both a description of the vertex format, and some configuration parameters for the triangle rasterizer.

This library provides a few predefined formats (such as TRIFMT_FILL, TRIFMT_TEX, etc.) but you are free to define your own format.

There is no overhead in using a custom format or even switching format from a triangle to another (besides the required mode changes), so feel free to define as many formats are required for your application.

Refer to rdpq_triangle for a description of the different vertex components.

Field Documentation

◆ pos_offset

int rdpq_trifmt_t::pos_offset

Index of the position component within the vertex arrays.

For instance, if pos_offset == 4, v1[4] and v1[5] must be the X and Y coordinates of the first vertex.

◆ shade_offset

int rdpq_trifmt_t::shade_offset

Index of the shade component within the vertex arrays.

For instance, if shade_offset == 4, v1[4], v1[5], v1[6], v1[7] must be the R, G, B, A values associated to the first vertex. If shade_offset is less than 0, no shade component will be used to draw the triangle.

◆ shade_flat

bool rdpq_trifmt_t::shade_flat

If true, draw the triangle with flat shading (instead of gouraud shading).

This parameter is ignored if the shade component does not exist (shade_offset < 0). Normally, gouraud shading is used to draw triangles, which means that the shading of each vertex is interpolated across the triangle. If flat shading is enabled, the shading of the first vertex is used for the whole triangle.

◆ tex_offset

int rdpq_trifmt_t::tex_offset

Index of the texture component within the vertex arrays.

For instance, if tex_offset == 4, v1[4], v1[5], v1[6] must be the S, T, W values associated to the first vertex. If tex_offset is less than 0, no texture component will be used to draw the triangle.

◆ tex_tile

rdpq_tile_t rdpq_trifmt_t::tex_tile

RDP tile descriptor that describes the texture (0-7).

This parameter is ignored if the texture component does not exist (tex_offset < 0). In case of multi-texturing, tile + 1 will be used for the second texture. Notice that the tile descriptor must be configured before drawing the triangle.

◆ tex_mipmaps

int rdpq_trifmt_t::tex_mipmaps

Number of mipmaps to use for the texture.

This parameter is ignored if the texture component does not exist (tex_offset < 0), or if mipmapping has not been configured.

Notice that when using the mode API (rdpq_mode_mipmap), the number of mipmaps is specified there, so this parameter should be left to zero.

◆ z_offset

int rdpq_trifmt_t::z_offset

Index of the depth component within the vertex array.

For instance, if z_offset == 4, v1[4] must be the Z coordinate of the first vertex. If z_offset is less than 0, no depth component will be used to draw the triangle.


The documentation for this struct was generated from the following file: