PixelLightAPI
.
|
Texture resource class. More...
#include <Texture.h>
Public Types | |
enum | ECompressionFormat { Default = 0, DXT1 = 1, DXT3 = 2, DXT5 = 3, DXT5_xGxR = 4, LATC1 = 5, LATC2 = 6, LATC2_XYSwizzle = 7, None = 8 } |
Texture compression formats. More... | |
Public Member Functions | |
virtual PLRENDERER_API | ~Texture () |
Destructor. | |
TextureManager & | GetTextureManager () const |
Returns the texture manager this texture is in. | |
PLRENDERER_API TextureBuffer * | GetTextureBuffer () const |
Returns the texture buffer. | |
PLRENDERER_API void | SetTextureBuffer (TextureBuffer *pTextureBuffer=nullptr) |
Sets the texture buffer. | |
ECompressionFormat | GetCompressionHint () const |
Returns the texture compression hint. | |
void | SetCompressionHint (ECompressionFormat nFormat=Default) |
Sets the texture compression hint. | |
const PLMath::Vector3i & | GetOriginalSize () const |
Returns the original texture size. | |
PLRENDERER_API bool | Bind (PLCore::uint32 nStage=0) const |
Makes the texture to the current renderer texture. | |
virtual PLRENDERER_API bool | IsAnimated () const |
Returns whether or not this texture is animated. | |
virtual PLRENDERER_API bool | LoadByFilename (const PLCore::String &sFilename, const PLCore::String &sParams="", const PLCore::String &sMethod="") override |
Loads the loadable from a file given by filename. | |
virtual PLRENDERER_API bool | SaveByFilename (const PLCore::String &sFilename, const PLCore::String &sParams="", const PLCore::String &sMethod="") override |
Saves the loadable to a file given by filename. | |
virtual PLRENDERER_API bool | SaveByFile (PLCore::File &cFile, const PLCore::String &sParams="", const PLCore::String &sMethod="") override |
Saves the loadable to a file given by reference. | |
virtual PLRENDERER_API bool | Unload () override |
Unloads the loadable. | |
virtual PLRENDERER_API PLCore::String | GetLoadableTypeName () const override |
Returns the loadable type name. | |
Protected Member Functions | |
Texture (TextureManager &cManager, const PLCore::String &sName) | |
Constructor. | |
PLCore::uint32 | GetCorrectTextureSize (PLCore::uint32 nSize, PLCore::uint32 nMinSize, PLCore::uint32 nMaxSize, bool bRectangle) const |
Returns a correct texture size. | |
void | DestroyTextureBuffer () |
Destroys the used texture buffer. |
Texture resource class.
The texture class has own special texture compression information standing 'above' the real renderer texture compression. A good example for the usage of this is 'normal map compression'. Because normal maps don't look good when using classic compression, it's better do don't compress them - or to use some tricks so we don't loose to much quality. So, the compression information just indicates for instance the usage like 'DXT5_xGxR' were a texture is compressed as 'DXT5', but the data is stored in a slightly other way. A scene renderer implementation can use this proved information to tell the shader programs about the special usage of the data. When loading a texture, by default the texture data is used as provided. If a 'tga' image is used, no GPU compression is used. If a 'dds' image provides 'fitting' compressed data, this data is directly send to the GPU.
To have some control over the loading and usage of a texture, we provide a XML based file format called 'plt'. If you for instance load in a texture called 'Data/Textures/Soldier_normal.dds', we look whether or not there's a file called 'Soldier_normal.plt' within the same directory. If so, we take the information this file contains into account. A 'plt' file for a compressed normal map may look like this: <?xml version="1.0"?> <Texture version="1"> <General compression="DXT5_xGxR"> </Texture> We can automatically detect whether or not a texture is compressed, but we CAN'T find out automatically HOW the data is organized internally. In the sample above 'DXT5_xGxR' tells us that 'swizzled DXT5' is used. It's the job of a scene renderer or of YOU as programmer to take this information into account.
Texture compression formats.
virtual PLRENDERER_API PLRenderer::Texture::~Texture | ( | ) | [virtual] |
Destructor.
PLRenderer::Texture::Texture | ( | TextureManager & | cManager, |
const PLCore::String & | sName | ||
) | [protected] |
TextureManager & PLRenderer::Texture::GetTextureManager | ( | ) | const [inline] |
Returns the texture manager this texture is in.
PLRENDERER_API TextureBuffer* PLRenderer::Texture::GetTextureBuffer | ( | ) | const |
Returns the texture buffer.
PLRENDERER_API void PLRenderer::Texture::SetTextureBuffer | ( | TextureBuffer * | pTextureBuffer = nullptr | ) |
Sets the texture buffer.
[in] | pTextureBuffer | Texture buffer to set, can be a null pointer |
Texture::ECompressionFormat PLRenderer::Texture::GetCompressionHint | ( | ) | const [inline] |
Returns the texture compression hint.
void PLRenderer::Texture::SetCompressionHint | ( | ECompressionFormat | nFormat = Default | ) | [inline] |
Sets the texture compression hint.
[in] | nFormat | The texture compression hint |
const PLMath::Vector3i & PLRenderer::Texture::GetOriginalSize | ( | ) | const [inline] |
Returns the original texture size.
PLRENDERER_API bool PLRenderer::Texture::Bind | ( | PLCore::uint32 | nStage = 0 | ) | const |
Makes the texture to the current renderer texture.
[in] | nStage | Which texture stage? |
virtual PLRENDERER_API bool PLRenderer::Texture::IsAnimated | ( | ) | const [virtual] |
Returns whether or not this texture is animated.
Reimplemented in PLRenderer::TextureAni.
PLCore::uint32 PLRenderer::Texture::GetCorrectTextureSize | ( | PLCore::uint32 | nSize, |
PLCore::uint32 | nMinSize, | ||
PLCore::uint32 | nMaxSize, | ||
bool | bRectangle | ||
) | const [protected] |
Returns a correct texture size.
[in] | nSize | Size to correct |
[in] | nMinSize | Minimum valid size |
[in] | nMaxSize | Maximum valid size |
[in] | bRectangle | Is this a rectangle texture? |
void PLRenderer::Texture::DestroyTextureBuffer | ( | ) | [protected] |
Destroys the used texture buffer.
virtual PLRENDERER_API bool PLRenderer::Texture::LoadByFilename | ( | const PLCore::String & | sFilename, |
const PLCore::String & | sParams = "" , |
||
const PLCore::String & | sMethod = "" |
||
) | [override, virtual] |
Loads the loadable from a file given by filename.
[in] | sFilename | Loadable filename |
[in] | sParams | Optional load method parameters, can be an empty string |
[in] | sMethod | Optional name of the load method to use, can be an empty string |
Reimplemented from PLCore::Loadable.
Reimplemented in PLRenderer::TextureAni.
virtual PLRENDERER_API bool PLRenderer::Texture::SaveByFilename | ( | const PLCore::String & | sFilename, |
const PLCore::String & | sParams = "" , |
||
const PLCore::String & | sMethod = "" |
||
) | [override, virtual] |
Saves the loadable to a file given by filename.
[in] | sFilename | Loadable filename |
[in] | sParams | Optional save method parameters, can be an empty string |
[in] | sMethod | Optional name of the save method to use, can be an empty string |
Reimplemented from PLCore::Loadable.
Reimplemented in PLRenderer::TextureAni.
virtual PLRENDERER_API bool PLRenderer::Texture::SaveByFile | ( | PLCore::File & | cFile, |
const PLCore::String & | sParams = "" , |
||
const PLCore::String & | sMethod = "" |
||
) | [override, virtual] |
Saves the loadable to a file given by reference.
[in] | cFile | File to save into, must be opened and writable |
[in] | sParams | Optional save method parameters, can be an empty string |
[in] | sMethod | Optional name of the save method to use, can be an empty string |
Reimplemented from PLCore::Loadable.
Reimplemented in PLRenderer::TextureAni.
virtual PLRENDERER_API bool PLRenderer::Texture::Unload | ( | ) | [override, virtual] |
Unloads the loadable.
Reimplemented from PLCore::Loadable.
Reimplemented in PLRenderer::TextureAni.
virtual PLRENDERER_API PLCore::String PLRenderer::Texture::GetLoadableTypeName | ( | ) | const [override, virtual] |
Returns the loadable type name.
Reimplemented from PLCore::Loadable.
Reimplemented in PLRenderer::TextureAni.
|