MCPcopy Create free account
hub / github.com/CelestiaProject/Celestia / LoadTextureFromFile

Function LoadTextureFromFile

src/celengine/texture.cpp:1031–1064  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1029
1030
1031Texture* LoadTextureFromFile(const string& filename,
1032 Texture::AddressMode addressMode,
1033 Texture::MipMapMode mipMode)
1034{
1035 // Check for a Celestia texture--these need to be handled specially.
1036 ContentType contentType = DetermineFileType(filename);
1037
1038 if (contentType == Content_CelestiaTexture)
1039 return LoadVirtualTexture(filename);
1040
1041 // All other texture types are handled by first loading an image, then
1042 // creating a texture from that image.
1043 Image* img = LoadImageFromFile(filename);
1044 if (img == NULL)
1045 return NULL;
1046
1047 Texture* tex = CreateTextureFromImage(*img, addressMode, mipMode);
1048
1049 if (contentType == Content_DXT5NormalMap)
1050 {
1051 // If the texture came from a .dxt5nm file then mark it as a dxt5
1052 // compressed normal map. There's no separate OpenGL format for dxt5
1053 // normal maps, so the file extension is the only thing that
1054 // distinguishes it from a plain old dxt5 texture.
1055 if (img->getFormat() == GL_COMPRESSED_RGBA_S3TC_DXT5_EXT)
1056 {
1057 tex->setFormatOptions(Texture::DXT5NormalMap);
1058 }
1059 }
1060
1061 delete img;
1062
1063 return tex;
1064}
1065
1066
1067// Load a height map texture from a file and convert it to a normal map.

Callers 4

initMethod · 0.85
loadMethod · 0.85
initRendererMethod · 0.85
celestia_loadtextureFunction · 0.85

Calls 6

DetermineFileTypeFunction · 0.85
LoadVirtualTextureFunction · 0.85
LoadImageFromFileFunction · 0.85
CreateTextureFromImageFunction · 0.85
getFormatMethod · 0.80
setFormatOptionsMethod · 0.80

Tested by

no test coverage detected