-
Notifications
You must be signed in to change notification settings - Fork 2
/
TextureManager.cpp
75 lines (58 loc) · 1.58 KB
/
TextureManager.cpp
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 "stdafx.h"
#include "TextureManager.h"
void TextureManager::render(HDC hdc)
{
Sorting();
for (auto iter = _lRenderObject.begin(); iter != _lRenderObject.end(); ++iter) {
if (iter->isFrameImage) {
IMAGEMANAGER->frameRender(iter->imgKey, hdc, (*iter->rc).left, (*iter->rc).top, *iter->frameX, *iter->frameY, CAMERA->GetZoom());
}
else if (iter->isAlaphImage) {
IMAGEMANAGER->alphaRender(iter->imgKey, hdc, (*iter->rc).left, (*iter->rc).top, *iter->alpha, CAMERA->GetZoom());
}
else {
IMAGEMANAGER->render(iter->imgKey, hdc, (*iter->rc).left, (*iter->rc).top, CAMERA->GetZoom());
}
}
}
void TextureManager::release()
{
_lRenderObject.clear();
}
// yÃà Á¤·Ä
void TextureManager::Sorting()
{
sort(_lRenderObject.begin(), _lRenderObject.end(), Compare);
}
bool TextureManager::Compare(tagRender * a, tagRender * b)
{
return (*a).rc->bottom < (*b).rc->bottom;
}
void TextureManager::AddRender(string p_imgKey, RECT *rc, LAYER p_layer, int* p_frameX, int* p_frameY, BYTE* p_alpha, bool isFrameImage)
{
tagRender t_render;
t_render.imgKey = p_imgKey;
t_render.layer = p_layer;
t_render.rc = rc;
if (p_frameX != nullptr)
{
t_render.frameX = p_frameX;
t_render.frameY = p_frameY;
}
t_render.isFrameImage = isFrameImage;
if (p_alpha != nullptr) {
t_render.isAlaphImage = true;
t_render.alpha = p_alpha;
}
_lRenderObject.push_back(t_render);
}
void TextureManager::CheckRemoveRenderObject()
{
for (auto iter = _lRenderObject.begin(); iter != _lRenderObject.end();) {
if ((*iter).rc == nullptr) {
iter = _lRenderObject.erase(iter);
}
else
++iter;
}
}