[fpc-pascal] Loading PNG files as OpenGL textures

Ryan Joseph ryan at thealchemistguild.com
Mon Oct 12 02:25:26 CEST 2015


> On Oct 12, 2015, at 3:46 AM, Anthony Walter <sysrpl at gmail.com> 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 sometime, maybe even Today.
> 

This is what I do on Mac but I wanted to make some cross platform code so I need to kill lots of this Apple stuff.

Basically I loaded the image from file, made a CGImage wrapper to it (which understands PNG) and then draw it into a CGContext (like a bitmap canvas) then extracted the pixel data from the bitmap for use with glTexImage2D.

The FPC RTL on http://wiki.freepascal.org/fcl-image seems to do this but I don’t see the interface for TFPCustomCanvas so I don’t know if it’s possible to access the pixel data. 

There’s code at http://www.sulaco.co.za/opengl_project_BMP_JPG_TGA_texture_loader.htm which follows a similar procedure but it’s Delphi and I couldn’t get it to run on FPC on my anyways.


Regards,
	Ryan Joseph




More information about the fpc-pascal mailing list