0ad/source/lib/res/graphics/tex_internal.h
janwas 871cdb6ef9 # SwEng (reduce full recompiles by splitting up master error header)
- error codes now accessed as ERR::NO_MEM, INFO::OK etc.
- no more X-macros => the above are now recognized by visual assist
- error codes are defined by the module originating them (lib_errors has
some generic ones)
  => no full rebuild when adding some
- error descriptions are now in C++ files => can be changed without full
rebuild

added AT_STARTUP in lib.h.

This was SVN commit r4374.
2006-09-22 13:19:40 +00:00

86 lines
2.8 KiB
C

/**
* =========================================================================
* File : tex_internal.h
* Project : 0 A.D.
* Description : private texture loader helper functions
*
* @author Jan.Wassenberg@stud.uni-karlsruhe.de
* =========================================================================
*/
/*
* Copyright (c) 2006 Jan Wassenberg
*
* Redistribution and/or modification are also permitted under the
* terms of the GNU General Public License as published by the
* Free Software Foundation (version 2 or later, at your option).
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
#ifndef TEX_INTERNAL_H__
#define TEX_INTERNAL_H__
#include "lib/res/res.h" // error codes and mem.h
#include "lib/allocators.h" // DynArray
/**
* check if the given texture format is acceptable: 8bpp grey,
* 24bpp color or 32bpp color+alpha (BGR / upside down are permitted).
* basically, this is the "plain" format understood by all codecs and
* tex_codec_plain_transform.
* @param bpp bits per pixel
* @param flags TexFlags
* @return LibError
**/
extern LibError tex_validate_plain_format(uint bpp, uint flags);
/**
* indicate if the two vertical orientations match.
*
* used by tex_codec.
*
* @param src_flags TexFlags, used to extract the orientation.
* we ask for this instead of src_orientation so callers don't have to
* mask off TEX_ORIENTATION.
* @param dst_orientation orientation to compare against.
* can be one of TEX_BOTTOM_UP, TEX_TOP_DOWN, or 0 for the
* "global orientation".
* @return bool
**/
extern bool tex_orientations_match(uint src_flags, uint dst_orientation);
/**
* decode an in-memory texture file into texture object.
*
* split out of tex_load to ease resource cleanup and allow
* decoding images without needing to write out to disk.
*
* @param data input data
* @param data_size its size [bytes]
* @param dtor the function used to release it when the texture object is
* freed (can be NULL). note: this is necessary because the Tex object
* assumes ownership (necessary due to Tex.hm).
* @param t output texture object.
* @return LibError.
**/
extern LibError tex_decode(const u8* data, size_t data_size, MEM_DTOR dtor, Tex* t);
/**
* encode a texture into a memory buffer in the desired file format.
*
* @param t input texture object
* @param fn filename; only used to determine the desired file format
* (via extension)
* @param da output memory array. allocated here; caller must free it
* when no longer needed. invalid unless function succeeds.
* @return LibError
**/
extern LibError tex_encode(Tex* t, const char* fn, DynArray* da);
#endif // #ifndef TEX_INTERNAL_H__