arsa  2.7
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
irr::video::ITexture Class Referenceabstract

Interface of a Video Driver dependent Texture. More...

#include <ITexture.h>

Inheritance diagram for irr::video::ITexture:
irr::IReferenceCounted

Public Member Functions

 ITexture (const io::path &name, E_TEXTURE_TYPE type)
 constructor More...
 
virtual voidlock (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. More...
 
virtual void unlock ()=0
 Unlock function. Must be called after a lock() to the texture. More...
 
virtual void regenerateMipMapLevels (void *data=0, u32 layer=0)=0
 Regenerates the mip map levels of the texture. More...
 
const core::dimension2d< u32 > & getOriginalSize () const
 Get original size of the texture. More...
 
const core::dimension2d< u32 > & getSize () const
 Get dimension (=size) of the texture. More...
 
E_DRIVER_TYPE getDriverType () const
 Get driver type of texture. More...
 
ECOLOR_FORMAT getColorFormat () const
 Get the color format of texture. More...
 
ECOLOR_FORMAT getOriginalColorFormat () const
 Get the original color format. More...
 
u32 getPitch () const
 Get pitch of the main texture (in bytes). More...
 
bool hasMipMaps () const
 Check whether the texture has MipMaps. More...
 
bool isRenderTarget () const
 Check whether the texture is a render target. More...
 
const io::SNamedPathgetName () const
 Get name of texture (in most cases this is the filename) More...
 
E_TEXTURE_SOURCE getSource () const
 Check where the last IVideoDriver::getTexture found this texture. More...
 
void updateSource (E_TEXTURE_SOURCE source)
 Used internally by the engine to update Source status on IVideoDriver::getTexture calls. More...
 
bool hasAlpha () const
 Returns if the texture has an alpha channel. More...
 
E_TEXTURE_TYPE getType () const
 Returns the type of texture. More...
 
- Public Member Functions inherited from irr::IReferenceCounted
 IReferenceCounted ()
 Constructor. More...
 
virtual ~IReferenceCounted ()
 Destructor. More...
 
void grab () const
 Grabs the object. Increments the reference counter by one. More...
 
bool drop () const
 Drops the object. Decrements the reference counter by one. More...
 
s32 getReferenceCount () const
 Get the reference count. More...
 
const c8getDebugName () const
 Returns the debug name of the object. More...
 

Protected Member Functions

E_TEXTURE_CREATION_FLAG getTextureFormatFromFlags (u32 flags)
 Helper function, helps to get the desired texture creation format from the flags. More...
 
- Protected Member Functions inherited from irr::IReferenceCounted
void setDebugName (const c8 *newName)
 Sets the debug name of the object. More...
 

Protected Attributes

io::SNamedPath NamedPath
 
core::dimension2d< u32OriginalSize
 
core::dimension2d< u32Size
 
E_DRIVER_TYPE DriverType
 
ECOLOR_FORMAT OriginalColorFormat
 
ECOLOR_FORMAT ColorFormat
 
u32 Pitch
 
bool HasMipMaps
 
bool IsRenderTarget
 
E_TEXTURE_SOURCE Source
 
E_TEXTURE_TYPE Type
 

Detailed Description

Interface of a Video Driver dependent Texture.

An ITexture is created by an IVideoDriver by using IVideoDriver::addTexture or IVideoDriver::getTexture. After that, the texture may only be used by this VideoDriver. As you can imagine, textures of the DirectX and the OpenGL device will, e.g., not be compatible. An exception is the Software device and the NULL device, their textures are compatible. If you try to use a texture created by one device with an other device, the device will refuse to do that and write a warning or an error message to the output buffer.

Definition at line 177 of file ITexture.h.

Constructor & Destructor Documentation

◆ ITexture()

irr::video::ITexture::ITexture ( const io::path name,
E_TEXTURE_TYPE  type 
)
inline

constructor

Definition at line 182 of file ITexture.h.

184  {
185  }
io::SNamedPath NamedPath
Definition: ITexture.h:332
ECOLOR_FORMAT ColorFormat
Definition: ITexture.h:337
ECOLOR_FORMAT OriginalColorFormat
Definition: ITexture.h:336
GLuint const GLchar * name
E_TEXTURE_TYPE Type
Definition: ITexture.h:342
Null driver, useful for applications to run the engine without visualization.
Definition: EDriverTypes.h:21
Unknown color format:
Definition: SColor.h:132
IVideoDriver::getTexture was never called (texture created otherwise)
Definition: ITexture.h:149
E_DRIVER_TYPE DriverType
Definition: ITexture.h:335
E_TEXTURE_SOURCE Source
Definition: ITexture.h:341
GLuint GLuint GLsizei GLenum type
Definition: SDL_opengl.h:1571

Member Function Documentation

◆ getColorFormat()

ECOLOR_FORMAT irr::video::ITexture::getColorFormat ( ) const
inline

Get the color format of texture.

Returns
The color format of texture.

Definition at line 252 of file ITexture.h.

252 { return ColorFormat; };
ECOLOR_FORMAT ColorFormat
Definition: ITexture.h:337

◆ getDriverType()

E_DRIVER_TYPE irr::video::ITexture::getDriverType ( ) const
inline

Get driver type of texture.

This is the driver, which created the texture. This method is used internally by the video devices, to check, if they may use a texture because textures may be incompatible between different devices.

Returns
Driver type of texture.

Definition at line 248 of file ITexture.h.

248 { return DriverType; };
E_DRIVER_TYPE DriverType
Definition: ITexture.h:335

◆ getName()

const io::SNamedPath& irr::video::ITexture::getName ( ) const
inline

Get name of texture (in most cases this is the filename)

Definition at line 278 of file ITexture.h.

278 { return NamedPath; }
io::SNamedPath NamedPath
Definition: ITexture.h:332

◆ getOriginalColorFormat()

ECOLOR_FORMAT irr::video::ITexture::getOriginalColorFormat ( ) const
inline

Get the original color format.

When create textures from image data we will often use different color formats. For example depending on driver TextureCreationFlag's. This can give you the original format which the image used to create the texture had

Definition at line 258 of file ITexture.h.

258 { return OriginalColorFormat; };
ECOLOR_FORMAT OriginalColorFormat
Definition: ITexture.h:336

◆ getOriginalSize()

const core::dimension2d<u32>& irr::video::ITexture::getOriginalSize ( ) const
inline

Get original size of the texture.

The texture is usually scaled, if it was created with an unoptimal size. For example if the size was not a power of two. This method returns the size of the texture it had before it was scaled. Can be useful when drawing 2d images on the screen, which should have the exact size of the original texture. Use ITexture::getSize() if you want to know the real size it has now stored in the system.

Returns
The original size of the texture.

Definition at line 237 of file ITexture.h.

237 { return OriginalSize; };
core::dimension2d< u32 > OriginalSize
Definition: ITexture.h:333

◆ getPitch()

u32 irr::video::ITexture::getPitch ( ) const
inline

Get pitch of the main texture (in bytes).

The pitch is the amount of bytes used for a row of pixels in a texture.

Returns
Pitch of texture in bytes.

Definition at line 264 of file ITexture.h.

264 { return Pitch; };

◆ getSize()

const core::dimension2d<u32>& irr::video::ITexture::getSize ( ) const
inline

Get dimension (=size) of the texture.

Returns
The size of the texture.

Definition at line 241 of file ITexture.h.

241 { return Size; };
core::dimension2d< u32 > Size
Definition: ITexture.h:334

◆ getSource()

E_TEXTURE_SOURCE irr::video::ITexture::getSource ( ) const
inline

Check where the last IVideoDriver::getTexture found this texture.

Definition at line 281 of file ITexture.h.

281 { return Source; }
E_TEXTURE_SOURCE Source
Definition: ITexture.h:341

◆ getTextureFormatFromFlags()

E_TEXTURE_CREATION_FLAG irr::video::ITexture::getTextureFormatFromFlags ( u32  flags)
inlineprotected

Helper function, helps to get the desired texture creation format from the flags.

Returns
Either ETCF_ALWAYS_32_BIT, ETCF_ALWAYS_16_BIT, ETCF_OPTIMIZED_FOR_QUALITY, or ETCF_OPTIMIZED_FOR_SPEED.

Definition at line 319 of file ITexture.h.

◆ getType()

E_TEXTURE_TYPE irr::video::ITexture::getType ( ) const
inline

Returns the type of texture.

Definition at line 312 of file ITexture.h.

312 { return Type; }
E_TEXTURE_TYPE Type
Definition: ITexture.h:342

◆ hasAlpha()

bool irr::video::ITexture::hasAlpha ( ) const
inline

Returns if the texture has an alpha channel.

Definition at line 287 of file ITexture.h.

288  {
289  bool status = false;
290 
291  switch (ColorFormat)
292  {
293  case ECF_A8R8G8B8:
294  case ECF_A1R5G5B5:
295  case ECF_DXT1:
296  case ECF_DXT2:
297  case ECF_DXT3:
298  case ECF_DXT4:
299  case ECF_DXT5:
300  case ECF_A16B16G16R16F:
301  case ECF_A32B32G32R32F:
302  status = true;
303  break;
304  default:
305  break;
306  }
307 
308  return status;
309  }
DXT3 color format.
Definition: SColor.h:49
DXT4 color format.
Definition: SColor.h:52
64 bit format using 16 bits for the red, green, blue and alpha channels.
Definition: SColor.h:95
ECOLOR_FORMAT ColorFormat
Definition: ITexture.h:337
128 bit format using 32 bits for the red, green, blue and alpha channels.
Definition: SColor.h:104
16 bit color format used by the software driver.
Definition: SColor.h:26
DXT2 color format.
Definition: SColor.h:46
DXT5 color format.
Definition: SColor.h:55
DXT1 color format.
Definition: SColor.h:43

◆ hasMipMaps()

bool irr::video::ITexture::hasMipMaps ( ) const
inline

Check whether the texture has MipMaps.

Returns
True if texture has MipMaps, else false.

Definition at line 268 of file ITexture.h.

268 { return HasMipMaps; }

◆ isRenderTarget()

bool irr::video::ITexture::isRenderTarget ( ) const
inline

Check whether the texture is a render target.

Render targets can be set as such in the video driver, in order to render a scene into the texture. Once unbound as render target, they can be used just as usual textures again.

Returns
True if this is a render target, otherwise false.

Definition at line 275 of file ITexture.h.

275 { return IsRenderTarget; }

◆ lock()

virtual void* irr::video::ITexture::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 
)
pure virtual

