Re: [fpc-pascal] Loading PNG files as OpenGL textures

2015-10-16 Thread Felipe Monteiro de Carvalho
On Fri, Oct 16, 2015 at 3:19 AM, Ryan Joseph wrote: > Are any of these FPImage classes documented or should I just try to dig > around the FPC sources to > find these things? There are dozens of classes available at > http://wiki.freepascal.org/fcl-image but I > don’t know what any of them do.

Re: [fpc-pascal] Loading PNG files as OpenGL textures

2015-10-16 Thread Ryan Joseph
> On Oct 15, 2015, at 4:38 PM, Mattias Gaertner > wrote: > > Actually it works like TFPMemoryImage and descends from > TFPCustomImage. The only difference is that it uses 4*8=32bit per pixel > instead of 4*16bit. Are any of these FPImage classes documented or should I just try to dig around t

Re: [fpc-pascal] Loading PNG files as OpenGL textures

2015-10-15 Thread Mattias Gaertner
On Thu, 15 Oct 2015 15:30:41 +0700 Ryan Joseph wrote: > > > On Oct 14, 2015, at 1:49 PM, Michael Van Canneyt > > wrote: > > > > Type > > TMyImage = Class(TFPCompactImgRGBA8Bit) > > Public > > property Data : PFPCompactImgRGBA8BitValue read FData; > > end; > > > > > > Should do it. Or if y

Re: [fpc-pascal] Loading PNG files as OpenGL textures

2015-10-15 Thread Ryan Joseph
> On Oct 14, 2015, at 1:49 PM, Michael Van Canneyt > wrote: > > Type > TMyImage = Class(TFPCompactImgRGBA8Bit) > Public > property Data : PFPCompactImgRGBA8BitValue read FData; > end; > > > Should do it. Or if you don't need Alpha: > > TMyImage = Class(TFPCompactImgRGB8Bit) > Public > pro

Re: [fpc-pascal] Loading PNG files as OpenGL textures

2015-10-15 Thread Ryan Joseph
> On Oct 14, 2015, at 4:59 PM, Graeme Geldenhuys > wrote: > > I assume it should work. I guess there is only one way to found out. ;-) Yes it did work which is nice. I didn’t do any speed tests yet but from what I read this unit is faster than FPImage and it's easier to implement also, being

Re: [fpc-pascal] Loading PNG files as OpenGL textures

2015-10-14 Thread Graeme Geldenhuys
Hello Ryan, On 2015-10-14 at 08:54, Ryan Joseph wrote: > According to Reimar’s code the raw image data is sufficient for > glTexImage2D so I wonder if the data pointer returned from BeRoPNG > would work also? I assume it should work. I guess there is only one way to found out. ;-) Regards,

Re: [fpc-pascal] Loading PNG files as OpenGL textures

2015-10-14 Thread Graeme Geldenhuys
Hello Michael, On 2015-10-14 at 08:49, Michael Van Canneyt wrote: > You could throw in a property to get a direct pointer to a scanline. > I should maybe add that to the base classes... +1 fpGUI's Image class has both ImageData and ScanLine[] properties, and they are very useful for fast access

Re: [fpc-pascal] Loading PNG files as OpenGL textures

2015-10-13 Thread Michael Van Canneyt
On Wed, 14 Oct 2015, Michael Van Canneyt wrote: On Wed, 14 Oct 2015, Ryan Joseph wrote: On Oct 12, 2015, at 2:25 PM, Michael Van Canneyt wrote: TFPCustomImage is an abstract image class, it provides no storage for the data. It can have several descendants such as TFPMemoryImage and

Re: [fpc-pascal] Loading PNG files as OpenGL textures

2015-10-13 Thread Michael Van Canneyt
On Wed, 14 Oct 2015, Ryan Joseph wrote: On Oct 12, 2015, at 2:25 PM, Michael Van Canneyt wrote: TFPCustomImage is an abstract image class, it provides no storage for the data. It can have several descendants such as TFPMemoryImage and TFPCompactImgRGBA8Bit. If you just want the raw data,

Re: [fpc-pascal] Loading PNG files as OpenGL textures

2015-10-13 Thread Michael Van Canneyt
On Wed, 14 Oct 2015, Ryan Joseph wrote: On Oct 12, 2015, at 8:39 PM, Reimar Grabowski wrote: http://sourceforge.net/p/asmoday/code/HEAD/tree/trunk/asmtypes.pas#l203 Not an example but a straightforward texture class implementation based on TFPCustomImage. Should work as is for bmp, jpg,

