Colobot
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
texture.h
Go to the documentation of this file.
1 // * This file is part of the COLOBOT source code
2 // * Copyright (C) 2012, Polish Portal of Colobot (PPC)
3 // *
4 // * This program is free software: you can redistribute it and/or modify
5 // * it under the terms of the GNU General Public License as published by
6 // * the Free Software Foundation, either version 3 of the License, or
7 // * (at your option) any later version.
8 // *
9 // * This program is distributed in the hope that it will be useful,
10 // * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // * GNU General Public License for more details.
13 // *
14 // * You should have received a copy of the GNU General Public License
15 // * along with this program. If not, see http://www.gnu.org/licenses/.
16 
22 #pragma once
23 
24 
25 #include "graphics/core/color.h"
26 
27 #include "math/intpoint.h"
28 
29 
30 // Graphics module namespace
31 namespace Gfx {
32 
33 
39 {
50 };
51 
59 {
60  TEX_MIN_FILTER_NEAREST,
61  TEX_MIN_FILTER_LINEAR,
62  TEX_MIN_FILTER_NEAREST_MIPMAP_NEAREST,
63  TEX_MIN_FILTER_LINEAR_MIPMAP_NEAREST,
64  TEX_MIN_FILTER_NEAREST_MIPMAP_LINEAR,
65  TEX_MIN_FILTER_LINEAR_MIPMAP_LINEAR
66 };
67 
73 {
74  TEX_MAG_FILTER_NEAREST,
75  TEX_MAG_FILTER_LINEAR
76 };
77 
83 {
84  TEX_WRAP_CLAMP,
85  TEX_WRAP_REPEAT
86 };
87 
93 {
104 };
105 
111 {
120 };
121 
130 {
132  bool mipmap;
141 
144  { LoadDefault(); }
145 
147  inline void LoadDefault()
148  {
150  mipmap = false;
151  padToNearestPowerOfTwo = false;
152 
153  minFilter = TEX_MIN_FILTER_NEAREST;
154  magFilter = TEX_MAG_FILTER_NEAREST;
155  }
156 };
157 
166 {
185 
188  { LoadDefault(); }
189 
191  inline void LoadDefault()
192  {
196 
200 
201  wrapS = wrapT = TEX_WRAP_REPEAT;
202  }
203 };
204 
212 struct Texture
213 {
215  unsigned int id;
221  bool alpha;
222 
223  Texture()
224  {
225  id = 0;
226  alpha = false;
227  }
228 
230  bool Valid() const
231  {
232  return id != 0;
233  }
234 
236  void SetInvalid()
237  {
238  id = 0;
239  }
240 
242  inline bool operator<(const Texture &other) const
243  {
244  // Invalid textures are always "less than" every other texture
245 
246  if ( (! Valid()) && (! other.Valid()) )
247  return false;
248 
249  if (! Valid())
250  return true;
251 
252  if (! other.Valid())
253  return false;
254 
255  return id < other.id;
256  }
257 
259  inline bool operator==(const Texture &other) const
260  {
261  if (Valid() != other.Valid())
262  return false;
263  if ( (! Valid()) && (! other.Valid()) )
264  return true;
265 
266  return id == other.id;
267  }
268 };
269 
270 
271 } // namespace Gfx
272