Programming => Graphics and Multimedia => Graphics => Topic started by: Agent_AL on April 21, 2008, 12:50:04 pm

Title: PNG Alpha in GLScene?
Post by: Agent_AL on April 21, 2008, 12:50:04 pm
Somehow I cannot get alpha channel working with any material settings. I load png file as texture using ~Material.Texture.Image.LoadFromFile(path).
In result I get png file displayed on surface but as 24 bit texture. Completely transparent areas are white and half transparent are black. Same code and material setup works fine in Delphi and blends png alpha properly. Loading texture in object inspector makes the same result: no alpha.
By the way, I tried to pull the same with 32 bit ico and there were no alpha too. Does GLScene for Lazarus support textures with alpha? TGA from GLScene package doesn't work - I've seen many lines commented out with scanline calls. Tried imagesforlazarus unit but without any progress: TGA read functions return black bitmap.
What should I do?
Title: PNG Alpha in GLScene?
Post by: Agent_AL on April 22, 2008, 03:13:09 am
I guess I found it.  :shock:
File: GLGraphics.pas in Glscene 635:1
Code: [Select]
pDest^ := $ff{pixel.alpha shr 8}; inc(pDest);
Why alpha data append line is commented out?
I changed it to
Code: [Select]
pDest^ := pixel.alpha shr 8; inc(pDest);
and tested with 24 and 32 bit raster bitmap files. Png now works fine too.
Srsly, this single line gave me two days of instant hell.  :evil:
Title: Re: PNG Alpha in GLScene?
Post by: crossbuilder on January 14, 2009, 07:36:22 pm
Not sure, but probably because it's in AssignFrom24BitBitmap and the initial porter (don't know who did this part, not me) expected a 24-bit image to not have any alpha channel...
However, as AssignFrom24BitBitmap is used for bitmaps of all pixelformats in lazarus, it should offcourse respect the alpha .. I fixed that in svn rev. 2275.
Btw. bug reports and patches are best placed in mantis (  Project "Packages"  Category "glscene" )

TinyPortal © 2005-2018