/* Transformation matrix stack code V1.21 19/8/04
   Copyright 2008 Jeffrey Lee
   This file is part of WOUM.
   WOUM is free software: you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation, either version 3 of the License, or
   (at your option) any later version.
   WOUM is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.
   You should have received a copy of the GNU General Public License
   along with WOUM.  If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef _TMATSTACK_H
#define _TMATSTACK_H

#include "tmat.h"

/* Number of matricies per stack */
#define TMATSTACK_SIZE 8

typedef struct {
	tmat s[TMATSTACK_SIZE]; /* The stack */
	int top; /* Top entry in stack */
} tmats;
typedef struct {
	tmat16 s[TMATSTACK_SIZE]; /* The stack */
	int top; /* Top entry in stack */
} tmats16;
typedef struct {
	tmat24 s[TMATSTACK_SIZE]; /* The stack */
	int top; /* Top entry in stack */
} tmats24;
typedef struct {
	tmat20 s[TMATSTACK_SIZE]; /* The stack */
	int top; /* Top entry in stack */
} tmats20;
typedef struct {
	tmat48 s[TMATSTACK_SIZE]; /* The stack */
	int top; /* Top entry in stack */
} tmats48;

extern tmats *tmats_alloc();
extern tmats16 *tmats16_alloc();
extern tmats24 *tmats24_alloc();
extern tmats20 *tmats20_alloc();
extern tmats48 *tmats48_alloc();
/* Creates and returns a pointer to a new tmat stack, or 0 for failure
*/

extern void tmats_free(tmats *s);
extern void tmats16_free(tmats16 *s);
extern void tmats24_free(tmats24 *s);
extern void tmats20_free(tmats20 *s);
extern void tmats48_free(tmats48 *s);
/* Deletes a tmat stack
*/

extern tmat *tmats_top(tmats *s);
extern tmat16 *tmats16_top(tmats16 *s);
extern tmat24 *tmats24_top(tmats24 *s);
extern tmat20 *tmats20_top(tmats20 *s);
extern tmat48 *tmats48_top(tmats48 *s);
/* Returns a pointer to the tmat ontop of the stack
*/

extern tmat *tmats_pop(tmats *s);
extern tmat16 *tmats16_pop(tmats16 *s);
extern tmat24 *tmats24_pop(tmats24 *s);
extern tmat20 *tmats20_pop(tmats20 *s);
extern tmat48 *tmats48_pop(tmats48 *s);
/* Removes the top tmat from the stack and returns a pointer to the one below it
   If you try and remove the last tmat, it will be replaced with an identity
   matrix and a pointer to that will be returned
*/

extern tmat *tmats_dup(tmats *s);
extern tmat16 *tmats16_dup(tmats16 *s);
extern tmat24 *tmats24_dup(tmats24 *s);
extern tmat20 *tmats20_dup(tmats20 *s);
extern tmat48 *tmats48_dup(tmats48 *s);
/* Duplicates the top tmat and returns a pointer to it, or 0 if the stack is full
*/

#endif
