-
Notifications
You must be signed in to change notification settings - Fork 1
/
texmanager.cpp
68 lines (56 loc) · 1.42 KB
/
texmanager.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
/******************************************************
g-Matrix3D Neo Engine
Copyright (c)2003 Kim Seong Wan (kaswan, Â𻧱ͽÅ)
E-mail: kaswan@hitel.net
http://www.g-matrix.pe.kr
*******************************************************/
#include "stdafx.h"
#include "texmanager.h"
void CTexManager::Init(int num = 100)
{
TexList = new CTexture[num];
MaxTexIndex = num;
}
void CTexManager::DeInit(void)
{
if (TexList) delete[] TexList;
TexList = NULL;
}
int CTexManager::Load(char * name)
{
if (NumTexIndex == MaxTexIndex) return -1;
int i = NumTexIndex;
if (TexList[i].pixeltype == EMPTY)
{
TexList[i].pixeltype = RGBA;
TexList[i].Load(name);
NumTexIndex = i + 1;
CurrentTexIndex = i;
::pTex = TexList[i].pTex;
::TEXWIDTH = TexList[i].TextureWidth;
::TEXHEIGHT = TexList[i].TextureHeight;
::TEXWIDTHBOUND = TEXWIDTH - 1;
::TEXHEIGHTBOUND = TEXHEIGHT - 1;
return i;
}
return -1;
}
int CTexManager::Create(int w, int h)
{
if (NumTexIndex == MaxTexIndex) return -1;
int i = NumTexIndex;
if (TexList[i].pixeltype == EMPTY)
{
TexList[i].pixeltype = RGBA;
TexList[i].Create(w, h);
NumTexIndex = i + 1;
CurrentTexIndex = i;
::pTex = TexList[i].pTex;
::TEXWIDTH = TexList[i].TextureWidth;
::TEXHEIGHT = TexList[i].TextureHeight;
::TEXWIDTHBOUND = TEXWIDTH - 1;
::TEXHEIGHTBOUND = TEXHEIGHT - 1;
return i;
}
return -1;
}