![]() |
Duckcpp 2.1.0
Duckcpp is a high-performance c++ graphics engine.
|
Interface of a Video Driver dependent Texture. More...
#include <duckcpp/core/engine/ITexture.hpp>
Public Member Functions | |
ITexture (const dcpp::io::path &name, E_TEXTURE_TYPE type) | |
constructor | |
virtual void * | lock (E_TEXTURE_LOCK_MODE mode=ETLM_READ_WRITE, dcpp::uint32_kt mipmapLevel=0, dcpp::uint32_kt layer=0, E_TEXTURE_LOCK_FLAGS lockFlags=ETLF_FLIP_Y_UP_RTT)=0 |
Lock function. | |
virtual void | unlock ()=0 |
Unlock function. Must be called after a lock() to the texture. | |
virtual void | regenerateMipMapLevels (void *data=0, dcpp::uint32_kt layer=0)=0 |
Regenerates the mip map levels of the texture. | |
const dcpp::nub::dimension2du & | getOriginalSize () const |
Get original size of the texture. | |
const dcpp::nub::dimension2du & | getSize () const |
Get dimension (=size) of the texture. | |
E_DRIVER_TYPE | getDriverType () const |
Get driver type of texture. | |
ECOLOR_FORMAT | getColorFormat () const |
Get the color format of texture. | |
ECOLOR_FORMAT | getOriginalColorFormat () const |
Get the original color format. | |
dcpp::uint32_kt | getPitch () const |
Get pitch of the main texture (in bytes). | |
bool | hasMipMaps () const |
Check whether the texture has MipMaps. | |
bool | isRenderTarget () const |
Check whether the texture is a render target. | |
const dcpp::io::SNamedPath & | getName () const |
Get name of texture (in most cases this is the filename) | |
E_TEXTURE_SOURCE | getSource () const |
Check where the last IVideoDriver::getTexture found this texture. | |
void | updateSource (E_TEXTURE_SOURCE source) |
Used internally by the engine to update Source status on IVideoDriver::getTexture calls. | |
bool | hasAlpha () const |
Returns if the texture has an alpha channel. | |
E_TEXTURE_TYPE | getType () const |
Returns the type of texture. | |
![]() | |
IReferenceCounted () | |
Constructor. | |
virtual | ~IReferenceCounted () |
Destructor. | |
void | grab () const |
Grabs the object. Increments the reference counter by one. | |
bool | drop () const |
Drops the object. Decrements the reference counter by one. | |
dcpp::int32_kt | getReferenceCount () const |
Get the reference count. | |
const dcpp::char_kt * | getDebugName () const |
Returns the debug name of the object. | |
Protected Member Functions | |
E_TEXTURE_CREATION_FLAG | getTextureFormatFromFlags (dcpp::uint32_kt flags) |
Helper function, helps to get the desired texture creation format from the flags. | |
![]() | |
void | setDebugName (const dcpp::char_kt *newName) |
Sets the debug name of the object. | |
Protected Attributes | |
dcpp::io::SNamedPath | NamedPath |
dcpp::nub::dimension2du | OriginalSize |
dcpp::nub::dimension2du | Size |
E_DRIVER_TYPE | DriverType |
ECOLOR_FORMAT | OriginalColorFormat |
ECOLOR_FORMAT | ColorFormat |
dcpp::uint32_kt | Pitch |
bool | HasMipMaps |
bool | IsRenderTarget |
E_TEXTURE_SOURCE | Source |
E_TEXTURE_TYPE | Type |
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.
|
inline |
Get the color format of texture.
|
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.
|
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
|
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.
|
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.
|
inline |
Get dimension (=size) of the texture.
|
inlineprotected |
Helper function, helps to get the desired texture creation format from the flags.
|
inline |
Check whether the texture has MipMaps.
|
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.
|
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)
mode | Specifies 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. |
mipmapLevel | NOTE: 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. |
layer | It determines which cubemap face or texture array layer should be locked. |
lockFlags | See E_TEXTURE_LOCK_FLAGS documentation. |
|
pure virtual |
Regenerates the mip map levels of the texture.
Required after modifying the texture, usually after calling unlock().
data | Optional 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. |
layer | It informs a texture about which cubemap or texture array layer needs mipmap regeneration. |
|
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.