From 59020e3e3dfd98c3619100934d83272287597a37 Mon Sep 17 00:00:00 2001 From: pixel Date: Tue, 7 Aug 2007 09:11:00 +0000 Subject: Modifing a bit the DDS interface - may be useful for texture caching. --- lib/dds.c | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) (limited to 'lib') diff --git a/lib/dds.c b/lib/dds.c index 4939e1b..8138cd9 100644 --- a/lib/dds.c +++ b/lib/dds.c @@ -123,7 +123,7 @@ typedef struct GLubyte *pixels; } DDS_IMAGE_DATA; -static DDS_IMAGE_DATA* loadDDSTextureFile( const char *filename ) +DDS_IMAGE_DATA* loadDDSTextureFile( const char *filename ) { DDS_IMAGE_DATA *pDDSImageData; DDSURFACEDESC2 ddsd; @@ -232,10 +232,20 @@ static DDS_IMAGE_DATA* loadDDSTextureFile( const char *filename ) return pDDSImageData; } -int loadCompressedTexture( const char *fname, int * pwidth, int * pheight ) +void destroyDDS( DDS_IMAGE_DATA *pDDSImageData ) +{ + if( pDDSImageData != NULL ) + { + if( pDDSImageData->pixels != NULL ) + free( pDDSImageData->pixels ); + + free( pDDSImageData ); + } +} + +int loadCompressedTexture( DDS_IMAGE_DATA *pDDSImageData ) { int g_compressedTextureID; - DDS_IMAGE_DATA *pDDSImageData = loadDDSTextureFile( fname ); if( pDDSImageData != NULL ) { @@ -243,11 +253,6 @@ int loadCompressedTexture( const char *fname, int * pwidth, int * pheight ) int nWidth = pDDSImageData->width; int nNumMipMaps = pDDSImageData->numMipMaps; - if (pwidth) - *pwidth = nWidth; - if (pheight) - *pheight = nHeight; - int nBlockSize; if( pDDSImageData->format == GL_COMPRESSED_RGBA_S3TC_DXT1_EXT ) @@ -291,14 +296,6 @@ int loadCompressedTexture( const char *fname, int * pwidth, int * pheight ) } } - if( pDDSImageData != NULL ) - { - if( pDDSImageData->pixels != NULL ) - free( pDDSImageData->pixels ); - - free( pDDSImageData ); - } - return g_compressedTextureID; } -- cgit v1.2.3