GXSetArray

C Specification

#include <revolution/gx.h>
void GXSetArray( GXAttr attr, const void* base_ptr, u8 stride )

Arguments

attr specifies the attribute array name 
Accepted values are:
Attributes Description
GX_POS_MTX_ARRAY position matrix array
GX_NRM_MTX_ARRAY normal matrix array
GX_TEX_MTX_ARRAY texture matrix array
GX_LIGHT_ARRAY light object array
GX_VA_POS position array
GX_VA_NRM or
GX_VA_NBT
normal or normal/binormal/tangent array
GX_VA_CLR0 color 0 array
GX_VA_CLR1 color 1 array
GX_VA_TEX0 texture coordinate 0 array
GX_VA_TEX1 texture coordinate 1 array
GX_VA_TEX2 texture coordinate 2 array
GX_VA_TEX3 texture coordinate 3 array
GX_VA_TEX4 texture coordinate 4 array
GX_VA_TEX5 texture coordinate 5 array
GX_VA_TEX6 texture coordinate 6 array
GX_VA_TEX7 texture coordinate 7 array
base_ptr pointer to the first element in the attribute data array
stride the stride in bytes between the attribute data elements

Return Values

None.

Description

This function sets the array base pointer and stride for a single attribute. The array base and stride are used to calculate the address of the indexed attribute data using the following equation:

attr_addr = base_ptr + attr_idx * stride

When drawing a graphics primitive that has been enabled to use indexed attributes (see GXSetVtxDesc), attr_idx is supplied in the vertex data. The format and size of the data in the array must also be described using GXSetVtxAttrFmt.

You can also index other data, such as matrices (see GXLoadPosMtxIndx, GXLoadNrmMtxIndx3x3, and GXLoadTexMtxIndx), and light objects (see GXLoadLightObjIndx). For matrices and light objects, the size and format of the data to be loaded is implied by the function call.

There is a base pointer, base_ptr, for each type of attribute as well as for light data and matrices. Each attribute can be stored in its own array for maximum data compression (i.e., removal of redundant attribute data). The  stride is in byte units and is the distance between attributes in the array.

Indexed data is loaded into a vertex cache in the graphics processor. The vertex cache fetches 32 bytes of data for each cache miss. As a result, there is a small performance benefit in aligning attribute arrays to 32 bytes, and in arranging vertex data so that it doesn't span 32-byte boundaries. Conveniently enough, OSAlloc returns 32-byte aligned pointers. For static data arrays, the ATTRIBUTE_ALIGN(32) macro (for the MetroWerks compiler) can be used to align base_ptr to 32 bytes, as in:

u32 mydata[] ATTRIBUTE_ALIGN(32) = {
    // initialize data
};

See Also

GXSetVtxAttrFmt
GXSetVtxDesc

Revision History

2006/08/10 Corrected mistake with enum type.
2006/03/01 Initial version.


CONFIDENTIAL