MCPcopy Create free account
hub / github.com/OpenNFS/OpenNFS / LoadTexture

Method LoadTexture

src/Loaders/nfs4_loader.cpp:904–929  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

902}
903
904Texture NFS4::LoadTexture(TEXTUREBLOCK track_texture, const std::string &track_name) {
905 std::stringstream filename;
906 std::stringstream filename_alpha;
907
908 if (track_texture.islane) {
909 filename << "../resources/sfx/" << setfill('0') << setw(4) << (track_texture.texture - 2048) + 9 << ".BMP";
910 filename_alpha << "../resources/sfx/" << setfill('0') << setw(4) << (track_texture.texture - 2048) + 9 << "-a.BMP";
911 } else {
912 filename << TRACK_PATH << ToString(NFS_4) << "/" << track_name << "/textures/" << setfill('0') << setw(4) << track_texture.texture << ".BMP";
913 filename_alpha << TRACK_PATH << ToString(NFS_4) << "/" << track_name << "/textures/" << setfill('0') << setw(4) << track_texture.texture << "-a.BMP";
914 }
915
916 // Width and height data isn't set properly in FRD loader so deduce from bmp
917 GLubyte *data;
918 GLsizei width;
919 GLsizei height;
920
921 if (!Utils::LoadBmpCustomAlpha(filename.str().c_str(), &data, &width, &height, 0)) {
922 std::cerr << "Texture " << filename.str() << " or " << filename_alpha.str() << " did not load succesfully!" << std::endl;
923 // If the texture is missing, load a "MISSING" texture of identical size.
924 ASSERT(Utils::LoadBmpWithAlpha("../resources/misc/missing.bmp", "../resources/misc/missing-a.bmp", &data, &width, &height), "Even the 'missing' texture is missing!");
925 return Texture((unsigned int) track_texture.texture, data, static_cast<unsigned int>(track_texture.width), static_cast<unsigned int>(track_texture.height));
926 }
927
928 return Texture((unsigned int) track_texture.texture, data, static_cast<unsigned int>(width), static_cast<unsigned int>(height));
929}

Callers

nothing calls this directly

Calls 3

LoadBmpCustomAlphaFunction · 0.85
LoadBmpWithAlphaFunction · 0.85
TextureClass · 0.85

Tested by

no test coverage detected