Replacing foo.png with foo.jpg and foo.alpha.jpg?
by Keith Johnston · in Torque Game Engine · 07/14/2005 (6:50 am) · 2 replies
Recently we found this code in gTextManager.cc - it allows you to replace a .png with two .jpg files. One that contains the RGB and one that contains the alpha channel. My question is - under what conditions would this not work? When would sgForcePalettedTexture be true or when would a graphics card not support paletted textures? Seems to work fine on our graphics cards, but I wonder if this will bomb on other cards.
// if a jpg, and RGB, look for file.alpha.jpg as alpha channel
if ( (!sgForcePalettedTexture || !dglDoesSupportPalettedTexture()) && !dStricmp(extArray[i],".jpg") && bmp && bmp->getFormat()==GBitmap::RGB)
{
...
Thanks,
Keith
// if a jpg, and RGB, look for file.alpha.jpg as alpha channel
if ( (!sgForcePalettedTexture || !dglDoesSupportPalettedTexture()) && !dStricmp(extArray[i],".jpg") && bmp && bmp->getFormat()==GBitmap::RGB)
{
...
Thanks,
Keith
#2
07/14/2005 (10:51 am)
Awesome! It is amazing how much space this can save. Thanks for the contribution.
Torque Owner Clark Fagot
The palletized texture code is really a red herring. The only reason you would have palletized textures is if you created them in your art pipeline. What "force palletized" does is choose the palletized version of a texture over the standard version (both would be on the hard drive). That was done for Tribes 2 so that low end cards could choose a lower impact texture. If you didn't create any bm8's, force palletized wouldn't do anything (you can see that by reading the loadBitmapInstance routine, which is the only place that really cares about the pref).
The logic about palletted textures in the code snippet is just to make sure a palletted texture doesn't slip into this code. But I think it is actually not needed since we are already checking to make sure the extension is jpg (so we are obviously not loading a bm8 at the moment).
In fact, the force palletized logic should probably be removed from the if statement since if someone set $pref::OpenGL::forcePalettedTexture then the alpha components would erroneously not get read in.