summaryrefslogtreecommitdiff
path: root/Source/modules/asura-core/Graphics/MatrixStack.cpp
blob: 987d29ccba513b8f0f846b77cfa0b7c5c2979c8e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#include "MatrixStack.h"

namespace_begin(AsuraEngine)
namespace_begin(Graphics)

MatrixStack::MatrixStack()
	: top(0)
{
	// ջʼջô˱֤ջԶǿգȡֵ
	m_Stack[top].SetIdentity();
}

MatrixStack::~MatrixStack()
{
}

void MatrixStack::LoadIdentity()
{
	m_Stack[top].SetIdentity();
}

bool MatrixStack::Push()
{
	if (top == ASURA_MAX_MATRIX_STACK_DEPTH - 1)
		return false;
	++top; 
	m_Stack[top] = m_Stack[top - 1];
	return true;
}

bool MatrixStack::Pop()
{
	if (top == 0)
		return false;
	--top; 
	return true;
}

AEMath::Matrix44& MatrixStack::GetTop()
{
	return m_Stack[top];
}

uint MatrixStack::GetTopIndex()
{
	return top; 
}

uint MatrixStack::GetCapacity()
{
	return ASURA_MAX_MATRIX_STACK_DEPTH;
}

void MatrixStack::Ortho(float left, float right, float bottom, float top, float near, float far)
{
	m_Stack[this->top].Ortho(left, right, bottom, top, near, far);
}

void MatrixStack::Rotate(float angle)
{
	m_Stack[top].Rotate(angle);
}

void MatrixStack::Translate(float x, float y)
{
	m_Stack[top].Translate(x, y);
}

void MatrixStack::Scale(float x, float y)
{
	m_Stack[top].Scale(x, y);
}

namespace_end
namespace_end