2d Buttons

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
LordNyson
Posts: 31
Joined: Tue Nov 11, 2008 12:02 pm
Location: Perth, Australia

2d Buttons

Post by LordNyson »

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...
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

Post by randomMesh »

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..."
LordNyson
Posts: 31
Joined: Tue Nov 11, 2008 12:02 pm
Location: Perth, Australia

Post by LordNyson »

That isn't a irrlicht function is it?
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

Post by randomMesh »

LordNyson wrote:That isn't a irrlicht function is it?
This is a method using Irrlicht API.
"Whoops..."
LordNyson
Posts: 31
Joined: Tue Nov 11, 2008 12:02 pm
Location: Perth, Australia

Post by LordNyson »

Works a charm, thanks mate.
But the cage only had "Warning: Vicious Lions" on it! Im a programmer! I only listen to errors!
Post Reply