What is happening is I have got the restarting of the engine running fine, however, I have to scale the 2d GUI to the new resolution. I was given some code not too long ago, that scaled it for me, and have since.. I think... got my head around it, but there are still a few grey areas. The code itself, once you restarted the engine did not always work, and upon editing it, I find that every time I now restart the engine (by this I mean change resolution, press apply and it creates a new irrlicht window, in place of the old one) It gives me an error.
Here is my edited version:
Code: Select all
irr::video::ITexture* EngineElements::scaleTexture(irr::video::ITexture* SrcTexture, const irr::core::dimension2di& destSize, stringc image)
{
ITexture* IntTexture = 0;
stringc SrcName = image;
IntTexture = driver->getTexture((image += (stringc)destSize.Width += (stringc)"x" += (stringc)destSize.Height += (stringc)".png").c_str());
if(IntTexture != 0)return IntTexture;
IImage* SrcImage = 0;
IImage* DestImage = 0;
driver->setTextureCreationFlag(irr::video::ETCF_CREATE_MIP_MAPS, false);
try
{
IntTexture = driver->addTexture(destSize, "IntermediateTexture");
SrcImage = driver->createImageFromData(SrcTexture->getColorFormat(), SrcTexture->getSize(), SrcTexture->lock());
DestImage = driver->createImageFromData(SrcTexture->getColorFormat(), destSize, IntTexture->lock());
}
catch(...)
{
int temp = MessageBox(NULL, ((stringc)"Error in scaling image: " += image += (stringc)"\nThis can be caused by incorrect resolution settings.").c_str(),"Fatal Error",MB_OK | MB_ICONSTOP);
return NULL;
};
SrcTexture->unlock();
SrcImage->copyToScaling(DestImage);
IntTexture->unlock();
driver->writeImageToFile(DestImage,(SrcName += (stringc)destSize.Width += (stringc)"x" += (stringc)destSize.Height += (stringc)".png").c_str());
driver->removeTexture(IntTexture);
IntTexture = driver->addTexture(SrcName.c_str(), DestImage);
SrcImage->drop();
DestImage->drop();
driver->setTextureCreationFlag(irr::video::ETCF_CREATE_MIP_MAPS, true);
return IntTexture;
} Code: Select all
irr::video::ITexture* Game::scaleTexture(irr::video::ITexture* SrcTexture, const irr::core::dimension2di& destSize) const
{
static irr::u32 counter = 0;
irr::video::IImage* SrcImage = 0;
irr::video::IImage* DestImage = 0;
irr::video::ITexture* IntTexture = 0;
irr::core::stringc SrcName = "NewTexture";
SrcName += counter;
videoDriver->setTextureCreationFlag(irr::video::ETCF_CREATE_MIP_MAPS, false);
IntTexture = this->videoDriver->addTexture(destSize, "IntermediateTexture");
SrcImage = this->videoDriver->createImageFromData(SrcTexture->getColorFormat(), SrcTexture->getSize(), SrcTexture->lock());
DestImage = this->videoDriver->createImageFromData(SrcTexture->getColorFormat(), destSize, IntTexture->lock());
IntTexture->unlock();
SrcImage->copyToScaling(DestImage);
SrcTexture->unlock();
this->videoDriver->removeTexture(IntTexture);
IntTexture = this->videoDriver->addTexture(SrcName.c_str(), DestImage);
SrcImage->drop();
DestImage->drop();
videoDriver->setTextureCreationFlag(irr::video::ETCF_CREATE_MIP_MAPS, true);
++counter;
return IntTexture;
} Code: Select all
DestImage = driver->createImageFromData(SrcTexture->getColorFormat(), destSize, IntTexture->lock()); Code: Select all
createImage(ECF_A8R8G8B8, destSize)Also, yes it does produce a file name in this format: AMIBackground2.png800x600.png