![]() |
MapLink Pro 11.1.1.0.
Envitia MapLink Pro: The Ultimate Mapping Application Toolkit
|
This utility class provides methods to load raster images that make up the textures associated with a model.
Public Member Functions | |
TSL3DTextureLoader () | |
void | destroy () |
bool | loadTexture (const char *filename, TSLUSize textureWidth, TSLUSize textureHeight, TSLUSize *actualWidth, TSLUSize *actualheight, int *depth, unsigned char **texture) |
bool | textureDimensions (const char *filename, TSLUSize *width, TSLUSize *height) |
void * | operator new (size_t size) TSL_NO_THROW |
void * | operator new (size_t size, char *filename, int line) |
Static Public Member Functions | |
static void | freeBuffer (unsigned char *buffer) |
TSL3DTextureLoader::TSL3DTextureLoader | ( | ) |
void TSL3DTextureLoader::destroy | ( | ) |
Deletes this object.
|
static |
Frees the memory buffer allocated by a call to loadTexture. Applications should call this function instead of deleting the buffer directly to ensure the correct heap is used.
bool TSL3DTextureLoader::loadTexture | ( | const char * | filename, |
TSLUSize | textureWidth, | ||
TSLUSize | textureHeight, | ||
TSLUSize * | actualWidth, | ||
TSLUSize * | actualheight, | ||
int * | depth, | ||
unsigned char ** | texture ) |
Loads the texture specified by filename and returns it as an array of RGB values via the texture parameter. It is the user's responsibility to free this memory once it has been finished with.
Note that some 3D implementations expect texture sizes to be powers of 2. In this case, you should specify the desired texture size in this format and the returned data will indicate how large the actual texture is for non-square textures. This information can then be used to adjust texture coordinates for the resulting model to only cover the actual texture size.
filename | full path to the texture file to load including filename |
textureWidth | desired width of the texture in pixels |
textureHeight | desired height of the texture in pixels |
actualWidth | set to the actual width of the loaded texture |
actualHeight | set to the actual height of the loaded texture |
depth | set to the colour depth of the loaded texture. This will either be 8 or 24. |
texture | set to the raw texture data. If depth is 8, this will consist of actualWidth * actualHeight colour indexes. If depth is 24, this will consist of actualWidth * actualHeight RGB components, with each component being 8 bits. Note that it is the user's responsibility to delete this memory by calling freeBuffer on this class. |
void * TSL3DTextureLoader::operator new | ( | size_t | size | ) |
Allocation override for API redirection.
void * TSL3DTextureLoader::operator new | ( | size_t | size, |
char * | filename, | ||
int | line ) |
When included in an MFC application in debug mode, the debug new expects this to be here. Override it and return the same as the normal one. The library must include it when compiled in release mode, since the user's application may be in debug mode.
bool TSL3DTextureLoader::textureDimensions | ( | const char * | filename, |
TSLUSize * | width, | ||
TSLUSize * | height ) |
Queries the specified file for its dimensions. These values can be used to determine an appropriate size for the texture.
filename | full path to the texture including filename |
width | set to the width of the texture in pixels |
height | set to the height of the texture in pixels |