1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 2<HTML> 3<HEAD> 4<META http-equiv="Content-Type" content="text/html; charset=windows-1252"> 5<META name="GENERATOR" content="Microsoft FrontPage 5.0"> 6<META http-equiv="Content-Style-Type" content="text/css"> 7<LINK rel="stylesheet" type="text/css" href="../../CSS/revolution.css"> 8<TITLE>MTXInitStack</TITLE> 9</HEAD> 10<BODY> 11<H1>MTXInitStack</H1> 12 13<H2>Syntax</H2> 14<dl><dd><pre class="construction"> 15#include<revolution/mtx.h> 16 17void MTXInitStack ( MtxStack* sPtr, u32 numMtx ); 18</pre></dd></dl> 19 20<H2>Arguments</H2> 21<TABLE class="arguments" border="1" > 22 <TBODY> 23 <TR> 24<TH>sPtr</TH> 25<TD>Pointer to a <a href="../Structures/MtxStack_MtxStackPtr.html"><code>MtxStack</code></a> structure.</TD> 26 </TR> 27 <TR> 28<TH>numMtx</TH> 29<TD>Number of matrices in the matrix stack referenced by <SPAN class="argument">sPtr</SPAN>. This must be the same value as that used immediately before calling <CODE>MTXAllocStack</CODE>.</TD> 30 </TR> 31 </TBODY> 32</TABLE> 33 34<H2>Return Values</H2> 35<P>None.</P> 36 37<H2>Description</H2> 38<P>This function is the companion to <a href="MTXAllocStack.html"><code>MTXAllocStack</code></a>. After <a href="MTXAllocStack.html"><code>MTXAllocStack</code></a> allocates memory to an <A href="../structures/MtxStack_MtxStackPtr.html"><CODE>MTXStack</CODE></A>'s <strong>stackBase</strong> pointer, <code>MTXInitStack</code> must be called to initialize the remaining members of <A href="../structures/MtxStack_MtxStackPtr.html"><CODE>MTXStack</CODE></A>. <a href="MTXAllocStack.html"><code>MTXAllocStack</code></a> and <code>MTXInitStack</code> are essentially two halves of the same function. <a href="MTXAllocStack.html"><code>MTXAllocStack</code></a> was separated out and converted to a macro in <code>mtx.h</code> to expose its memory allocation call.</P> 39<P><code>MTXInitStack</code> sets <code><strong><em>sPtr</em>->numMtx</strong></code> to <code><em><strong>numMtx</strong></em></code> and, to indicate an empty stack, sets <code><strong><em>sPtr</em>->stackPtr</strong></code> to <code><strong>NULL</strong></code>.</P> 40<P>Creation of a matrix stack must follow these steps:</P> 41<P>a) Create an <CODE>MtxStack</CODE> structure either through a normal variable definition or by a call to a memory allocation routine. For example:</P> 42<dl><dd><pre class="construction"> 43MtxStack <SPAN class="argument">sPtr</SPAN>; MtxStackPtr <SPAN class="argument">sPtr</SPAN> = OSAlloc( sizeof(MtxStack) ) ; 44</pre></dd></dl> 45<P>b) Use the <A href="MTXAllocStack.html"><CODE>MTXAllocStack</CODE></A> (<SPAN class="argument">sPtr</SPAN>, <SPAN class="argument">numMtx</SPAN>) macro to allocate <SPAN class="argument">numMtx</SPAN> matrices to <SPAN class="argument">sPtr</SPAN><CODE><STRONG>->stackBase</STRONG></CODE>.</P> 46<P>c) Initialize the remaining members of the <A href="../structures/MtxStack_MtxStackPtr.html"><code>MtxStack</code></a> structure with a call to <code>MTXInitStack</code>. <code><em><strong>numMtx</strong></em></code> must have the same value as that used for <a href="MTXAllocStack.html"><code>MTXAllocStack</code></a>.</P> 47 48<H2>See Also</H2> 49<P class="reference"> 50<A href="../structures/Mtx_MtxPtr.html">Mtx, MtxPtr</A>, 51<A href="../structures/MtxStack_MtxStackPtr.html">MtxStack, MtxStackPtr</A>, 52<A href="MTXAllocStack.html">MTXAllocStack</A>, 53<A href="MTXFreeStack.html">MTXFreeStack</A>, 54<A href="../../os/Alloc/OSAlloc.html">OSAlloc</A>, 55<A href="../../os/Alloc/OSFree.html">OSFree</A> 56</P> 57 58<H2>Revision History</H2> 59<P> 602006/03/01 Initial version.<br> 61</P> 62 63<hr><p>CONFIDENTIAL</p></body> 64</HTML>