=============== ActuallyLoadImage Absolutely every image goes through this path On exit, the idImage will have a valid OpenGL texture number that can be bound =============== */
| 1641 | =============== |
| 1642 | */ |
| 1643 | void idImage::ActuallyLoadImage( bool checkForPrecompressed, bool fromBackEnd ) { |
| 1644 | int width, height; |
| 1645 | byte *pic; |
| 1646 | |
| 1647 | // this is the ONLY place generatorFunction will ever be called |
| 1648 | if ( generatorFunction ) { |
| 1649 | generatorFunction( this ); |
| 1650 | return; |
| 1651 | } |
| 1652 | |
| 1653 | // if we are a partial image, we are only going to load from a compressed file |
| 1654 | if ( isPartialImage ) { |
| 1655 | if ( CheckPrecompressedImage( false ) ) { |
| 1656 | return; |
| 1657 | } |
| 1658 | // this is an error -- the partial image failed to load |
| 1659 | MakeDefault(); |
| 1660 | return; |
| 1661 | } |
| 1662 | |
| 1663 | // |
| 1664 | // load the image from disk |
| 1665 | // |
| 1666 | if ( cubeFiles != CF_2D ) { |
| 1667 | byte *pics[6]; |
| 1668 | |
| 1669 | // we don't check for pre-compressed cube images currently |
| 1670 | R_LoadCubeImages( imgName, cubeFiles, pics, &width, ×tamp ); |
| 1671 | |
| 1672 | if ( pics[0] == NULL ) { |
| 1673 | common->Warning( "Couldn't load cube image: %s", imgName.c_str() ); |
| 1674 | MakeDefault(); |
| 1675 | return; |
| 1676 | } |
| 1677 | |
| 1678 | GenerateCubeImage( (const byte **)pics, width, filter, allowDownSize, depth ); |
| 1679 | precompressedFile = false; |
| 1680 | |
| 1681 | for ( int i = 0 ; i < 6 ; i++ ) { |
| 1682 | if ( pics[i] ) { |
| 1683 | R_StaticFree( pics[i] ); |
| 1684 | } |
| 1685 | } |
| 1686 | } else { |
| 1687 | // see if we have a pre-generated image file that is |
| 1688 | // already image processed and compressed |
| 1689 | if ( checkForPrecompressed && globalImages->image_usePrecompressedTextures.GetBool() ) { |
| 1690 | if ( CheckPrecompressedImage( true ) ) { |
| 1691 | // we got the precompressed image |
| 1692 | return; |
| 1693 | } |
| 1694 | // fall through to load the normal image |
| 1695 | } |
| 1696 | |
| 1697 | R_LoadImageProgram( imgName, &pic, &width, &height, ×tamp, &depth ); |
| 1698 | |
| 1699 | if ( pic == NULL ) { |
| 1700 | common->Warning( "Couldn't load image: %s", imgName.c_str() ); |
no test coverage detected