Pyrogenesis HEAD
Pyrogenesis, a RTS Engine
tex_codec.cpp File Reference
#include "precompiled.h"
#include "tex_codec.h"
#include <string.h>
#include <stdlib.h>
#include "lib/allocators/shared_ptr.h"
#include "tex.h"
Include dependency graph for tex_codec.cpp:

Functions

Status tex_codec_for_filename (const OsPath &extension, const ITexCodec **c)
 Find codec that recognizes the desired output file extension. More...
 
Status tex_codec_for_header (const u8 *file, size_t file_size, const ITexCodec **c)
 find codec that recognizes the header's magic field. More...
 
Status tex_codec_transform (Tex *t, size_t transforms)
 transform the texture's pixel format. More...
 
std::vector< RowPtrtex_codec_alloc_rows (const u8 *data, size_t h, size_t pitch, size_t src_flags, size_t dst_orientation)
 
Status tex_codec_write (Tex *t, size_t transforms, const void *hdr, size_t hdr_size, DynArray *da)
 apply transforms and then copy header and image into output buffer. More...
 

Variables

TexCodecDds DdsCodec
 
TexCodecPng PngCodec
 
TexCodecTga TgaCodec
 
TexCodecBmp BmpCodec
 
static const ITexCodeccodecs []
 
static const int codecs_len = sizeof(codecs) / sizeof(ITexCodec*)
 

Function Documentation

◆ tex_codec_alloc_rows()

std::vector< RowPtr > tex_codec_alloc_rows ( const u8 data,
size_t  h,
size_t  pitch,
size_t  src_flags,
size_t  dst_orientation 
)

◆ tex_codec_for_filename()

Status tex_codec_for_filename ( const OsPath extension,
const ITexCodec **  c 
)

Find codec that recognizes the desired output file extension.

Parameters
extension
c(out) vtbl of responsible codec
Returns
Status; ERR::RES_UNKNOWN_FORMAT (without warning, because this is called by tex_is_known_extension) if no codec indicates they can handle the given extension.

◆ tex_codec_for_header()

Status tex_codec_for_header ( const u8 data,
size_t  data_size,
const ITexCodec **  c 
)

find codec that recognizes the header's magic field.

Parameters
datatypically contents of file, but need only include the (first 4 bytes of) header.
data_size[bytes]
c(out) vtbl of responsible codec
Returns
Status; ERR::RES_UNKNOWN_FORMAT if no codec indicates they can handle the given format (header).

◆ tex_codec_transform()

Status tex_codec_transform ( Tex t,
size_t  transforms 
)

transform the texture's pixel format.

tries each codec's transform method once, or until one indicates success.

Parameters
ttexture object
transformsOR-ed combination of TEX_* flags that are to be changed.
Returns
Status

◆ tex_codec_write()

Status tex_codec_write ( Tex t,
size_t  transforms,
const void *  hdr,
size_t  hdr_size,
DynArray da 
)

apply transforms and then copy header and image into output buffer.

Parameters
tinput texture object
transformstransformations to be applied to pixel format
hdrheader data
hdr_size[bytes]
daoutput data array (will be expanded as necessary)
Returns
Status

Variable Documentation

◆ BmpCodec

TexCodecBmp BmpCodec

◆ codecs

const ITexCodec* codecs[]
static
Initial value:
virtual method table for TexCodecs.
Definition: tex_codec.h:40
TexCodecTga TgaCodec
Definition: tex_codec.cpp:39
TexCodecPng PngCodec
Definition: tex_codec.cpp:38
TexCodecBmp BmpCodec
Definition: tex_codec.cpp:40
TexCodecDds DdsCodec
Definition: tex_codec.cpp:37

◆ codecs_len

const int codecs_len = sizeof(codecs) / sizeof(ITexCodec*)
static

◆ DdsCodec

TexCodecDds DdsCodec

◆ PngCodec

TexCodecPng PngCodec

◆ TgaCodec

TexCodecTga TgaCodec