MCPcopy Create free account
hub / github.com/dhewm/dhewm3 / ActuallyLoadImage

Method ActuallyLoadImage

neo/renderer/Image_load.cpp:1643–1731  ·  view source on GitHub ↗

=============== ActuallyLoadImage Absolutely every image goes through this path On exit, the idImage will have a valid OpenGL texture number that can be bound =============== */

Source from the content-addressed store, hash-verified

1641===============
1642*/
1643void 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, &timestamp );
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, &timestamp, &depth );
1698
1699 if ( pic == NULL ) {
1700 common->Warning( "Couldn't load image: %s", imgName.c_str() );

Callers 3

ImageFromFunctionMethod · 0.80
ImageFromFileMethod · 0.80
EndLevelLoadMethod · 0.80

Calls 7

R_LoadCubeImagesFunction · 0.85
R_StaticFreeFunction · 0.85
R_LoadImageProgramFunction · 0.85
MD4_BlockChecksumFunction · 0.85
WarningMethod · 0.45
c_strMethod · 0.45
GetBoolMethod · 0.45

Tested by

no test coverage detected