10#include "ps2gl/debug.h"
11#include "ps2s/cpu_matrix.h"
13#include "ps2gl/drawcontext.h"
14#include "ps2gl/glcontext.h"
25 static const int MaxStackDepth = 16;
26 cpu_mat_44 Matrices[MaxStackDepth], InverseMatrices[MaxStackDepth];
34 Matrices[0].set_identity();
35 InverseMatrices[0].set_identity();
41 virtual void Pop() = 0;
42 virtual void Push() = 0;
43 virtual void Concat(
const cpu_mat_44& xform,
const cpu_mat_44& inverse) = 0;
44 virtual void SetTop(
const cpu_mat_44& newMat,
const cpu_mat_44& newInv) = 0;
60 mErrorIf(CurStackDepth == 0,
"No matrices to pop!");
62 GLContext.GetImmDrawContext().SetVertexXformValid(
false);
67 mErrorIf(CurStackDepth == MaxStackDepth - 1,
69 Matrices[CurStackDepth + 1] = Matrices[CurStackDepth];
70 InverseMatrices[CurStackDepth + 1] = InverseMatrices[CurStackDepth];
74 void Concat(
const cpu_mat_44& xform,
const cpu_mat_44& inverse)
76 cpu_mat_44& curMat = Matrices[CurStackDepth];
77 cpu_mat_44& curInv = InverseMatrices[CurStackDepth];
78 curMat = curMat * xform;
79 curInv = inverse * curInv;
80 GLContext.GetImmDrawContext().SetVertexXformValid(
false);
83 void SetTop(
const cpu_mat_44& newMat,
const cpu_mat_44& newInv)
85 Matrices[CurStackDepth] = newMat;
86 InverseMatrices[CurStackDepth] = newInv;
87 GLContext.GetImmDrawContext().SetVertexXformValid(
false);
90 const cpu_mat_44& GetTop()
const {
return Matrices[CurStackDepth]; }
91 const cpu_mat_44& GetInvTop()
const {
return InverseMatrices[CurStackDepth]; }
107 void Concat(
const cpu_mat_44& xform,
const cpu_mat_44& inverse);
108 void SetTop(
const cpu_mat_44& newMat,
const cpu_mat_44& newInv);