Pyrogenesis HEAD
Pyrogenesis, a RTS Engine
|
Texture conversion helper class. More...
#include <TextureConverter.h>
Classes | |
struct | ConversionResult |
Response from the asynchronous task. More... | |
struct | Match |
Representation of <File> line from settings XML file. More... | |
struct | Settings |
Texture conversion settings. More... | |
struct | SettingsFile |
Representation of settings XML file. More... | |
Public Types | |
enum | EFormat { FMT_UNSPECIFIED , FMT_DXT1 , FMT_DXT3 , FMT_DXT5 , FMT_RGBA , FMT_ALPHA } |
enum | EMipmap { MIP_UNSPECIFIED , MIP_TRUE , MIP_FALSE } |
enum | ENormalMap { NORMAL_UNSPECIFIED , NORMAL_TRUE , NORMAL_FALSE } |
enum | EAlpha { ALPHA_UNSPECIFIED , ALPHA_NONE , ALPHA_PLAYER , ALPHA_TRANSPARENCY } |
enum | EFilter { FILTER_UNSPECIFIED , FILTER_BOX , FILTER_TRIANGLE , FILTER_KAISER } |
Public Member Functions | |
CTextureConverter (PIVFS vfs, bool highQuality) | |
Construct texture converter, for use with files in the given vfs. More... | |
~CTextureConverter () | |
The destructor does wait for already started tasks. More... | |
SettingsFile * | LoadSettings (const VfsPath &path) const |
Load a texture conversion settings XML file. More... | |
Settings | ComputeSettings (const std::wstring &filename, const std::vector< SettingsFile * > &settingsFiles) const |
Match a sequence of settings files against a given texture filename, and return the resulting settings. More... | |
bool | ConvertTexture (const CTexturePtr &texture, const VfsPath &src, const VfsPath &dest, const Settings &settings) |
Begin converting a texture, using the given settings. More... | |
bool | Poll (CTexturePtr &texture, VfsPath &dest, bool &ok) |
Returns the result of a successful ConvertTexture call. More... | |
bool | IsBusy () const |
The TextureConverter shouldn't utilize the CPU/Memory fully, so no conversion should be started when a call to IsBusy returns true. More... | |
Private Attributes | |
PIVFS | m_VFS |
bool | m_HighQuality |
std::queue< Future< std::unique_ptr< ConversionResult > > > | m_ResultQueue |
Texture conversion helper class.
Provides an asynchronous API to convert input image files into compressed DDS, given various conversion settings. (The (potentially very slow) compression is a performed asynchronously, so the game can remain responsive). Also provides an API to load conversion settings from XML files.
XML files are of the form:
'pattern' is a wildcard expression, matching on filenames. All other attributes are optional. Later elements override attributes from earlier elements.
'format' is 'dxt1', 'dxt3', 'dxt5' or 'rgba'.
'mipmap' is 'true' or 'false'.
'normal' is 'true' or 'false'.
'alpha' is 'transparency' or 'player' (it determines whether the color value of 0-alpha pixels is significant or not).
'filter' is 'box', 'triangle' or 'kaiser'.
'kaiserwidth', 'kaiseralpha', 'kaiserstretch' are floats (see http://code.google.com/p/nvidia-texture-tools/wiki/ApiDocumentation#Mipmap_Generation)
CTextureConverter::CTextureConverter | ( | PIVFS | vfs, |
bool | highQuality | ||
) |
Construct texture converter, for use with files in the given vfs.
|
default |
The destructor does wait for already started tasks.
This might take a long time (maybe seconds).
CTextureConverter::Settings CTextureConverter::ComputeSettings | ( | const std::wstring & | filename, |
const std::vector< SettingsFile * > & | settingsFiles | ||
) | const |
Match a sequence of settings files against a given texture filename, and return the resulting settings.
Later entries in settingsFiles override earlier entries.
bool CTextureConverter::ConvertTexture | ( | const CTexturePtr & | texture, |
const VfsPath & | src, | ||
const VfsPath & | dest, | ||
const Settings & | settings | ||
) |
Begin converting a texture, using the given settings.
This will load src and return false on failure. Otherwise it will return true and start an asynchronous conversion request, whose result will be returned from Poll() (with the texture and dest passed into this function).
bool CTextureConverter::IsBusy | ( | ) | const |
The TextureConverter shouldn't utilize the CPU/Memory fully, so no conversion should be started when a call to IsBusy
returns true.
CTextureConverter::SettingsFile * CTextureConverter::LoadSettings | ( | const VfsPath & | path | ) | const |
Load a texture conversion settings XML file.
Returns NULL on failure.
bool CTextureConverter::Poll | ( | CTexturePtr & | texture, |
VfsPath & | dest, | ||
bool & | ok | ||
) |
Returns the result of a successful ConvertTexture call.
If no result is available yet, returns false. Otherwise, if the conversion succeeded, it sets ok to true and sets texture and dest to the corresponding values passed into ConvertTexture(), then returns true. If the conversion failed, it sets ok to false and doesn't touch the other arguments, then returns true.
|
private |
|
private |
|
private |