1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 2<html> 3 4<head> 5<META http-equiv="Content-Type" content="text/html; charset=windows-1252"> 6<META name="GENERATOR" content="Microsoft FrontPage 5.0"> 7<META http-equiv="Content-Style-Type" content="text/css"> 8<LINK rel="stylesheet" type="text/css" href="../../CSS/revolution.css"> 9<title>GXSetArray</title> 10</head> 11 12<body> 13 14<h1 align="left">GXSetArray</h1> 15 16<h2>Syntax</h2> 17<dl><dd><pre class="construction"> 18#include <revolution/gx.h> 19 20void GXSetArray( <A href="../Enumerated_Types/GXAttr.html">GXAttr</A> attr, const void* base_ptr, u8 stride ); 21</pre></dd></dl> 22 23<h2>Arguments</h2> 24<TABLE class="arguments" border="1" > 25 <tr> 26<TH>attr</TH> 27<TD>Specifies the attribute array name. <BR>Accepted values are:<BR> 28 <TABLE class="arguments" border="1" > 29 <tr> 30<TD bgcolor="#C0C0C0">Attributes</TD> 31<TD bgcolor="#C0C0C0">Description</TD> 32 </tr> 33 <tr> 34<TH>GX_POS_MTX_ARRAY</TH> 35<TD>Array of position coordinate matrices.</TD> 36 </tr> 37 <tr> 38<TH>GX_NRM_MTX_ARRAY</TH> 39<TD>Array of normal matrices.</TD> 40 </tr> 41 <tr> 42<TH>GX_TEX_MTX_ARRAY</TH> 43<TD>Texture matrix array.</TD> 44 </tr> 45 <tr> 46<TH>GX_LIGHT_ARRAY</TH> 47<TD>Light object array.</TD> 48 </tr> 49 <tr> 50<TH>GX_VA_POS</TH> 51<TD>Position coordinates array.</TD> 52 </tr> 53 <tr> 54<TH>GX_VA_NRM or<br> GX_VA_NBT</TH> 55<TD>Normal, or normal/binormal/tangent array.</TD> 56 </tr> 57 <tr> 58<TH>GX_VA_CLR0</TH> 59<TD>Color 0 array.</TD> 60 </tr> 61 <tr> 62<TH>GX_VA_CLR1</TH> 63<TD>Color 1 array.</TD> 64 </tr> 65 <tr> 66<TH>GX_VA_TEX0</TH> 67<TD>Texture coordinate 0 array.</TD> 68 </tr> 69 <tr> 70<TH>GX_VA_TEX1</TH> 71<TD>Texture coordinate 1 array.</TD> 72 </tr> 73 <tr> 74<TH>GX_VA_TEX2</TH> 75<TD>Texture coordinate 2 array.</TD> 76 </tr> 77 <tr> 78<TH>GX_VA_TEX3</TH> 79<TD>Texture coordinate 3 array.</TD> 80 </tr> 81 <tr> 82<TH>GX_VA_TEX4</TH> 83<TD>Texture coordinate 4 array.</TD> 84 </tr> 85 <tr> 86<TH>GX_VA_TEX5</TH> 87<TD>Texture coordinate 5 array.</TD> 88 </tr> 89 <tr> 90<TH>GX_VA_TEX6</TH> 91<TD>Texture coordinate 6 array.</TD> 92 </tr> 93 <tr> 94<TH>GX_VA_TEX7</TH> 95<TD>Texture coordinate 7 array.</TD> 96 </tr> 97 </TABLE> 98 </TD> 99 </tr> 100 <tr> 101<TH>base_ptr</TH> 102<TD>Pointer to the first element in the attribute data array.</TD> 103 </tr> 104 <tr> 105<TH>stride</TH> 106<TD>Stride in bytes between the attribute data elements.</TD> 107 </tr> 108</TABLE> 109 110<h2>Return Values</h2> 111<p>None.</p> 112 113<H2>Description</H2> 114<P>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:</P> 115<P><EM>attr_addr = <SPAN class="argument">base_ptr</SPAN> + attr_idx * <SPAN class="argument">stride</SPAN></EM></P> 116<P>When drawing a graphics primitive that has been enabled to use indexed attributes (see the <A href="GXSetVtxDesc.html"><CODE>GXSetVtxDesc</CODE></A> function), <EM>attr_idx</EM> is supplied in the vertex data. The format and size of the data in the array must also be described in the <A href="GXSetVtxAttrFmt.html"><CODE>GXSetVtxAttrFmt</CODE></A> function.</P> 117<P>You can also index other data, such as matrices (see the <A href="../Transform/GXLoadPosMtxIndx.html"><CODE>GXLoadPosMtxIndx</CODE></A>,<A href="../Transform/GXLoadNrmMtxIndx3x3.html"><CODE>GXLoadNrmMtxIndx3x3</CODE></A> and<A href="../Transform/GXLoadTexMtxIndx.html"><CODE>GXLoadTexMtxIndx</CODE></A> functions), and light objects (see the <A href="../Lighting/GXLoadLightObjIndx.html"><CODE>GXLoadLightObjIndx</CODE></A> function). For matrices and light objects, the size and format of the data to be loaded is implied by the function call.</P> 118<P>There is a base pointer, <SPAN class="argument">base_ptr</SPAN>, 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 <SPAN class="argument">stride</SPAN> is in byte units and indicates the distance between attributes in the array.</P> 119<P>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, the <A href="../../os/Alloc/OSAlloc.html"><CODE>OSAlloc</CODE></A> function returns 32-byte aligned pointers. For static data arrays, the <CODE>ATTRIBUTE_ALIGN(32)</CODE> macro (for the MetroWerks compiler) can be used to align <SPAN class="argument">base_ptr</SPAN> to 32 bytes, as in:</P> 120<P><code>u32 mydata[] ATTRIBUTE_ALIGN(32) = {<br> // initialize data<br> };</code></P> 121 122<h2>See Also</h2> 123<p class="reference"> 124<a href="GXSetVtxAttrFmt.html">GXSetVtxAttrFmt</a>, 125<a href="GXSetVtxDesc.html">GXSetVtxDesc</a> 126</p> 127 128<H2>Revision History</H2> 129<P> 1302006/08/10 Corrected mistake with enum type.<br>2006/03/01 Initial version.<br> 131</P> 132 133<hr><p>CONFIDENTIAL</p></body> 134</HTML>