Colobot
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Pages
src
graphics
core
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
38
enum
TexImgFormat
39
{
41
TEX_IMG_AUTO
,
43
TEX_IMG_RGB
,
45
TEX_IMG_BGR
,
47
TEX_IMG_RGBA
,
49
TEX_IMG_BGRA
50
};
51
58
enum
TexMinFilter
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
72
enum
TexMagFilter
73
{
74
TEX_MAG_FILTER_NEAREST,
75
TEX_MAG_FILTER_LINEAR
76
};
77
82
enum
TexWrapMode
83
{
84
TEX_WRAP_CLAMP,
85
TEX_WRAP_REPEAT
86
};
87
92
enum
TexMixOperation
93
{
95
TEX_MIX_OPER_DEFAULT
,
97
TEX_MIX_OPER_REPLACE
,
99
TEX_MIX_OPER_MODULATE
,
101
TEX_MIX_OPER_ADD
,
103
TEX_MIX_OPER_SUBTRACT
104
};
105
110
enum
TexMixArgument
111
{
113
TEX_MIX_ARG_TEXTURE
,
115
TEX_MIX_ARG_COMPUTED_COLOR
,
117
TEX_MIX_ARG_SRC_COLOR
,
119
TEX_MIX_ARG_FACTOR
120
};
121
129
struct
TextureCreateParams
130
{
132
bool
mipmap
;
134
TexImgFormat
format
;
136
TexMinFilter
minFilter
;
138
TexMagFilter
magFilter
;
140
bool
padToNearestPowerOfTwo
;
141
143
TextureCreateParams
()
144
{
LoadDefault
(); }
145
147
inline
void
LoadDefault
()
148
{
149
format
=
TEX_IMG_RGB
;
150
mipmap
=
false
;
151
padToNearestPowerOfTwo
=
false
;
152
153
minFilter
= TEX_MIN_FILTER_NEAREST;
154
magFilter
= TEX_MAG_FILTER_NEAREST;
155
}
156
};
157
165
struct
TextureStageParams
166
{
168
TexMixOperation
colorOperation
;
170
TexMixArgument
colorArg1
;
172
TexMixArgument
colorArg2
;
174
TexMixOperation
alphaOperation
;
176
TexMixArgument
alphaArg1
;
178
TexMixArgument
alphaArg2
;
180
TexWrapMode
wrapS
;
182
TexWrapMode
wrapT
;
184
Color
factor
;
185
187
TextureStageParams
()
188
{
LoadDefault
(); }
189
191
inline
void
LoadDefault
()
192
{
193
colorOperation
=
TEX_MIX_OPER_DEFAULT
;
194
colorArg1
=
TEX_MIX_ARG_COMPUTED_COLOR
;
195
colorArg2
=
TEX_MIX_ARG_TEXTURE
;
196
197
alphaOperation
=
TEX_MIX_OPER_DEFAULT
;
198
alphaArg1
=
TEX_MIX_ARG_COMPUTED_COLOR
;
199
alphaArg2
=
TEX_MIX_ARG_TEXTURE
;
200
201
wrapS
=
wrapT
= TEX_WRAP_REPEAT;
202
}
203
};
204
212
struct
Texture
213
{
215
unsigned
int
id
;
217
Math::IntPoint
size
;
219
Math::IntPoint
originalSize
;
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
Generated on Sat Jul 5 2014 09:25:02 for Colobot by
1.8.1.2