View Full Version : PNG/TGA Transparency in GLScene + Lazarus
26-02-2010, 04:53 PM
I've just started to port Dage from Delphi into Lazarus and 99% of everything worked off the box in Ubuntu 9.10.
Only thing that really bugs me now is PNG and TGA transparency in THudSprite objects, and probably in meshobjects too. I use GraphicEx library for Delphi version and everything works as charmed. Is there a GraphicEx lib for Lazarus somewhere? Coulnd't find anything but dead links.
I have the latest Lazarus, FPC and GLScene from SVN repository.
27-02-2010, 09:45 AM
I made a small test program that doesn't work for me.
Download zip file here (http://rahakasvi.hinguere.fi/Dage/lazarus-pngtest.zip)
27-02-2010, 10:06 AM
You could use Vampyre Image lib instead (It's FPC compatible and supports loads of image formats). :)
I have no experience with GLScene and GraphicEx (I might have tried it, but i can't recall). So I can't really help you with these.
27-02-2010, 10:13 AM
A little stray off the subject - from what I heard, GraphicEx is not the best choice. I read somewhere that it's unstable and tends to be a "memory-leak maker".
I'd suggest Vampire Lib (http://imaginglib.sourceforge.net/), too. :) It is OpenGL-compatible, cross-platform (even MacOS is supported!) and, just like chronozphere said, compiles in FPC and Lazarus.
I used to work with GLScene, but I've never tried Vampire Lib with it. I guess you will have to do some tweaks here and there to make it work.
27-02-2010, 11:02 AM
Thanks for a tip! I'll try Vampire and post the results here soon.
27-02-2010, 01:11 PM
Ugh.. Okay the Vampyre builds and compiles fine. The demos work etc. But I can't seem to tell GLScene to load those PNGs with Vampyre instead of Lazarus Graphics. Any ideas?
27-02-2010, 02:09 PM
I can't really help because I don't know how GLScene loads it's images. You should try loading "some" image with Vampyre ImageLib, so that you have all it's pixels in memory. Now you need to look for a way to import raw pixel data into GLScene. Once you found this, you can make a routine to convert an ImageLib image to a GLScene texture. :)
27-02-2010, 05:49 PM
AFAIK, GraphicEx registers the image format somehow so that it is supported by Delphi and thus can be loaded to a TImage. Maybe you should check how it's done and use VampireLib instead?
27-02-2010, 08:26 PM
Ok, I got it working in the small testunit :)
But not yet with Dage.
The problem is probably the usage of GLVfsPAK. It requires ApplicationFileIO and because of it, GLScene does some kind of "hack" to TPicture file format list. This causes AV.
I hope the newsgroups for glscene comes online soon...
27-02-2010, 08:32 PM
I think that GLVfsPack has nothing to do with pictures- it's just a unit which provides support for Quake packages.
27-02-2010, 09:03 PM
It has. It replaces the LoadFromStream functions, I think.
There is at GLTexture.pas in procedure TGLPersistentImage.LoadFromFile(const fileName: string);
if ApplicationFileIODefined then
gr := CreateGraphicFromFile(buf);
if Assigned(gr) then
Picture.Graphic := gr;
else if FileExists(buf) then
And if you create TGLVfsPAk, it creates the ApplicationIO
28-02-2010, 11:26 AM
I managed to got it working somehow ;)
Here is a bug tracker ticket (http://sourceforge.net/tracker/?func=detail&aid=2960377&group_id=29749&atid=397251)
It works now with TGLVfsPak also. Thanks for help.
Powered by vBulletin® Version 4.1.10 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.