[SOLVED] Transparency = grey?

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
Abraxas)
Posts: 227
Joined: Sun Oct 18, 2009 7:24 am

[SOLVED] Transparency = grey?

Post by Abraxas) »

I just did a half hour forum search and couldnt find an answer so...

Code: Select all

hardguibuttontex[SET_RALLY_POINT] = driver->getTexture("UI/Rally Pointer.BMP");
driver->makeColorKeyTexture(hardguibuttontex[SET_RALLY_POINT], position2d<s32>(0,0));
The black becomes translucent grey.

Could someone point me to a solution? thanks.
Last edited by Abraxas) on Tue Nov 10, 2009 3:23 pm, edited 1 time in total.
Desconocido
Posts: 9
Joined: Mon Aug 31, 2009 12:00 am

Post by Desconocido »

I could be wrong about this, as i'm too lazy to look it up to be sure. But I want to say .bmp file formats dont support transparency. Try saving as a .png or another format that does support transparency and see if that works.
Image
roelor
Posts: 240
Joined: Wed Aug 13, 2008 8:06 am

Post by roelor »

You want black to be transparancy?
Try these
SetTransparent(true);
SetTransparentColor(SColor(0,255,0,255),driver);
SetBilinearFilter(true);
(look in the 2dgraphics example for more)
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

Desconocido wrote:I want to say .bmp file formats dont support transparency.
that's why you make a color key texture, so you have transparency with bmp files... ;)


another problem could be the MipMap generation !!!
either you turn it off when loading the texture (usually done for GUI stuff):

Code: Select all

driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, false);
hardguibuttontex[SET_RALLY_POINT] = driver->getTexture("UI/Rally Pointer.BMP"); 
driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, true);
driver->makeColorKeyTexture(hardguibuttontex[SET_RALLY_POINT], position2d<s32>(0,0));
or you recalculate the mip maps:

Code: Select all

hardguibuttontex[SET_RALLY_POINT] = driver->getTexture("UI/Rally Pointer.BMP");
driver->makeColorKeyTexture(hardguibuttontex[SET_RALLY_POINT], position2d<s32>(0,0));
hardguibuttontex[SET_RALLY_POINT]->regenerateMipMapLevels();
but how do you use the texture afterwards, I do you use draw2DImage() or what ???
maybe the problem is there !?!?! ;)
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
Abraxas)
Posts: 227
Joined: Sun Oct 18, 2009 7:24 am

Post by Abraxas) »

Hang on this is what I'm doing:

Code: Select all

hardguibuttontex[SET_RALLY_POINT] = driver->getTexture("UI/Rally Pointer.BMP");
driver->makeColorKeyTexture(hardguibuttontex[SET_RALLY_POINT], position2d<s32>(0,0));
hardguibutton[SET_RALLY_POINT] = guienv->addButton(rect<s32>(10,100,50,140), hud[4],SET_RALLY_POINT);;
hardguibutton[SET_RALLY_POINT]->setImage(hardguibuttontex[SET_RALLY_POINT]);
hardguibutton[SET_RALLY_POINT]->setPressedImage(hardguibuttontex[SET_RALLY_POINT], rect<s32>(28,28,100,100));
without the colorkey set, the image is a white reticle on a black background. with that line, the black become transparent grey.

Maybe the gui is doing this?

EDIT: Acki, I tried the mipmap settings, no difference. I can post a screenshot if what I'm describing is vague.
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

aha !!! :lol:
well for buttons you'll have to set it to use the alpha channel, I think:

Code: Select all

hardguibutton[SET_RALLY_POINT]->setUseAlphaChannel(true);
also, are you sure the grey color you see is not the button itself ???
remember that the buttons have a grey color by default !!! ;)

and in general you should turn mip map generation off for gui stuff (can save lots of memory as mip maps are not needed for gui stuff) !!! ;)
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
Virion
Competition winner
Posts: 2149
Joined: Mon Dec 18, 2006 5:04 am

Post by Virion »

and also use

Code: Select all

yourButton->setDrawBorder(false);
to turn off the grey background. 8)
My company: https://kloena.com
My profile: https://zhieng.com
My co-working space: https://deskspace.info
My game engine: https://kemena3d.com
Abraxas)
Posts: 227
Joined: Sun Oct 18, 2009 7:24 am

Post by Abraxas) »

Virion let me know whenever you want a sexual favor
Post Reply