Irrlicht 3D Engine
ITexture.h
Go to the documentation of this file.
1 // Copyright (C) 2002-2012 Nikolaus Gebhardt
2 // This file is part of the "Irrlicht Engine".
3 // For conditions of distribution and use, see copyright notice in irrlicht.h
4 
5 #ifndef __I_TEXTURE_H_INCLUDED__
6 #define __I_TEXTURE_H_INCLUDED__
7 
8 #include "IReferenceCounted.h"
9 #include "IImage.h"
10 #include "dimension2d.h"
11 #include "EDriverTypes.h"
12 #include "path.h"
13 #include "matrix4.h"
14 
15 namespace irr
16 {
17 namespace video
18 {
19 
20 
23 {
32  ETCF_ALWAYS_16_BIT = 0x00000001,
33 
41  ETCF_ALWAYS_32_BIT = 0x00000002,
42 
50 
57 
59  ETCF_CREATE_MIP_MAPS = 0x00000010,
60 
62  ETCF_NO_ALPHA_CHANNEL = 0x00000020,
63 
65 
66  ETCF_ALLOW_NON_POWER_2 = 0x00000040,
67 
69 
74  ETCF_ALLOW_MEMORY_COPY = 0x00000080,
75 
79 };
80 
83 {
86 
88 
90 
92 
95 };
96 
99 {
101 
103 
119 };
120 
123 {
126 
129 
132 };
133 
136 {
139 
142 };
143 
145 
153 class ITexture : public virtual IReferenceCounted
154 {
155 public:
156 
160  {
161  }
162 
164 
186  virtual void* lock(E_TEXTURE_LOCK_MODE mode = ETLM_READ_WRITE, u32 mipmapLevel=0, u32 layer = 0, E_TEXTURE_LOCK_FLAGS lockFlags = ETLF_FLIP_Y_UP_RTT) = 0;
187 
189 
191  virtual void unlock() = 0;
192 
194 
202  virtual void regenerateMipMapLevels(void* data = 0, u32 layer = 0) = 0;
203 
205 
213 
215 
216  const core::dimension2d<u32>& getSize() const { return Size; };
217 
219 
224 
226 
228 
230 
234 
236 
239  u32 getPitch() const { return Pitch; };
240 
242 
243  bool hasMipMaps() const { return HasMipMaps; }
244 
246 
250  bool isRenderTarget() const { return IsRenderTarget; }
251 
253  const io::SNamedPath& getName() const { return NamedPath; }
254 
256  E_TEXTURE_SOURCE getSource() const { return Source; }
257 
259  void updateSource(E_TEXTURE_SOURCE source) { Source = source; }
260 
262  bool hasAlpha() const
263  {
264  bool status = false;
265 
266  switch (ColorFormat)
267  {
268  case ECF_A8R8G8B8:
269  case ECF_A1R5G5B5:
270  case ECF_DXT1:
271  case ECF_DXT2:
272  case ECF_DXT3:
273  case ECF_DXT4:
274  case ECF_DXT5:
275  case ECF_A16B16G16R16F:
276  case ECF_A32B32G32R32F:
277  status = true;
278  break;
279  default:
280  break;
281  }
282 
283  return status;
284  }
285 
287  E_TEXTURE_TYPE getType() const { return Type; }
288 
289 protected:
290 
292 
295  {
296  if (flags & ETCF_OPTIMIZED_FOR_SPEED)
298  if (flags & ETCF_ALWAYS_16_BIT)
299  return ETCF_ALWAYS_16_BIT;
300  if (flags & ETCF_ALWAYS_32_BIT)
301  return ETCF_ALWAYS_32_BIT;
302  if (flags & ETCF_OPTIMIZED_FOR_QUALITY)
305  }
306 
318 };
319 
320 
321 } // end namespace video
322 } // end namespace irr
323 
324 #endif
325 
E_DRIVER_TYPE getDriverType() const
Get driver type of texture.
Definition: ITexture.h:223
io::SNamedPath NamedPath
Definition: ITexture.h:307
const core::dimension2d< u32 > & getSize() const
Get dimension (=size) of the texture.
Definition: ITexture.h:216
ECOLOR_FORMAT getColorFormat() const
Get the color format of texture.
Definition: ITexture.h:227
DXT3 color format.
Definition: SColor.h:47
DXT4 color format.
Definition: SColor.h:50
The default mode. Texture can be read and written to.
Definition: ITexture.h:85
64 bit format using 16 bits for the red, green, blue and alpha channels.
Definition: SColor.h:93
ECOLOR_FORMAT ColorFormat
Definition: ITexture.h:312
ECOLOR_FORMAT OriginalColorFormat
Definition: ITexture.h:311
E_TEXTURE_SOURCE
Where did the last IVideoDriver::getTexture call find this texture.
Definition: ITexture.h:122
Allow the driver to keep a copy of the texture in memory.
Definition: ITexture.h:74
bool isRenderTarget() const
Check whether the texture is a render target.
Definition: ITexture.h:250
ECOLOR_FORMAT
An enum for the color format of textures used by the Irrlicht Engine.
Definition: SColor.h:20
E_TEXTURE_TYPE
Enumeration describing the type of ITexture.
Definition: ITexture.h:135
E_TEXTURE_TYPE getType() const
Returns the type of texture.
Definition: ITexture.h:287
core::dimension2d< u32 > OriginalSize
Definition: ITexture.h:308
Everything in the Irrlicht Engine can be found in this namespace.
Definition: aabbox3d.h:12
E_TEXTURE_LOCK_MODE
Enum for the mode for texture locking. Read-Only, write-only or read/write.
Definition: ITexture.h:82
E_TEXTURE_CREATION_FLAG getTextureFormatFromFlags(u32 flags)
Helper function, helps to get the desired texture creation format from the flags.
Definition: ITexture.h:294
void updateSource(E_TEXTURE_SOURCE source)
Used internally by the engine to update Source status on IVideoDriver::getTexture calls.
Definition: ITexture.h:259
E_TEXTURE_TYPE Type
Definition: ITexture.h:317
Texture has been found in cache.
Definition: ITexture.h:128
ECOLOR_FORMAT getOriginalColorFormat() const
Get the original color format.
Definition: ITexture.h:233
Read only. The texture is downloaded, but not uploaded again.
Definition: ITexture.h:89
Cubemap texture.
Definition: ITexture.h:141
u32 getPitch() const
Get pitch of the main texture (in bytes).
Definition: ITexture.h:239
E_DRIVER_TYPE
An enum for all types of drivers the Irrlicht Engine supports.
Definition: EDriverTypes.h:16
Null driver, useful for applications to run the engine without visualization.
Definition: EDriverTypes.h:21
Used in places where we identify objects by a filename, but don't actually work with the real filenam...
Definition: path.h:23
Unknown color format:
Definition: SColor.h:130
128 bit format using 32 bits for the red, green, blue and alpha channels.
Definition: SColor.h:102
unsigned int u32
32 bit unsigned variable.
Definition: irrTypes.h:62
16 bit color format used by the software driver.
Definition: SColor.h:26
Flip left-bottom origin rendertarget textures upside-down.
Definition: ITexture.h:118
2D texture.
Definition: ITexture.h:138
E_TEXTURE_LOCK_FLAGS
Additional bitflags for ITexture::lock() call.
Definition: ITexture.h:98
virtual void * lock(E_TEXTURE_LOCK_MODE mode=ETLM_READ_WRITE, u32 mipmapLevel=0, u32 layer=0, E_TEXTURE_LOCK_FLAGS lockFlags=ETLF_FLIP_Y_UP_RTT)=0
Lock function.
IVideoDriver::getTexture was never called (texture created otherwise)
Definition: ITexture.h:125
DXT2 color format.
Definition: SColor.h:44
bool hasMipMaps() const
Check whether the texture has MipMaps.
Definition: ITexture.h:243
ITexture(const io::path &name, E_TEXTURE_TYPE type)
constructor
Definition: ITexture.h:158
E_DRIVER_TYPE DriverType
Definition: ITexture.h:310
DXT5 color format.
Definition: SColor.h:53
E_TEXTURE_SOURCE getSource() const
Check where the last IVideoDriver::getTexture found this texture.
Definition: ITexture.h:256
const core::dimension2d< u32 > & getOriginalSize() const
Get original size of the texture.
Definition: ITexture.h:212
core::dimension2d< u32 > Size
Definition: ITexture.h:309
E_TEXTURE_SOURCE Source
Definition: ITexture.h:316
E_TEXTURE_CREATION_FLAG
Enumeration flags telling the video driver in which format textures should be created.
Definition: ITexture.h:22
const io::SNamedPath & getName() const
Get name of texture (in most cases this is the filename)
Definition: ITexture.h:253
Interface of a Video Driver dependent Texture.
Definition: ITexture.h:153
Base class of most objects of the Irrlicht Engine.
virtual void regenerateMipMapLevels(void *data=0, u32 layer=0)=0
Regenerates the mip map levels of the texture.
Write only. The texture is not downloaded and might be uninitialized.
Definition: ITexture.h:94
DXT1 color format.
Definition: SColor.h:41
Allow the Driver to use Non-Power-2-Textures.
Definition: ITexture.h:66
bool hasAlpha() const
Returns if the texture has an alpha channel.
Definition: ITexture.h:262
virtual void unlock()=0
Unlock function. Must be called after a lock() to the texture.
Texture had to be loaded.
Definition: ITexture.h:131