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

Method LoadTexture

src/Loaders/nfs3_loader.cpp:687–711  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

685}
686
687Texture NFS3::LoadTexture(TEXTUREBLOCK track_texture, const std::string &track_name) {
688 std::stringstream filename;
689 std::stringstream filename_alpha;
690
691 if (track_texture.islane) {
692 filename << "../resources/sfx/" << setfill('0') << setw(4) << track_texture.texture + 9 << ".BMP";
693 filename_alpha << "../resources/sfx/" << setfill('0') << setw(4) << track_texture.texture + 9 << "-a.BMP";
694 } else {
695 filename << TRACK_PATH << ToString(NFS_3) << "/" << track_name << "/textures/" << setfill('0') << setw(4) << track_texture.texture << ".BMP";
696 filename_alpha << TRACK_PATH << ToString(NFS_3) << "/" << track_name << "/textures/" << setfill('0') << setw(4) << track_texture.texture << "-a.BMP";
697 }
698
699 GLubyte *data;
700 GLsizei width = track_texture.width;
701 GLsizei height = track_texture.height;
702
703 if (!Utils::LoadBmpWithAlpha(filename.str().c_str(), filename_alpha.str().c_str(), &data, &width, &height)) {
704 LOG(WARNING) << "Texture " << filename.str() << " or " << filename_alpha.str() << " did not load succesfully!";
705 // If the texture is missing, load a "MISSING" texture of identical size.
706 ASSERT(Utils::LoadBmpWithAlpha("../resources/misc/missing.bmp", "../resources/misc/missing-a.bmp", &data, &width, &height), "Even the 'missing' texture is missing!");
707 return Texture((unsigned int) track_texture.texture, data, static_cast<unsigned int>(width), static_cast<unsigned int>(height));
708 }
709
710 return Texture((unsigned int) track_texture.texture, data, static_cast<unsigned int>(track_texture.width), static_cast<unsigned int>(track_texture.height));
711}
712
713void NFS3::FreeFRD(const std::shared_ptr<TRACK> &track) {
714 // Free FRD data

Callers

nothing calls this directly

Calls 2

LoadBmpWithAlphaFunction · 0.85
TextureClass · 0.85

Tested by

no test coverage detected