Re: [fpc-pascal] Loading PNG files as OpenGL textures

2015-10-13 Thread Ryan Joseph
> On Oct 12, 2015, at 8:39 PM, Reimar Grabowski wrote: > > http://sourceforge.net/p/asmoday/code/HEAD/tree/trunk/asmtypes.pas#l203 > > Not an example but a straightforward texture class implementation based on > TFPCustomImage. Should work as is for bmp, jpg, png, tga, xpm, if not drop me > a

Re: [fpc-pascal] Loading PNG files as OpenGL textures

2015-10-13 Thread Ryan Joseph
> On Oct 12, 2015, at 2:25 PM, Michael Van Canneyt > wrote: > > TFPCustomImage is an abstract image class, it provides no storage for the > data. It can have several descendants such as TFPMemoryImage and > TFPCompactImgRGBA8Bit. > If you just want the raw data, create a TFPMemoryImage and ac

Re: [fpc-pascal] Loading PNG files as OpenGL textures

2015-10-13 Thread Ryan Joseph
> On Oct 12, 2015, at 5:52 PM, Graeme Geldenhuys > wrote: > > http://members.upc.nl/h.speksnijder4/software/fpGUI/pngloader.html Thanks for the links. BeRoPNG seems to load a PNG and the author states it’s fast and has no external dependancies. Fantastic. According to Reimar’s code the raw

Re: [fpc-pascal] Loading PNG files as OpenGL textures

2015-10-12 Thread Reimar Grabowski
On Sun, 11 Oct 2015 16:36:56 +0700 Ryan Joseph wrote: > is there any more complete examples I could look at? http://sourceforge.net/p/asmoday/code/HEAD/tree/trunk/asmtypes.pas#l203 Not an example but a straightforward texture class implementation based on TFPCustomImage. Should work as is for

Re: [fpc-pascal] Loading PNG files as OpenGL textures

2015-10-12 Thread Graeme Geldenhuys
On 2015-10-12 08:26, Anthony Walter wrote: > The OS imaging libs are orders of magnitudes faster than TFPImage, > especially when it comes to loading 100s of textures during the start > of a demo or game. Indeed, FPImage is not very fast... This was also extensively proven and compared against man

Re: [fpc-pascal] Loading PNG files as OpenGL textures

2015-10-12 Thread Graeme Geldenhuys
On 2015-10-12 01:21, Ryan Joseph wrote: > But can I then access the pixel data so I can hand it to glTexImage2D and > make the texture? Yes, look at line 61. Simply use the Colors[] array property. The code I suggested was not meant as a complete implementation for you, but as an example of how

Re: [fpc-pascal] Loading PNG files as OpenGL textures

2015-10-12 Thread Michael Van Canneyt
On Mon, 12 Oct 2015, Anthony Walter wrote: Michael, I've written a whole lot of OpenGL demos (demoscene) using both C and Pascal. I can tell you there is a huge difference between the Delphi image decompression performance and the performance of the image libs ones provided by the OS (WIC and

Re: [fpc-pascal] Loading PNG files as OpenGL textures

2015-10-12 Thread Anthony Walter
Michael, I've written a whole lot of OpenGL demos (demoscene) using both C and Pascal. I can tell you there is a huge difference between the Delphi image decompression performance and the performance of the image libs ones provided by the OS (WIC and Quartz especially). The OS imaging libs are ord

Re: [fpc-pascal] Loading PNG files as OpenGL textures

2015-10-12 Thread Michael Van Canneyt
On Sun, 11 Oct 2015, Ryan Joseph wrote: On Oct 11, 2015, at 1:53 PM, Michael Van Canneyt wrote: You can use the fpimage and fpreadpng units. Check the packages/fcl-image sources. There is a small demo program that shows how to do it. I see you can load an image as TFPCustomImage with TF

Re: [fpc-pascal] Loading PNG files as OpenGL textures

2015-10-12 Thread Anthony Walter
Michae ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Loading PNG files as OpenGL textures

2015-10-12 Thread Anthony Walter
I would abstract all platform specific code. I define a encapsulating set of interfaces for any platform specific stuff. Interface types also provide a nice layer of abstraction. In such a way I have at least IDocument, IBitmap, IAudio, and IVideo; where the last three type define methods for load

Re: [fpc-pascal] Loading PNG files as OpenGL textures

