diff options
| author | pixel <pixel> | 2007-08-07 09:11:00 +0000 | 
|---|---|---|
| committer | pixel <pixel> | 2007-08-07 09:11:00 +0000 | 
| commit | 59020e3e3dfd98c3619100934d83272287597a37 (patch) | |
| tree | f115f5fa55acc480a5ca04e9f76317479207fa48 | |
| parent | 84c92ab61304209ccd83935c7745b5d535109456 (diff) | |
Modifing a bit the DDS interface - may be useful for texture caching.
| -rw-r--r-- | include/dds.h | 16 | ||||
| -rw-r--r-- | lib/dds.c | 29 | 
2 files changed, 28 insertions, 17 deletions
diff --git a/include/dds.h b/include/dds.h index 417c755..8339cb0 100644 --- a/include/dds.h +++ b/include/dds.h @@ -5,10 +5,24 @@  extern "C" {  #endif +#include <GL/gl.h> + +typedef struct +{ +    GLsizei  width; +    GLsizei  height; +    GLint    components; +    GLenum   format; +    int      numMipMaps; +    GLubyte *pixels; +} DDS_IMAGE_DATA; +  int ddsInit(); +DDS_IMAGE_DATA* loadDDSTextureFile( const char *filename ); +void destroyDDS( DDS_IMAGE_DATA *pDDSImageData );  // returns the OpenGL-generated texture index. -int loadCompressedTexture( const char *fname, int * width, int * height ); +int loadCompressedTexture( DDS_IMAGE_DATA *pDDSImageData );  #ifdef __cplusplus  } @@ -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;  }  | 
