transparency with png (alpha)

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
Shomaa
Posts: 15
Joined: Sat Mar 14, 2009 2:28 pm
Location: {Epitech.} Kremlin-Bicetre

transparency with png (alpha)

Post by Shomaa »

Hello,

i'm working on a small game project with several images, but I don't know how to resolve my problem.
On the tutorial with the 2D images, the format png is supported.
but my images in png displays a ugly color black instead of the background (a sort of gradient blue...)
Image
same with the TGA format or png 8-bits 24 bits or 32 bits ...
Image
why ? i dont understand...
Please help...
--
Shomaa
zerochen
Posts: 273
Joined: Wed Jan 07, 2009 1:17 am
Location: Germany

Re: transparency with png (alpha)

Post by zerochen »

hi,

http://irrlicht.sourceforge.net/docu/cl ... e526bbcdb3

did you set the last param to true? -> useAlphaChannelOfTexture
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Re: transparency with png (alpha)

Post by hybrid »

If that was not the case, you should probably post some code. That makes it much simpler for us to find the answer.
pyandrea
Posts: 11
Joined: Sun Jul 13, 2014 7:01 pm

Re: transparency with png (alpha)

Post by pyandrea »

zerochen wrote:hi,

http://irrlicht.sourceforge.net/docu/cl ... e526bbcdb3

did you set the last param to true? -> useAlphaChannelOfTexture
It worked for me! I had the same problem (pngs showing the Alpha channel as a solid color) and I solved it by simply changing the last parameter to true.

For instance, after that an image is 'loaded' (example code below)...

Code: Select all

video::ITexture* image = driver->getTexture("../../media/image.png");
...the loaded image is displayed with its original Alpha channel by setting the last parameter to true (example code below, intended to be used in the main drawing loop):

Code: Select all

driver->draw2DImage(image, core::position2d<s32>(100, 0), core::rect<s32>(0, 0, 100, 100), 0, SColor(255, 255, 255, 255), true);
Post Reply