Irrlicht 3D Engine
irr::video::ITexture Class Referenceabstract

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

#include <ITexture.h>

+ Inheritance diagram for irr::video::ITexture:

Public Member Functions

 ITexture (const io::path &name)
 constructor More...
 
virtual ECOLOR_FORMAT getColorFormat () const =0
 Get the color format of texture. More...
 
virtual E_DRIVER_TYPE getDriverType () const =0
 Get driver type of texture. More...
 
const io::SNamedPathgetName () const
 Get name of texture (in most cases this is the filename) More...
 
virtual const core::dimension2d< u32 > & getOriginalSize () const =0
 Get original size of the texture. More...
 
virtual u32 getPitch () const =0
 Get pitch of the main texture (in bytes). More...
 
virtual const core::dimension2d< u32 > & getSize () const =0
 Get dimension (=size) of the texture. More...
 
virtual bool hasAlpha () const
 Returns if the texture has an alpha channel. More...
 
virtual bool hasMipMaps () const
 Check whether the texture has MipMaps. More...
 
virtual bool isRenderTarget () const
 Check whether the texture is a render target. More...
 
virtual void * lock (E_TEXTURE_LOCK_MODE mode=ETLM_READ_WRITE, u32 mipmapLevel=0)=0
 Lock function. More...
 
virtual void regenerateMipMapLevels (void *mipmapData=0)=0
 Regenerates the mip map levels of the texture. More...
 
virtual void unlock ()=0
 Unlock function. Must be called after a lock() to the texture. More...
 
- Public Member Functions inherited from irr::IReferenceCounted
 IReferenceCounted ()
 Constructor. More...
 
virtual ~IReferenceCounted ()
 Destructor. More...
 
bool drop () const
 Drops the object. Decrements the reference counter by one. More...
 
const c8getDebugName () const
 Returns the debug name of the object. More...
 
s32 getReferenceCount () const
 Get the reference count. More...
 
void grab () const
 Grabs the object. Increments the reference counter by one. 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
 

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 98 of file ITexture.h.

Constructor & Destructor Documentation

§ ITexture()

irr::video::ITexture::ITexture ( const io::path name)
inline

Member Function Documentation

§ getColorFormat()

virtual ECOLOR_FORMAT irr::video::ITexture::getColorFormat ( ) const
pure virtual

Get the color format of texture.

Returns
The color format of texture.

Referenced by hasAlpha(), and ITexture().

§ getDriverType()

virtual E_DRIVER_TYPE irr::video::ITexture::getDriverType ( ) const
pure virtual

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.

Referenced by ITexture().

§ getName()

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

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

Definition at line 191 of file ITexture.h.

References NamedPath.

§ getOriginalSize()

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

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.

Referenced by ITexture().

§ getPitch()

virtual u32 irr::video::ITexture::getPitch ( ) const
pure virtual

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.

Referenced by ITexture().

§ getSize()

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

Get dimension (=size) of the texture.

Returns
The size of the texture.

Referenced by ITexture().

§ 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 198 of file ITexture.h.

References irr::video::ETCF_ALWAYS_16_BIT, irr::video::ETCF_ALWAYS_32_BIT, irr::video::ETCF_OPTIMIZED_FOR_QUALITY, and irr::video::ETCF_OPTIMIZED_FOR_SPEED.

§ hasAlpha()

virtual bool irr::video::ITexture::hasAlpha ( ) const
inlinevirtual

Returns if the texture has an alpha channel.

Definition at line 170 of file ITexture.h.

References irr::video::ECF_A1R5G5B5, irr::video::ECF_A8R8G8B8, getColorFormat(), and regenerateMipMapLevels().

§ hasMipMaps()

virtual bool irr::video::ITexture::hasMipMaps ( ) const
inlinevirtual

Check whether the texture has MipMaps.

Returns
True if texture has MipMaps, else false.

Definition at line 167 of file ITexture.h.

§ isRenderTarget()

virtual bool irr::video::ITexture::isRenderTarget ( ) const
inlinevirtual

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 188 of file ITexture.h.

§ lock()

virtual void* irr::video::ITexture::lock ( E_TEXTURE_LOCK_MODE  mode = ETLM_READ_WRITE,
u32  mipmapLevel = 0 
)
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 inbetween, 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.
mipmapLevelNumber of the mipmapLevel to lock. 0 is main texture. Non-existing levels will silently fail and return 0.
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.

Referenced by ITexture().

§ regenerateMipMapLevels()

virtual void irr::video::ITexture::regenerateMipMapLevels ( void *  mipmapData = 0)
pure virtual

Regenerates the mip map levels of the texture.

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

Parameters
mipmapDataOptional 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.

Referenced by hasAlpha().

§ 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.

Referenced by ITexture().

Member Data Documentation

§ NamedPath

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

Definition at line 211 of file ITexture.h.

Referenced by getName().


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