Recent

Author Topic: PNG Alpha in GLScene?  (Read 9963 times)

Agent_AL

  • Newbie
  • Posts: 6
PNG Alpha in GLScene?
« 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?

Agent_AL

  • Newbie
  • Posts: 6
PNG Alpha in GLScene?
« Reply #1 on: April 22, 2008, 03:13:09 am »
I guess I found it.  :shock:
File: GLGraphics.pas in Glscene 1.0.0.2 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:

crossbuilder

  • New member
  • *
  • Posts: 7
Re: PNG Alpha in GLScene?
« Reply #2 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 ( http://bugs.freepascal.org  Project "Packages"  Category "glscene" )

I'm here only once a year!
About GLScene4Lazarus: http://wiki.freepascal.org/GLScene
Please report GLScene bugs in mantis! ( http://wiki.freepascal.org/GLScene#Bug_reporting )
Contact: The #glscene IRC channel on irc.freenode.net (If I'm offline, I'll read the chat log)

 

TinyPortal © 2005-2018