![]() |
Pyrogenesis HEAD
Pyrogenesis, a RTS Engine
|
virtual method table for TexCodecs. More...
#include <tex_codec.h>

Public Member Functions | |
| virtual Status | decode (u8 *data, size_t size, Tex *RESTRICT t) const =0 |
| decode the file into a Tex structure. More... | |
| virtual Status | encode (Tex *RESTRICT t, DynArray *RESTRICT da) const =0 |
| encode the texture data into the codec's file format (in memory). More... | |
| virtual Status | transform (Tex *t, size_t transforms) const =0 |
| transform the texture's pixel format. More... | |
| virtual bool | is_hdr (const u8 *file) const =0 |
| indicate if the data appears to be an instance of this codec's header, i.e. More... | |
| virtual bool | is_ext (const OsPath &extension) const =0 |
| is the extension that of a file format supported by this codec? More... | |
| virtual size_t | hdr_size (const u8 *file) const =0 |
| return size of the file header supported by this codec. More... | |
| virtual const wchar_t * | get_name () const =0 |
| name of codec for debug purposes. More... | |
| virtual | ~ITexCodec () |
virtual method table for TexCodecs.
rationale: this works in C and also allows storing name and next in vtbl. 'template method'-style interface to increase code reuse and simplify writing new codecs.
|
inlinevirtual |
decode the file into a Tex structure.
| data | input data array (non-const, because the texture may have to be flipped in-place - see "texture orientation"). |
| size | [bytes] of data, always >= 4 (this is usually enough to compare the header's "magic" field, and no legitimate file will be smaller) |
| t | output texture object |
Implemented in TexCodecPng, TexCodecDds, TexCodecTga, and TexCodecBmp.
encode the texture data into the codec's file format (in memory).
| t | input texture object. note: non-const because encoding may require a Tex::transform. |
| da | output data array, allocated by codec. rationale: some codecs cannot calculate the output size beforehand (e.g. PNG output via libpng), so the output memory cannot be allocated by the caller. |
Implemented in TexCodecPng, TexCodecDds, TexCodecTga, and TexCodecBmp.
|
pure virtual |
name of codec for debug purposes.
typically set via TEX_CODEC_REGISTER.
Implemented in TexCodecPng, TexCodecDds, TexCodecTga, and TexCodecBmp.
|
pure virtual |
return size of the file header supported by this codec.
| file | the specific header to return length of (taking its variable-length fields into account). if NULL, return minimum guaranteed header size, i.e. the header without any variable-length fields. |
Implemented in TexCodecPng, TexCodecDds, TexCodecTga, and TexCodecBmp.
|
pure virtual |
is the extension that of a file format supported by this codec?
rationale: cannot just return the extension string and have caller compare it (-> smaller code) because a codec's file format may have several valid extensions (e.g. jpg and jpeg).
| extension | (including '.') |
Implemented in TexCodecPng, TexCodecDds, TexCodecTga, and TexCodecBmp.
|
pure virtual |
indicate if the data appears to be an instance of this codec's header, i.e.
can this codec decode it?
| file | input data; only guaranteed to be 4 bytes! (this should be enough to examine the header's 'magic' field) |
Implemented in TexCodecPng, TexCodecDds, TexCodecTga, and TexCodecBmp.
transform the texture's pixel format.
| t | texture object |
| transforms | OR-ed combination of TEX_* flags that are to be changed. note: the codec needs only handle situations specific to its format; generic pixel format transforms are handled by the caller. |
Implemented in TexCodecPng, TexCodecDds, TexCodecTga, and TexCodecBmp.