2015-10-11 Thread Michael Van Canneyt
On Sun, 11 Oct 2015, Anthony Walter wrote: I tend to use OS core elements or well known open source libraries for a few reasons. 1) less code compiled and small programs 2) superior performance 3) more features 1. is not true for image code if you're using lazarus. The code will already be

Re: [fpc-pascal] Loading PNG files as OpenGL textures

2015-10-11 Thread Ryan Joseph
> On Oct 12, 2015, at 10:57 AM, Anthony Walter wrote: > > I tend to use OS core elements or well known open source libraries for a few > reasons. > > 1) less code compiled and small programs > 2) superior performance > 3) more features > > Example: When loading hundreds of textures you bet th

Re: [fpc-pascal] Loading PNG files as OpenGL textures

2015-10-11 Thread Anthony Walter
I tend to use OS core elements or well known open source libraries for a few reasons. 1) less code compiled and small programs 2) superior performance 3) more features Example: When loading hundreds of textures you bet the Apple Quartz graphics libs are faster and more reliable. Same goes to WIC

Re: [fpc-pascal] Loading PNG files as OpenGL textures

2015-10-11 Thread Ryan Joseph
> On Oct 12, 2015, at 9:47 AM, Anthony Walter wrote: > > Okay, I looked at my Darwin sources which use minimal wrappers around the > inbuilt Quartz classes to handle image loading, saving, and pixel data access. > I have a good working implementation of loading OpenGL textures on Mac but I

Re: [fpc-pascal] Loading PNG files as OpenGL textures

2015-10-11 Thread Anthony Walter
Okay, I looked at my Darwin sources which use minimal wrappers around the inbuilt Quartz classes to handle image loading, saving, and pixel data access. To load any image (png, jpg, bmp, gif, ect) you use a CGImageSourceRef object. >From file: ImageSource := CGImageSourceCreateWithURL(UrlRefCrea

Re: [fpc-pascal] Loading PNG files as OpenGL textures

2015-10-11 Thread Ryan Joseph
> On Oct 12, 2015, at 3:46 AM, Anthony Walter wrote: > > You can write an interface to the quartz libs and have them load or save a > variety of image formats such as bmp, jpg, gif, and png. I've done this with > OpenGL on OSX with Free Pascal and I look for the code and post it to git > some

Re: [fpc-pascal] Loading PNG files as OpenGL textures

2015-10-11 Thread Ryan Joseph
> On Oct 11, 2015, at 10:45 PM, Graeme Geldenhuys > wrote: > > As Michael mentioned, fpimage and fpreadpng can do this. Here is how I > use it to populate fpGUI's TfpgImage class with image data. > > https://github.com/graemeg/fpGUI/blob/develop/src/corelib/fpg_imgfmt_png.pas But can I then a

Re: [fpc-pascal] Loading PNG files as OpenGL textures

2015-10-11 Thread Anthony Walter
You can write an interface to the quartz libs and have them load or save a variety of image formats such as bmp, jpg, gif, and png. I've done this with OpenGL on OSX with Free Pascal and I look for the code and post it to git sometime, maybe even Today. http://codebot.org/baregame/ ___

Re: [fpc-pascal] Loading PNG files as OpenGL textures

2015-10-11 Thread Graeme Geldenhuys
On 2015-10-11 05:29, Ryan Joseph wrote: > Does the FPC RTL contain any units for loading PNG files as bitmaps As Michael mentioned, fpimage and fpreadpng can do this. Here is how I use it to populate fpGUI's TfpgImage class with image data. https://github.com/graemeg/fpGUI/blob/develop/src/coreli

Re: [fpc-pascal] Loading PNG files as OpenGL textures

2015-10-11 Thread Ryan Joseph
> On Oct 11, 2015, at 1:53 PM, Michael Van Canneyt > wrote: > > You can use the fpimage and fpreadpng units. Check the packages/fcl-image > sources. There is a small demo program that shows how to do it. I see you can load an image as TFPCustomImage with TFPCustomImageReader then there is a

Re: [fpc-pascal] Loading PNG files as OpenGL textures

2015-10-10 Thread Michael Van Canneyt
On Sun, 11 Oct 2015, Ryan Joseph wrote: I’m coming from the Mac and I’d like to replace some code that loads .png files into OpenGL textures using Apple libraries that aren’t cross platform compatible. Does the FPC RTL contain any units for loading PNG files as bitmaps that I could extract