Overview   Project   Class   Tree   Deprecated   Index 
0 A.D.
FRAMES    NO FRAMES
SUMMARY:  INNER | FIELD | CONSTR | METHOD

lib.res.graphics
Struct TexCodecVTbl

   in tex_codec.h

struct TexCodecVTbl

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.


Field Summary
 LibError ( * )( DynArray* RESTRICT da, Tex* RESTRICT t ) decode
          decode the file into a Tex structure.
 LibError ( * )( Tex* RESTRICT t, DynArray* RESTRICT da ) encode
          encode the texture data into the codec's file format (in memory).
 size_t ( * )( const u8* file ) hdr_size
          return size of the file header supported by this codec.
 bool ( * )( const char* ext ) is_ext
          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).
 bool ( * )( const u8* file ) is_hdr
          indicate if the data appears to be an instance of this codec's header, i.
 const char* name
          name of codec for debug purposes.
 const TexCodecVTbl* next
          intrusive linked-list of codecs: more convenient than fixed-size static storage.
 LibError ( * )( Tex* t, uint s ) transform
          transform the texture's pixel format.
 

Field Detail

decode

public LibError ( * decode )( DynArray* RESTRICT da, Tex* RESTRICT t );
decode the file into a Tex structure.
Parameters:
da - input data array (not const, because the texture may have to be flipped in-place - see "texture orientation"). its size is guaranteed to be >= 4. (usually enough to compare the header's "magic" field; anyway, no legitimate file will be smaller)
t - output texture object
Returns:
LibError

encode

public LibError ( * encode )( Tex* RESTRICT t, DynArray* RESTRICT da );
encode the texture data into the codec's file format (in memory).
Parameters:
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.
Returns:
LibError

hdr_size

public size_t ( * hdr_size )( const u8* file );
return size of the file header supported by this codec.
Parameters:
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.
Returns:
size [bytes]

is_ext

public bool ( * is_ext )( const char* ext );
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).
Parameters:
ext - non-NULL extension string; does not contain '.'. must be compared as case-insensitive.
Returns:
bool

is_hdr

public bool ( * is_hdr )( const u8* file );
indicate if the data appears to be an instance of this codec's header, i.e. can this codec decode it?
Parameters:
file - input data; only guaranteed to be 4 bytes! (this should be enough to examine the header's 'magic' field)
Returns:
bool

name

public const char* name;
name of codec for debug purposes. typically set via TEX_CODEC_REGISTER.

next

public const TexCodecVTbl* next;
intrusive linked-list of codecs: more convenient than fixed-size static storage. set by caller; should be initialized to NULL.

transform

public LibError ( * transform )( Tex* t, uint transforms );
transform the texture's pixel format.
Parameters:
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.

 Overview   Project   Class   Tree   Deprecated   Index 
0 A.D.
Generated on September 04, 2007 at 18:14
CppDoc v2.4.0
FRAMES    NO FRAMES
SUMMARY:  INNER | FIELD | CONSTR | METHOD