Lock function.

Locks the Texture and returns a pointer to access the pixels. After lock() has been called and all operations on the pixels are done, you must call unlock(). Locks are not accumulating, hence one unlock will do for an arbitrary number of previous locks. You should avoid locking different levels without unlocking in between, though, because only the last level locked will be unlocked. The size of the i-th mipmap level is defined as max(getSize().Width>>i,1) and max(getSize().Height>>i,1)

Parameters
modeSpecifies what kind of changes to the locked texture are allowed. Unspecified behavior will arise if texture is written in read only mode or read from in write only mode. Support for this feature depends on the driver, so don't rely on the texture being write-protected when locking with read-only, etc.
mipmapLevelNOTE: Currently broken, sorry, we try if we can repair it for 1.9 release. Number of the mipmapLevel to lock. 0 is main texture. Non-existing levels will silently fail and return 0.
layerIt determines which cubemap face or texture array layer should be locked.
lockFlagsSee E_TEXTURE_LOCK_FLAGS documentation.
Returns
Returns a pointer to the pixel data. The format of the pixel can be determined by using getColorFormat(). 0 is returned, if the texture cannot be locked.

◆ regenerateMipMapLevels()

virtual void irr::video::ITexture::regenerateMipMapLevels ( void data = 0,
u32  layer = 0 
)
pure virtual

