MTXInitStack

C Specification

#include<revolution/mtx.h>
void MTXInitStack ( MtxStack* sPtr, u32 numMtx );

Arguments

sPtr Pointer to a MtxStack structure.
numMtx Number of matrices in the matrix stack referenced by sPtr. This must be the same value as that used immediately before calling MTXAllocStack.

Return Values

None.

Description

This function is the companion to MTXAllocStack. After MTXAllocStack allocates memory to an MTXStack's stackBase pointer, MTXInitStack must be called to initialize the MTXStack's remaining members. MTXAllocStack and MTXInitStack are essentially two halves of the same function — MTXAllocStack was separated out and converted to a macro in mtx.h to expose its memory allocation call.

MTXInitStack sets sPtr->numMtx to numMtx and sets sPtr->stackPtr equal to NULL, indicating an empty stack.

Creation of a matrix stack must follow these steps:

a) Create a MtxStack structure either through a normal variable definition or by a call to a memory allocation routine. For example:

MtxStack sPtr ;           MtxStackPtr sPtr = OSAlloc( sizeof(MtxStack) )  ;

b) Use the macro MTXAllocStack (sPtr,numMtx) to allocate numMtx matrices to sPtr->stackBase

c) Initialize the remaining members of the MtxStack structure with a call to MTXInitStacknumMtx must have the same value as that used for MTXAllocStack.

See Also

Mtx, MtxPtr
MtxStack, MtxStackPtr

MTXAllocStack
MTXFreeStack

OSAlloc
OSFree

Revision History

03/01/2006 Initial version.