| 1490 | } |
| 1491 | |
| 1492 | GFXCubemap* GFXTextureManager::createCubemap( const Torque::Path &path ) |
| 1493 | { |
| 1494 | // Very first thing... check the cache. |
| 1495 | CubemapTable::Iterator iter = mCubemapTable.find( path.getFullPath() ); |
| 1496 | if ( iter != mCubemapTable.end() ) |
| 1497 | return iter->value; |
| 1498 | |
| 1499 | // Not in the cache... we have to load it ourselves. |
| 1500 | |
| 1501 | // First check for a DDS file. |
| 1502 | if ( !sDDSExt.equal( path.getExtension(), String::NoCase ) ) |
| 1503 | { |
| 1504 | // At the moment we only support DDS cubemaps. |
| 1505 | return NULL; |
| 1506 | } |
| 1507 | |
| 1508 | const U32 scalePower = getTextureDownscalePower( NULL ); |
| 1509 | |
| 1510 | // Ok... load the DDS file then. |
| 1511 | Resource<DDSFile> dds = DDSFile::load( path, scalePower ); |
| 1512 | if ( !dds || !dds->isCubemap() ) |
| 1513 | { |
| 1514 | // This wasn't a cubemap... give up too. |
| 1515 | return NULL; |
| 1516 | } |
| 1517 | |
| 1518 | // We loaded the cubemap dds, so now we create the GFXCubemap from it. |
| 1519 | GFXCubemap *cubemap = GFX->createCubemap(); |
| 1520 | cubemap->initStatic( dds ); |
| 1521 | cubemap->_setPath( path.getFullPath() ); |
| 1522 | |
| 1523 | // Store the cubemap into the cache. |
| 1524 | mCubemapTable.insertUnique( path.getFullPath(), cubemap ); |
| 1525 | |
| 1526 | return cubemap; |
| 1527 | } |
| 1528 | |
| 1529 | void GFXTextureManager::releaseCubemap( GFXCubemap *cubemap ) |
| 1530 | { |
nothing calls this directly
no test coverage detected