|
|
//:Header:222, "_texture", 3b9b50d4
|
|
|
//
|
|
|
// File: llgfx_stexture.h
|
|
|
//
|
|
|
// G A M E.O.N.E - LOW LEVEL LIB V1.0
|
|
|
// Copyright (C) 2001 LEVEL ONE ENTERTAINMENT,
|
|
|
// Licensed under the terms of LGPL.
|
|
|
//:---------------------------------------------------------------------------
|
|
|
//:Description
|
|
|
//
|
|
|
// Texture struktur - laden, convertieren, blitten
|
|
|
//
|
|
|
//:-----------------------------------------------------------------------------
|
|
|
|
|
|
#if !defined(LLGFX_STEXTURE_INCLUDED)
|
|
|
#define LLGFX_STEXTURE_INCLUDED
|
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
TXFMT_ANY, // unbestimmt
|
|
|
TXFMT_RGB_332, // 8Bit/Pixel ohne Palette
|
|
|
TXFMT_I_8, // 8Bit/Pixel Intensity, MONO Format ohne Palette
|
|
|
TXFMT_P_8, // 8Bit/Pixel mit Palette
|
|
|
TXFMT_RGB_555, // 16Bit/Pixel 555 Format
|
|
|
TXFMT_RGB_565, // 16Bit/Pixel 565 Format
|
|
|
TXFMT_RGB, // 24 Bit/Pixel (TXMT_RGB_888)
|
|
|
TXFMT_RxGxBx, // scanline*R(8bit) + scanline*G(8bit) + scanline*B(8bit)
|
|
|
TXFMT_ARGB, // 24 Bit/Pixel + 8 Bit Alpha 0..255
|
|
|
TXFMT_UNKNOWN // ende kennung
|
|
|
} TxFormat;
|
|
|
|
|
|
struct _texture
|
|
|
{
|
|
|
TxFormat format; // TX_FMT
|
|
|
int width; // in Pixels
|
|
|
int height; // in Pixels
|
|
|
int pitch; // bytes pro rasterzeile.
|
|
|
int size; // Gesamtbytes databereich.
|
|
|
int pixsize; // bytes pro pixel
|
|
|
int bpp; // bits pro pixel
|
|
|
|
|
|
TxU8 *data; // Zeiger auf Pixeldaten (modulo = 0 )
|
|
|
TxU32 *pal; // Bei TXFMT_P_8, Zeiger auf ein array mit 256 Elemente: pal[256]
|
|
|
TxU8 *mask; // Maske in width*height*1, pitch=width
|
|
|
};
|
|
|
|
|
|
typedef struct _texture s_texture;
|
|
|
|
|
|
int GetTxFMT_Bpp( TxFormat f);
|
|
|
int GetTxFMT_Bpp(s_texture* txTex);
|
|
|
int GetTxFMT_Size(s_texture* txTex);
|
|
|
|
|
|
|
|
|
inline int GetTxFMT_Bpp(s_texture* txTex)
|
|
|
{
|
|
|
SYS_ASSERT_PTR(txTex);
|
|
|
return GetTxFMT_Bpp(txTex->format);
|
|
|
}
|
|
|
|
|
|
inline int GetTxFMT_Bpp( TxFormat f)
|
|
|
{
|
|
|
SYS_ASSERT( f >= 0 && f < TXFMT_UNKNOWN );
|
|
|
|
|
|
if( f < TXFMT_RGB_555 )
|
|
|
return(1);
|
|
|
if( f < TXFMT_RGB )
|
|
|
return(2);
|
|
|
if( f < TXFMT_ARGB )
|
|
|
return(3);
|
|
|
else
|
|
|
return(4);
|
|
|
}
|
|
|
|
|
|
|
|
|
inline int GetTxFMT_Size(s_texture* txTex)
|
|
|
{
|
|
|
SYS_ASSERT_PTR(txTex);
|
|
|
SYS_ASSERT( txTex->width >= 0 && txTex->width < 0xFFFF ); // Test auf Plausibilit<69>t
|
|
|
SYS_ASSERT( txTex->height >= 0 && txTex->height < 0xFFFF ); // Test auf Plausibilit<69>t
|
|
|
|
|
|
int size = txTex->width * txTex->height * GetTxFMT_Bpp(txTex->format);
|
|
|
return(size);
|
|
|
}
|
|
|
|
|
|
//::12
|
|
|
// +----------------+
|
|
|
// | txFmtAlloc() |
|
|
|
// +----------------+
|
|
|
|
|
|
inline void txFmtAlloc( s_texture *txTex)
|
|
|
{
|
|
|
SYS_ASSERT_PTR(txTex);
|
|
|
|
|
|
txTex->size = GetTxFMT_Size(txTex);
|
|
|
txTex->data = new TxU8 [txTex->size];
|
|
|
txTex->pitch = txTex->width * GetTxFMT_Bpp(txTex);
|
|
|
txTex->mask = 0;
|
|
|
if( txTex->format == TXFMT_P_8 )
|
|
|
txTex->pal = new TxU32 [256]; // Palette
|
|
|
}
|
|
|
|
|
|
//::16
|
|
|
// +---------------+
|
|
|
// | txFmtFree() |
|
|
|
// +---------------+
|
|
|
|
|
|
inline void txFmtFree( s_texture *txTex)
|
|
|
{
|
|
|
SYS_ASSERT_PTR(txTex);
|
|
|
|
|
|
delete txTex->data;
|
|
|
txTex->data = 0;
|
|
|
txTex->size = 0;
|
|
|
|
|
|
if( txTex->format == TXFMT_P_8 )
|
|
|
{
|
|
|
delete txTex->pal;
|
|
|
txTex->pal = 0;
|
|
|
}
|
|
|
|
|
|
delete txTex->mask;
|
|
|
txTex->mask = 0;
|
|
|
}
|
|
|
|
|
|
#endif // LLGFX_STEXTURE_INCLUDED
|