Saga3D API Documentation  1.0-RC4
saga::video::ITexture Class Referenceabstract

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

#include <ITexture.h>

Public Member Functions

 ITexture (const std::string &name, E_TEXTURE_TYPE type)
 constructor More...
 
virtual void * lock (E_TEXTURE_LOCK_MODE mode=E_TEXTURE_LOCK_MODE::READ_WRITE, std::uint32_t layer=0)=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, std::uint32_t layer=0)=0
 Regenerates the mip map levels of the texture. More...
 
const glm::uvec2 & getOriginalSize () const
 Get original size of the texture. More...
 
const glm::uvec2 & getSize () const
 Get dimension (=size) of the texture. More...
 
E_DRIVER_TYPE getDriverType () const
 Get driver type of texture. More...
 
E_PIXEL_FORMAT getColorFormat () const
 Get the color format of texture. More...
 
std::uint32_t 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 std::string & getName () 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...
 

Protected Attributes

std::string NamedPath
 
glm::uvec2 OriginalSize
 
glm::uvec2 Size
 
E_DRIVER_TYPE DriverType
 
E_PIXEL_FORMAT OriginalColorFormat
 
E_PIXEL_FORMAT ColorFormat
 
std::uint32_t 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 25 of file ITexture.h.

Constructor & Destructor Documentation

◆ ITexture()

saga::video::ITexture::ITexture ( const std::string &  name,
E_TEXTURE_TYPE  type 
)
inline

constructor

Definition at line 30 of file ITexture.h.

Member Function Documentation

◆ getColorFormat()

E_PIXEL_FORMAT saga::video::ITexture::getColorFormat ( ) const
inline

Get the color format of texture.

Returns
The color format of texture.

Definition at line 99 of file ITexture.h.

◆ getDriverType()

E_DRIVER_TYPE saga::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 95 of file ITexture.h.

◆ getName()

const std::string& saga::video::ITexture::getName ( ) const
inline

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

Definition at line 119 of file ITexture.h.

◆ getOriginalSize()

const glm::uvec2& saga::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 84 of file ITexture.h.

◆ getPitch()

std::uint32_t saga::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 105 of file ITexture.h.

◆ getSize()

const glm::uvec2& saga::video::ITexture::getSize ( ) const
inline

Get dimension (=size) of the texture.

Returns
The size of the texture.

Definition at line 88 of file ITexture.h.

◆ getSource()

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

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

Definition at line 122 of file ITexture.h.

◆ getType()

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

Returns the type of texture.

Definition at line 152 of file ITexture.h.

◆ hasAlpha()

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

Returns if the texture has an alpha channel.

Definition at line 128 of file ITexture.h.

◆ hasMipMaps()

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

Check whether the texture has MipMaps.

Returns
True if texture has MipMaps, else false.

Definition at line 109 of file ITexture.h.

◆ isRenderTarget()

bool saga::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 116 of file ITexture.h.

◆ lock()

virtual void* saga::video::ITexture::lock ( E_TEXTURE_LOCK_MODE  mode = E_TEXTURE_LOCK_MODE::READ_WRITE,
std::uint32_t  layer = 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 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.
layerIt determines which cubemap face or texture array layer should be locked.
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 saga::video::ITexture::regenerateMipMapLevels ( void *  data = 0,
std::uint32_t  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 layer which needs mipmaps regeneration.

◆ unlock()

virtual void saga::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.

◆ updateSource()

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

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

Definition at line 125 of file ITexture.h.

Member Data Documentation

◆ ColorFormat

E_PIXEL_FORMAT saga::video::ITexture::ColorFormat
protected

Definition at line 160 of file ITexture.h.

◆ DriverType

E_DRIVER_TYPE saga::video::ITexture::DriverType
protected

Definition at line 158 of file ITexture.h.

◆ HasMipMaps

bool saga::video::ITexture::HasMipMaps
protected

Definition at line 162 of file ITexture.h.

◆ IsRenderTarget

bool saga::video::ITexture::IsRenderTarget
protected

Definition at line 163 of file ITexture.h.

◆ NamedPath

std::string saga::video::ITexture::NamedPath
protected

Definition at line 155 of file ITexture.h.

◆ OriginalColorFormat

E_PIXEL_FORMAT saga::video::ITexture::OriginalColorFormat
protected

Definition at line 159 of file ITexture.h.

◆ OriginalSize

glm::uvec2 saga::video::ITexture::OriginalSize
protected

Definition at line 156 of file ITexture.h.

◆ Pitch

std::uint32_t saga::video::ITexture::Pitch
protected

Definition at line 161 of file ITexture.h.

◆ Size

glm::uvec2 saga::video::ITexture::Size
protected

Definition at line 157 of file ITexture.h.

◆ Source

E_TEXTURE_SOURCE saga::video::ITexture::Source
protected

Definition at line 164 of file ITexture.h.

◆ Type

E_TEXTURE_TYPE saga::video::ITexture::Type
protected

Definition at line 165 of file ITexture.h.


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