]> git.lizzy.rs Git - dragonfireclient.git/blob - src/texture.h
d8310789d2bd735e7c8024844113ef7da88f4c8d
[dragonfireclient.git] / src / texture.h
1 /*
2 Minetest-c55
3 Copyright (C) 2010 celeron55, Perttu Ahola <celeron55@gmail.com>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19
20 #ifndef TEXTURE_HEADER
21 #define TEXTURE_HEADER
22
23 // This file now contains all that was here
24 #include "tile.h"
25
26 // TODO: Remove this
27 typedef u16 textureid_t;
28
29 #if 0
30
31 #include "common_irrlicht.h"
32 //#include "utility.h"
33 #include "debug.h"
34
35 /*
36         All textures are given a "texture id".
37         0 = nothing (a NULL pointer texture)
38 */
39 typedef u16 textureid_t;
40
41 /*
42         Every texture in the game can be specified by this.
43         
44         It exists instead of specification strings because arbitary
45         texture combinations for map nodes are handled using this,
46         and strings are too slow for that purpose.
47
48         Plain texture pointers are not used because they don't contain
49         content information by themselves. A texture can be completely
50         reconstructed by just looking at this, while this also is a
51         fast unique key to containers.
52 */
53
54 #define TEXTURE_SPEC_TEXTURE_COUNT 4
55
56 struct TextureSpec
57 {
58         TextureSpec()
59         {
60                 clear();
61         }
62
63         TextureSpec(textureid_t id0)
64         {
65                 clear();
66                 tids[0] = id0;
67         }
68
69         TextureSpec(textureid_t id0, textureid_t id1)
70         {
71                 clear();
72                 tids[0] = id0;
73                 tids[1] = id1;
74         }
75
76         void clear()
77         {
78                 for(u32 i=0; i<TEXTURE_SPEC_TEXTURE_COUNT; i++)
79                 {
80                         tids[i] = 0;
81                 }
82         }
83
84         bool empty() const
85         {
86                 for(u32 i=0; i<TEXTURE_SPEC_TEXTURE_COUNT; i++)
87                 {
88                         if(tids[i] != 0)
89                                 return false;
90                 }
91                 return true;
92         }
93
94         void addTid(textureid_t tid)
95         {
96                 for(u32 i=0; i<TEXTURE_SPEC_TEXTURE_COUNT; i++)
97                 {
98                         if(tids[i] == 0)
99                         {
100                                 tids[i] = tid;
101                                 return;
102                         }
103                 }
104                 // Too many textures
105                 assert(0);
106         }
107
108         bool operator==(const TextureSpec &other) const
109         {
110                 for(u32 i=0; i<TEXTURE_SPEC_TEXTURE_COUNT; i++)
111                 {
112                         if(tids[i] != other.tids[i])
113                                 return false;
114                 }
115                 return true;
116         }
117
118         bool operator<(const TextureSpec &other) const
119         {
120                 for(u32 i=0; i<TEXTURE_SPEC_TEXTURE_COUNT; i++)
121                 {
122                         if(tids[i] >= other.tids[i])
123                                 return false;
124                 }
125                 return true;
126         }
127
128         // Ids of textures. They are blit on each other.
129         textureid_t tids[TEXTURE_SPEC_TEXTURE_COUNT];
130 };
131
132 #endif
133
134 #endif