Regenerates the mip map levels of the texture.

Required after modifying the texture, usually after calling unlock().

Parameters
dataOptional parameter to pass in image data which will be used instead of the previously stored or automatically generated mipmap data. The data has to be a continuous pixel data for all mipmaps until 1x1 pixel. Each mipmap has to be half the width and height of the previous level. At least one pixel will be always kept.
layerIt informs a texture about which cubemap or texture array layer needs mipmap regeneration.

◆ unlock()

virtual void irr::video::ITexture::unlock ( )
pure virtual

Unlock function. Must be called after a lock() to the texture.

One should avoid to call unlock more than once before another lock. The last locked mip level will be unlocked. You may want to call regenerateMipMapLevels() after this when you changed any data.

◆ updateSource()

void irr::video::ITexture::updateSource ( E_TEXTURE_SOURCE  source)
inline

Used internally by the engine to update Source status on IVideoDriver::getTexture calls.

Definition at line 284 of file ITexture.h.

284 { Source = source; }
GLsizei GLsizei GLchar * source
E_TEXTURE_SOURCE Source
Definition: ITexture.h:341

Member Data Documentation

◆ ColorFormat

ECOLOR_FORMAT irr::video::ITexture::ColorFormat
protected

Definition at line 337 of file ITexture.h.

◆ DriverType

E_DRIVER_TYPE irr::video::ITexture::DriverType
protected

Definition at line 335 of file ITexture.h.

◆ HasMipMaps

bool irr::video::ITexture::HasMipMaps
protected

Definition at line 339 of file ITexture.h.

◆ IsRenderTarget

bool irr::video::ITexture::IsRenderTarget
protected

Definition at line 340 of file ITexture.h.

◆ NamedPath

io::SNamedPath irr::video::ITexture::NamedPath
protected

Definition at line 332 of file ITexture.h.

◆ OriginalColorFormat

ECOLOR_FORMAT irr::video::ITexture::OriginalColorFormat
protected

Definition at line 336 of file ITexture.h.

◆ OriginalSize

core::dimension2d<u32> irr::video::ITexture::OriginalSize
protected

Definition at line 333 of file ITexture.h.

◆ Pitch

u32 irr::video::ITexture::Pitch
protected

Definition at line 338 of file ITexture.h.

◆ Size

core::dimension2d<u32> irr::video::ITexture::Size
protected

Definition at line 334 of file ITexture.h.

◆ Source

E_TEXTURE_SOURCE irr::video::ITexture::Source
protected

Definition at line 341 of file ITexture.h.

◆ Type

E_TEXTURE_TYPE irr::video::ITexture::Type
protected

Definition at line 342 of file ITexture.h.


The documentation for this class was generated from the following file: