Skylicht Engine
Loading...
Searching...
No Matches
ITexture.h
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
15namespace irr
16{
17namespace video
18{
19
20
23{
32 ETCF_ALWAYS_16_BIT = 0x00000001,
33
41 ETCF_ALWAYS_32_BIT = 0x00000002,
42
50
57
60
63
65
67
71};
72
88
101
102enum E_TEXTURE_TYPE
103{
104 ETT_TEXTURE_2D,
105 ETT_TEXTURE_CUBE,
106 ETT_TEXTURE_ARRAY,
107};
108
110
118class ITexture : public virtual IReferenceCounted
119{
120public:
121
123 ITexture(const io::path& name) : NamedPath(name), DriverType(EDT_NULL), ColorFormat(ECF_UNKNOWN),
124 Pitch(0), HasMipMaps(false), HasAlpha(false), IsRenderTarget(false), Source(ETS_UNKNOWN), TextureType(ETT_TEXTURE_2D)
125 {
126 }
127
129
148 virtual void* lock(E_TEXTURE_LOCK_MODE mode=ETLM_READ_WRITE, u32 mipmapLevel=0) = 0;
149
151
153 virtual void unlock() = 0;
154
156
162 virtual void regenerateMipMapLevels(void* mipmapData = 0) = 0;
163
165
172 const core::dimension2d<u32>& getOriginalSize() const { return OriginalSize; };
173
175
176 const core::dimension2d<u32>& getSize() const { return Size; };
177
179
183 E_DRIVER_TYPE getDriverType() const { return DriverType; };
184
186
187 ECOLOR_FORMAT getColorFormat() const { return ColorFormat; };
188
190
193 u32 getPitch() const { return Pitch; };
194
196
197 bool hasMipMaps() const { return HasMipMaps; }
198
200 bool hasAlpha() const { return HasAlpha; }
201
203
207 bool isRenderTarget() const { return IsRenderTarget; }
208
210 const io::SNamedPath& getName() const { return NamedPath; }
211
213 E_TEXTURE_SOURCE getSource() const { return Source; }
214
216 void updateSource(E_TEXTURE_SOURCE source) { Source = source; }
217
218 const E_TEXTURE_TYPE& getTextureType() const
219 {
220 return TextureType;
221 }
222
223protected:
224
226
240
241 io::SNamedPath NamedPath;
242 core::dimension2d<u32> OriginalSize;
244 E_DRIVER_TYPE DriverType;
245 ECOLOR_FORMAT ColorFormat;
246 u32 Pitch;
247 bool HasMipMaps;
248 bool HasAlpha;
249 bool IsRenderTarget;
250 E_TEXTURE_SOURCE Source;
251 E_TEXTURE_TYPE TextureType;
252};
253
254
255} // end namespace video
256} // end namespace irr
257
258#endif
259
IReferenceCounted()
Constructor.
Definition IReferenceCounted.h:50
Specifies a 2 dimensional size.
Definition dimension2d.h:21
ECOLOR_FORMAT getColorFormat() const
Get the color format of texture.
Definition ITexture.h:187
const core::dimension2d< u32 > & getSize() const
Get dimension (=size) of the texture.
Definition ITexture.h:176
bool hasAlpha() const
Returns if the texture has an alpha channel.
Definition ITexture.h:200
virtual void unlock()=0
Unlock function. Must be called after a lock() to the texture.
ITexture(const io::path &name)
constructor
Definition ITexture.h:123
u32 getPitch() const
Get pitch of the main texture (in bytes).
Definition ITexture.h:193
virtual void * lock(E_TEXTURE_LOCK_MODE mode=ETLM_READ_WRITE, u32 mipmapLevel=0)=0
Lock function.
E_TEXTURE_SOURCE getSource() const
Check where the last IVideoDriver::getTexture found this texture.
Definition ITexture.h:213
void updateSource(E_TEXTURE_SOURCE source)
Used internally by the engine to update Source status on IVideoDriver::getTexture calls.
Definition ITexture.h:216
virtual void regenerateMipMapLevels(void *mipmapData=0)=0
Regenerates the mip map levels of the texture.
bool isRenderTarget() const
Check whether the texture is a render target.
Definition ITexture.h:207
bool hasMipMaps() const
Check whether the texture has MipMaps.
Definition ITexture.h:197
const io::SNamedPath & getName() const
Get name of texture (in most cases this is the filename).
Definition ITexture.h:210
const core::dimension2d< u32 > & getOriginalSize() const
Get original size of the texture.
Definition ITexture.h:172
E_DRIVER_TYPE getDriverType() const
Get driver type of texture.
Definition ITexture.h:183
E_TEXTURE_CREATION_FLAG getTextureFormatFromFlags(u32 flags)
Helper function, helps to get the desired texture creation format from the flags.
Definition ITexture.h:228
core::string< fschar_t > path
Type used for all file system related strings.
Definition path.h:17
The video namespace contains classes for accessing the video driver. All 2d and 3d rendering is done ...
Definition EDriverFeatures.h:11
ECOLOR_FORMAT
An enum for the color format of textures used by the Irrlicht Engine.
Definition SColor.h:18
@ ECF_UNKNOWN
Unknown color format:
Definition SColor.h:138
E_TEXTURE_LOCK_MODE
Enum for the mode for texture locking. Read-Only, write-only or read/write.
Definition ITexture.h:75
@ ETLM_READ_ONLY
Read only. The texture is downloaded, but not uploaded again.
Definition ITexture.h:81
@ ETLM_READ_WRITE
The default mode. Texture can be read and written to.
Definition ITexture.h:77
@ ETLM_WRITE_ONLY
Write only. The texture is not downloaded and might be uninitialised.
Definition ITexture.h:86
E_TEXTURE_SOURCE
Where did the last IVideoDriver::getTexture call find this texture.
Definition ITexture.h:91
@ ETS_UNKNOWN
IVideoDriver::getTexture was never called (texture created otherwise).
Definition ITexture.h:93
@ ETS_FROM_FILE
Texture had to be loaded.
Definition ITexture.h:99
@ ETS_FROM_CACHE
Texture has been found in cache.
Definition ITexture.h:96
E_TEXTURE_CREATION_FLAG
Enumeration flags telling the video driver in which format textures should be created.
Definition ITexture.h:23
@ ETCF_FORCE_32_BIT_DO_NOT_USE
Definition ITexture.h:70
@ ETCF_OPTIMIZED_FOR_SPEED
Definition ITexture.h:56
@ ETCF_ALWAYS_32_BIT
Definition ITexture.h:41
@ ETCF_CREATE_MIP_MAPS
Definition ITexture.h:59
@ ETCF_ALWAYS_16_BIT
Definition ITexture.h:32
@ ETCF_ALLOW_NON_POWER_2
Allow the Driver to use Non-Power-2-Textures.
Definition ITexture.h:66
@ ETCF_NO_ALPHA_CHANNEL
Definition ITexture.h:62
@ ETCF_OPTIMIZED_FOR_QUALITY
Definition ITexture.h:49
E_DRIVER_TYPE
An enum for all types of drivers the Irrlicht Engine supports.
Definition EDriverTypes.h:15
@ EDT_NULL
Null driver, useful for applications to run the engine without visualisation.
Definition EDriverTypes.h:19
Everything in the Irrlicht Engine can be found in this namespace.
Definition Skylicht.h:33
unsigned int u32
32 bit unsigned variable.
Definition irrTypes.h:58
Used in places where we identify objects by a filename, but don't actually work with the real filenam...
Definition path.h:24