| 463 | } |
| 464 | |
| 465 | bool TriTextureRes::Save( const wchar_t* filename ) |
| 466 | { |
| 467 | USE_MAIN_THREAD_RENDER_CONTEXT(); |
| 468 | |
| 469 | // Only permit saving of 2d and cube textures |
| 470 | if( m_type == TEX_TYPE_INVALID ) |
| 471 | { |
| 472 | CCP_LOGERR( "Texture save failed - texture is invalid" ); |
| 473 | return false; |
| 474 | } |
| 475 | else if( m_type != TEX_TYPE_2D && m_type != TEX_TYPE_CUBE ) |
| 476 | { |
| 477 | CCP_LOGERR( "Texture save failed - only 2d and cubemap textures can be saved" ); |
| 478 | return false; |
| 479 | } |
| 480 | |
| 481 | if( !ImageIO::IsSaveSupported( filename, *this ) ) |
| 482 | { |
| 483 | CCP_LOGERR( "Unsupported format for saving (%S)", filename ); |
| 484 | return false; |
| 485 | } |
| 486 | |
| 487 | Tr2HostBitmapPtr saveBitmap; |
| 488 | |
| 489 | if( !saveBitmap.CreateInstance() || |
| 490 | !saveBitmap->CreateFromBitmapDimensions( *this ) || |
| 491 | !saveBitmap->CopyFromTextureRes( *this, renderContext ) ) |
| 492 | { |
| 493 | return false; |
| 494 | } |
| 495 | |
| 496 | return saveBitmap->Save( filename ); |
| 497 | } |
| 498 | |
| 499 | bool TriTextureRes::SaveAsync( const wchar_t* filename ) |
| 500 | { |
no test coverage detected