in IVideoDriver.h just after
Code: Select all
class IMaterialRenderer;
class IGPUProgrammingServices;
Code: Select all
//dynamic texture size support
enum IRR_TEXTURESIZEOPT
{
IRR_TEX_TINY,
IRR_TEX_SMALL,
IRR_TEX_MEDIUM,
IRR_TEX_LARGE
};
add
Code: Select all
//sets size of texture support desired
void setTextureSizeSupport ( IRR_TEXTURESIZEOPT in ) { textureSizeSupport = in; }
//gets current texture size support
IRR_TEXTURESIZEOPT getTextureSizeSupport () { return textureSizeSupport; }
IRR_TEXTURESIZEOPT textureSizeSupport;
Code: Select all
#ifdef _DEBUG
setDebugName("CNullDriver");
#endif
Code: Select all
textureSizeSupport = IRR_TEX_LARGE; //default to full texture size support
then in
CNullDriver::loadTextureFromFile(io::IReadFile* file, const c8 *hashName ) change
Code: Select all
if (image)
{
// create texture from surface
texture = createDeviceDependentTexture(image, hashName ? hashName : file->getFileName() );
os::Printer::log("Loaded texture", file->getFileName());
image->drop();
}
Code: Select all
if (image)
{
if (textureSizeSupport == IRR_TEX_LARGE) {
// create texture from surface
texture = createDeviceDependentTexture(image, hashName ? hashName : file->getFileName() );
os::Printer::log("Loaded texture", file->getFileName());
image->drop();
} else {
// create texture from surface
core::dimension2d<s32> texSize = image->getDimension();
f32 sizeMode = 1.0f;
switch (textureSizeSupport) {
case IRR_TEX_TINY:
sizeMode = 0.10f;
break;
case IRR_TEX_SMALL:
sizeMode = 0.25;
break;
case IRR_TEX_MEDIUM:
sizeMode = 0.50;
break;
case IRR_TEX_LARGE:
sizeMode = 1.0f;
break;
}
texSize.Width = (s32)ceil((f32)texSize.Width * sizeMode);
texSize.Height = (s32)ceil((f32)texSize.Height * sizeMode);
IImage * ImageTmp = new CImage(image->getColorFormat(), texSize);
image->copyToScaling(ImageTmp);
texture = createDeviceDependentTexture(ImageTmp, hashName ? hashName : file->getFileName() );
os::Printer::log("Loaded texture", file->getFileName());
image->drop();
ImageTmp->drop();
}
}
driver->setTextureSizeSupport(video::IRR_TEX_MEDIUM);
Tiny Support is about 10th the size of the texture

Medium is 1/2 the size

You can change the Texture Size Support at any time before loading textures. You could easly setup options for characters to have their own texture size settings and enviroment, FX, etc.
It's been tested against the latest SVN and on OSX, Linux and Windows
Course this does the change at load time, you could how ever save it back to disc, so next time it wouldn't have to load up the entire texture.
Thx
V

