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 align="left">MTXInitStack</H1>
12<H2 align="left">C Specification</H2>
13<BLOCKQUOTE><CODE><CODE>#include&lt;revolution/mtx.h&gt;</CODE></CODE></BLOCKQUOTE>
14<BLOCKQUOTE><CODE><CODE>void MTXInitStack ( MtxStack* <EM>sPtr</EM>, u32 <EM>numMtx</EM> );</CODE></CODE></BLOCKQUOTE>
15<H2 align="left">Arguments</H2>
16<DIV align="left">
17<TABLE border="1" cellpadding="3" cellspacing="0.1">
18  <TBODY>
19    <TR>
20<TD width="120" valign="top" align="left" bgcolor="#ffffe8"><CODE><STRONG><EM>sPtr</EM></STRONG></CODE></TD>
21<TD width="520" valign="top" align="left">Pointer to a <A href="../structures/MtxStack_MtxStackPtr.html"><CODE>MtxStack</CODE></A> structure.</TD>
22    </TR>
23    <TR>
24<TD width="120" valign="top" align="left" bgcolor="#ffffe8"><CODE><STRONG><EM>numMtx</EM></STRONG></CODE></TD>
25<TD width="520">Number of matrices in the matrix stack referenced by <EM><STRONG><CODE>sPtr</CODE></STRONG></EM>. This must be the same value as that used immediately before calling <CODE>MTXAllocStack</CODE>.</TD>
26    </TR>
27  </TBODY>
28</TABLE>
29</DIV>
30<H2 align="left">Return Values</H2>
31<P align="left">None.</P>
32<H2 align="left">Description</H2>
33<P>This function is the companion to <a href="MTXAllocStack.html"><code>MTXAllocStack</code></a>.&nbsp;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 <A href="../structures/MtxStack_MtxStackPtr.html"><CODE>MTXStack</CODE></A>'s remaining members.&nbsp;<a href="MTXAllocStack.html"><code>MTXAllocStack</code></a> and <code>MTXInitStack</code> are essentially two halves of the same function &mdash; <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>
34<P><code>MTXInitStack</code> sets <code><strong><em>sPtr</em>-&gt;numMtx</strong></code> to <code><em><strong>numMtx</strong></em></code> and sets <code><strong><em>sPtr</em>-&gt;stackPtr</strong></code> equal to <code><strong>NULL</strong></code>, indicating an empty stack.</P>
35<P>Creation of a matrix stack must follow these steps:</P>
36<P>a)&nbsp;Create a MtxStack structure either through a normal variable definition or by a call to a memory allocation routine. For example:</P>
37<P align="left"><CODE>MtxStack <EM><STRONG>sPtr </STRONG></EM>; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MtxStackPtr <EM><STRONG>sPtr</STRONG></EM> = OSAlloc( sizeof(MtxStack) )&nbsp; ;</CODE></P>
38<P>b) Use the macro <a href="MTXAllocStack.html"><code>MTXAllocStack</code></a> (<code><em><strong>sPtr</strong></em>,<em><strong>numMtx</strong></em></code>) to allocate <code><em><strong>numMtx</strong></em></code> matrices to <code><strong><em>sPtr</em>-&gt;stackBase</strong></code>.&nbsp;</P>
39<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>.&nbsp;<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>
40
41
42<H2 align="left">See Also</H2>
43<P align="left"><A href="../structures/Mtx_MtxPtr.html"><CODE>Mtx, MtxPtr</CODE></A><BR> <CODE><A href="../structures/MtxStack_MtxStackPtr.html">MtxStack, MtxStackPtr</A></CODE></P>
44<P align="left"><A href="MTXAllocStack.html"><CODE>MTXAllocStack</CODE></A><BR> <A href="MTXFreeStack.html"><CODE>MTXFreeStack</CODE></A></P>
45<P align="left"><A href="../../os/Alloc/OSAlloc.html"><CODE>OSAlloc</CODE></A><BR> <A href="../../os/Alloc/OSFree.html"><CODE>OSFree</CODE></A></P>
46<H2>Revision History</H2>
47<P>2006/03/01 Initial version.</P>
48<hr>
49<P>CONFIDENTIAL</p>
50</BODY>
51</HTML>