Bit of a n00b question I suppose.
Basically I have a bunch of buttons on a main menu, and I have custom button image for each of them. However, due to how the program is set up, the res is changeable... is there any way to scale an image/texture? I had a look through the API but couldn't find a function for this specific problem. I have looked at plugging in an external library.. but thought I should ask on here first.. Just in case there is something I have overlooked somewhere...
2d Buttons
2d Buttons
But the cage only had "Warning: Vicious Lions" on it! Im a programmer! I only listen to errors!
-
randomMesh
- Posts: 1186
- Joined: Fri Dec 29, 2006 12:04 am
Re: 2d Buttons
Maybe this helps:
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;
}
"Whoops..."
-
randomMesh
- Posts: 1186
- Joined: Fri Dec 29, 2006 12:04 am