Colobot
texture.h
Go to the documentation of this file.
1 /*
2  * This file is part of the Colobot: Gold Edition source code
3  * Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam
4  * http://epsitec.ch; http://colobot.info; http://github.com/colobot
5  *
6  * This program is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14  * See the GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see http://gnu.org/licenses
18  */
19 
25 #pragma once
26 
27 
28 #include "graphics/core/color.h"
29 
30 #include "math/intpoint.h"
31 
32 
33 // Graphics module namespace
34 namespace Gfx
35 {
36 
37 
43 {
54 };
55 
63 {
64  TEX_FILTER_NEAREST,
65  TEX_FILTER_BILINEAR,
66  TEX_FILTER_TRILINEAR
67 };
68 
76 {
77  TEX_MIN_FILTER_NEAREST,
78  TEX_MIN_FILTER_LINEAR,
79  TEX_MIN_FILTER_NEAREST_MIPMAP_NEAREST,
80  TEX_MIN_FILTER_LINEAR_MIPMAP_NEAREST,
81  TEX_MIN_FILTER_NEAREST_MIPMAP_LINEAR,
82  TEX_MIN_FILTER_LINEAR_MIPMAP_LINEAR
83 };
84 
90 {
91  TEX_MAG_FILTER_NEAREST,
92  TEX_MAG_FILTER_LINEAR
93 };
94 
100 {
101  TEX_WRAP_CLAMP,
102  TEX_WRAP_CLAMP_TO_BORDER,
103  TEX_WRAP_REPEAT
104 };
105 
111 {
122 };
123 
129 {
146 };
147 
156 {
158  bool mipmap = false;
162  TexFilter filter = TEX_FILTER_NEAREST;
165 
167  void LoadDefault()
168  {
169  *this = TextureCreateParams();
170  }
171 };
172 
181 {
195  TexWrapMode wrapS = TEX_WRAP_REPEAT;
197  TexWrapMode wrapT = TEX_WRAP_REPEAT;
200 
202  void LoadDefault()
203  {
204  *this = TextureStageParams();
205  }
206 };
207 
213 {
226 };
227 
235 {
236  struct Coord
237  {
238  TexGenMode mode = TEX_GEN_NONE;
239  float plane[4] = {};
240  };
241  Coord coords[4];
242 
243  void LoadDefault()
244  {
245  *this = TextureGenerationParams();
246  }
247 };
248 
256 struct Texture
257 {
259  unsigned int id = 0;
265  bool alpha = false;
266 
268  bool Valid() const
269  {
270  return id != 0;
271  }
272 
274  void SetInvalid()
275  {
276  id = 0;
277  }
278 
280  bool operator<(const Texture &other) const
281  {
282  // Invalid textures are always "less than" every other texture
283 
284  if ( (! Valid()) && (! other.Valid()) )
285  return false;
286 
287  if (! Valid())
288  return true;
289 
290  if (! other.Valid())
291  return false;
292 
293  return id < other.id;
294  }
295 
297  bool operator==(const Texture &other) const
298  {
299  if (Valid() != other.Valid())
300  return false;
301  if ( (! Valid()) && (! other.Valid()) )
302  return true;
303 
304  return id == other.id;
305  }
306 };
307 
308 
309 } // namespace Gfx
310 
Color from texture unit 1.
Definition: texture.h:135
bool Valid() const
Returns whether the texture is valid (ID != 0)
Definition: texture.h:268
Try to determine automatically (may not work)
Definition: texture.h:45
bool mipmap
Whether to generate mipmaps.
Definition: texture.h:158
(Source) color of textured fragment (diffuse in DirectX; primary color in OpenGL) ...
Definition: texture.h:143
TexMixOperation
Multitexture mixing operation.
Definition: texture.h:110
bool operator<(const Texture &other) const
Comparator for use in texture maps and sets.
Definition: texture.h:280
TexMixArgument
Multitexture mixing argument.
Definition: texture.h:128
Texture generation mode.
unsigned int id
ID of the texture in graphics engine; 0 = invalid texture.
Definition: texture.h:259
Color from current texture.
Definition: texture.h:131
TexWrapMode
Wrapping mode for texture coords.
Definition: texture.h:99
Normal mapping mode.
Definition: texture.h:223
Constant color (texture factor in DirectX; texture env color in OpenGL)
Definition: texture.h:145
Math::IntPoint size
Size of texture.
Definition: texture.h:261
Color from texture unit 2.
Definition: texture.h:137
TexMagFilter
Texture magnification filter.
Definition: texture.h:89
Parameters for a texture unit.
Definition: texture.h:180
Color from texture unit 3.
Definition: texture.h:139
bool operator==(const Texture &other) const
Comparator.
Definition: texture.h:297
TexMinFilter
Texture minification filter.
Definition: texture.h:75
Color computed by previous texture unit (current in DirectX; previous in OpenGL)
Definition: texture.h:141
RGBA triplet, 4 bytes.
Definition: texture.h:51
TexImgFormat format
Format of source image data.
Definition: texture.h:160
Parameters for texture coordinate generation.
Definition: texture.h:234
Eye linear mode.
Definition: texture.h:219
TexImgFormat
Format of image data.
Definition: texture.h:42
Spherical mapping mode.
Definition: texture.h:221
Color structs and related functions.
Parameters for texture creation.
Definition: texture.h:155
Color from texture unit 0.
Definition: texture.h:133
void SetInvalid()
Sets the ID to invalid value (0)
Definition: texture.h:274
TexFilter filter
General texture filtering mode.
Definition: texture.h:162
Color factor
Constant color factor (for TEX_MIX_ARG_FACTOR)
Definition: texture.h:199
= Arg1 * Arg2
Definition: texture.h:117
BGR triplet, 3 bytes.
Definition: texture.h:49
= Arg1 + Arg2
Definition: texture.h:119
bool padToNearestPowerOfTwo
Pad the image to nearest power of 2 dimensions.
Definition: texture.h:164
Namespace for (new) graphics code.
Definition: app.h:49
No texture generation.
Definition: texture.h:215
= Arg1 - Arg2
Definition: texture.h:121
Info about a texture.
Definition: texture.h:256
Definition: texture.h:236
TexFilter
General texture filtering mode.
Definition: texture.h:62
void LoadDefault()
Loads the default values.
Definition: texture.h:167
Reflection mapping mode.
Definition: texture.h:225
2D Point with integer coords
Definition: intpoint.h:41
Math::IntPoint originalSize
Original size of texture (as loaded from image)
Definition: texture.h:263
RGBA color.
Definition: color.h:39
void LoadDefault()
Loads the default values.
Definition: texture.h:202
BGRA triplet, 4 bytes.
Definition: texture.h:53
IntPoint struct.
= Arg1
Definition: texture.h:115
Default operation on default params (modulate on computed & texture)
Definition: texture.h:113
RGB triplet, 3 bytes.
Definition: texture.h:47
Object linear mode.
Definition: texture.h:217