Transparent Button Image

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
grumpymonkey
Posts: 222
Joined: Mon Jan 19, 2009 10:03 pm
Location: Miami, Florida
Contact:

Transparent Button Image

Post by grumpymonkey »

How do I set a transparent image on a button? Using IGUIButton::setImage()
I have a transparent PNG, but the transparent pixels are being replaced with the color black.
Image
rtr_18
Posts: 60
Joined: Thu Jun 10, 2010 8:35 am
Location: Programmer

Post by rtr_18 »

How do I set a transparent image on a button?
Did you try the following?

Code: Select all

button->setUseAlphaChannel(true);
This should work:

Code: Select all

 recti buttonRect = recti(100,170,228,202);
 IGUIButton* button = pManager->getGUIEnvironment()->addButton(buttonRect);
 button->setImage(pManager->getDriver()->getTexture("Your file path.png"));
 button->setUseAlphaChannel(true);
grumpymonkey
Posts: 222
Joined: Mon Jan 19, 2009 10:03 pm
Location: Miami, Florida
Contact:

Post by grumpymonkey »

the setUseAlphaChannel fixes the transparency, but it still shows the gray button box thing in the back. How do I make it so that it ONLY shows my image?
Image
no_response
Posts: 26
Joined: Fri Aug 20, 2010 11:07 am
Location: Bulgaria

Post by no_response »

also apply

Code: Select all

button->setDrawBorder(0);
grumpymonkey
Posts: 222
Joined: Mon Jan 19, 2009 10:03 pm
Location: Miami, Florida
Contact:

Post by grumpymonkey »

Thanks to both of you it works now!!
Image
Post Reply