[fpc-pascal] Loading PNG files as OpenGL textures

Michael Van Canneyt michael at freepascal.org
Wed Oct 14 08:44:34 CEST 2015



On Wed, 14 Oct 2015, Ryan Joseph wrote:

>
>> On Oct 12, 2015, at 8:39 PM, Reimar Grabowski <reimgrab at web.de> 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 line.
>
> Thanks, this is really helpful.
>
> I see how you populated TFPCustomImage and generated “Data” to store the color values.
>
> Is it necessary to build an entire subclass or can I just use
> TFPMemoryImage to achieve the same effect?  I understand now
> TFPCustomImage is an abstract class but TFPMemoryImage apparently has
> stored values so I should be able to access the “Data” property but these
> seem to be accessors to getting single pixel values so I can’t just pass
> the entire block into glTexImage2D like you did.

If you need access to the actual memory block, then you must create another subclass of TFPCustomImage.
TFPMemoryImage stores rgba in 4 word values which is the 'maximum' storage allowed by the API. 
There are other subclasses with more common formats, see my other mail.

Michael.


More information about the fpc-pascal mailing list