MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / loadUncompressedTexture

Method loadUncompressedTexture

Engine/source/gfx/gfxTextureManager.cpp:892–929  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

890}
891
892GBitmap *GFXTextureManager::loadUncompressedTexture(const Torque::Path &path, GFXTextureProfile *profile, U32 width, U32 height, bool genMips)
893{
894 GBitmap* inBitmap = loadUncompressedTexture(path, &GFXTexturePersistentProfile);
895
896 if (inBitmap == NULL)
897 {
898 Con::warnf("GFXTextureManager::loadUncompressedTexture unable to load texture: %s", path.getFullPath().c_str());
899 return NULL;
900 }
901
902 // Set the format so we don't have to handle which channels are where.
903 if (!inBitmap->setFormat(GFXFormatR8G8B8A8))
904 {
905 Con::warnf("GFXTextureManager::loadUncompressedTexture unable to handle texture format: %s", path.getFullPath().c_str());
906 return NULL;
907 }
908
909 GBitmap* outBmp = new GBitmap(width, height, true, GFXFormatR8G8B8A8);
910
911 U8* oBits = (U8*)outBmp->getWritableBits();
912 for (S32 y = 0; y < width; y++)
913 {
914 for (S32 x = 0; x < height; x++)
915 {
916 ColorI texelColor = inBitmap->sampleTexel(x / F32(width), y / F32(height), true).toColorI(true);
917
918 oBits[(y * width + x) * 4] = texelColor.red;
919 oBits[(y * width + x) * 4 + 1] = texelColor.green;
920 oBits[(y * width + x) * 4 + 2] = texelColor.blue;
921 oBits[(y * width + x) * 4 + 3] = texelColor.alpha;
922 }
923 }
924
925 if (genMips)
926 outBmp->extrudeMipLevels();
927
928 return outBmp;
929}
930
931GBitmap *GFXTextureManager::loadUncompressedTexture(const Torque::Path &path, GFXTextureProfile *profile)
932{

Callers 1

setTextureMethod · 0.80

Calls 15

IsFileFunction · 0.85
loadFunction · 0.85
isPow2Function · 0.85
getWritableBitsMethod · 0.80
toColorIMethod · 0.80
sampleTexelMethod · 0.80
extrudeMipLevelsMethod · 0.80
getFileNameMethod · 0.80
decompressToGBitmapMethod · 0.80
canDownscaleMethod · 0.80
chopTopMipsMethod · 0.80
warnfFunction · 0.50

Tested by

no test coverage detected