DDS loading improvement
by Jeremiah Fulbright · in Torque Game Engine Advanced · 08/13/2006 (11:42 pm) · 1 replies
This isn't a bug, but more of an improvement to the current DDS loading "hackery". I don't know if it has been modified for MS4 or not, but if not, then its a good improvement!
Trunk - GFXTextureManager.cpp:
Changes - GFXTextureManager.cpp:
It is the same as previous code, but it works better in that location, since if the file was found, it will return the full path including the .dds extension. Otherwise, you need to have .dds added to every filename and this makes it tough (if not impossible) for interior dds support.
You can keep the old code in place, if you want to make sure to support actual filename that has .dds on it, but in most cases, this will allow using dds without almost no other changes (or should)
Trunk - GFXTextureManager.cpp:
GFXTextureObject *GFXTextureManager::createTexture( const char *filename, GFXTextureProfile *profile )
{
// hack to load .dds files until proper support is in
if( dStrstr( filename, ".dds" ) )
{
GFXTextureObject *obj = _loadDDSHack( filename, profile );
if( !obj ) return NULL;
linkTexture( obj );
// Return the new texture!
return obj;
}
// Check the cache first...
ResourceObject * ro = GBitmap::findBmpResource(filename);
if (ro)
{
StringTableEntry fileName = ro->getFullPath();
GFXTextureObject * cacheHit = hashFind(fileName);
if (cacheHit)
return cacheHit;
}Changes - GFXTextureManager.cpp:
GFXTextureObject *GFXTextureManager::createTexture( const char *filename, GFXTextureProfile *profile )
{
// Check the cache first...
ResourceObject * ro = GBitmap::findBmpResource(filename);
if (ro)
{
StringTableEntry fileName = ro->getFullPath();
GFXTextureObject * cacheHit = hashFind(fileName);
if (cacheHit)
return cacheHit;
[b]
// hack to load .dds files until proper support is in
if( dStrstr( filename, ".dds" ) )
{
GFXTextureObject *obj = _loadDDSHack( filename, profile );
if( !obj ) return NULL;
linkTexture( obj );
// Return the new texture!
return obj;
}
[/b]
}It is the same as previous code, but it works better in that location, since if the file was found, it will return the full path including the .dds extension. Otherwise, you need to have .dds added to every filename and this makes it tough (if not impossible) for interior dds support.
You can keep the old code in place, if you want to make sure to support actual filename that has .dds on it, but in most cases, this will allow using dds without almost no other changes (or should)
Torque Owner Jeremiah Fulbright
Trunk - gBitmap.cpp:
#define EXT_ARRAY_SIZE 5 static const char* extArray[EXT_ARRAY_SIZE] = { "", ".jpg", ".png", ".gif", ".bmp" };Changes - gBitmap.cpp:
#define EXT_ARRAY_SIZE [b]6[/b] static const char* extArray[EXT_ARRAY_SIZE] = { "", ".jpg", ".png", ".gif", ".bmp"[b], ".dds"[/b] };If you have modified your Arrays or such, just make a note to add 1 to it.. and add ".dds", to the array.