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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
|
/*
Minetest-c55
Copyright (C) 2010 celeron55, Perttu Ahola <celeron55@gmail.com>
This program 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 2 of the License, or
(at your option) any later version.
This program 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 this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef TEXTURE_HEADER
#define TEXTURE_HEADER
#include "common_irrlicht.h"
//#include "utility.h"
#include "debug.h"
/*
All textures are given a "texture id".
0 = nothing (a NULL pointer texture)
*/
typedef u16 textureid_t;
/*
Every texture in the game can be specified by this.
It exists instead of specification strings because arbitary
texture combinations for map nodes are handled using this,
and strings are too slow for that purpose.
Plain texture pointers are not used because they don't contain
content information by themselves. A texture can be completely
reconstructed by just looking at this, while this also is a
fast unique key to containers.
*/
#define TEXTURE_SPEC_TEXTURE_COUNT 4
struct TextureSpec
{
TextureSpec()
{
clear();
}
TextureSpec(textureid_t id0)
{
clear();
tids[0] = id0;
}
TextureSpec(textureid_t id0, textureid_t id1)
{
clear();
tids[0] = id0;
tids[1] = id1;
}
void clear()
{
for(u32 i=0; i<TEXTURE_SPEC_TEXTURE_COUNT; i++)
{
tids[i] = 0;
}
}
bool empty() const
{
for(u32 i=0; i<TEXTURE_SPEC_TEXTURE_COUNT; i++)
{
if(tids[i] != 0)
return false;
}
return true;
}
void addTid(textureid_t tid)
{
for(u32 i=0; i<TEXTURE_SPEC_TEXTURE_COUNT; i++)
{
if(tids[i] == 0)
{
tids[i] = tid;
return;
}
}
// Too many textures
assert(0);
}
bool operator==(const TextureSpec &other) const
{
for(u32 i=0; i<TEXTURE_SPEC_TEXTURE_COUNT; i++)
{
if(tids[i] != other.tids[i])
return false;
}
return true;
}
bool operator<(const TextureSpec &other) const
{
for(u32 i=0; i<TEXTURE_SPEC_TEXTURE_COUNT; i++)
{
if(tids[i] >= other.tids[i])
return false;
}
return true;
}
// Ids of textures. They are blit on each other.
textureid_t tids[TEXTURE_SPEC_TEXTURE_COUNT];
};
#endif
|