From: Ilmari Heikkinen Date: 2006-05-30T07:27:47+09:00 Subject: Re: PNG to OpenGL Texture (libpng) Hi, On 5/29/06, Xavier wrote:> Hi,> I'm trying to load a PNG file into an OpenGL texture using> ruby-libpng-0.3.3> I can't quite figure out how to convert libpng data to the correct> format.> I've dumped png.read_image to screen and it looks like my picture (with> numbers instead of colors). At the moment I'm trying to use this index> as my Red index (just to get something displaying) but am getting a> white square instead. I'm already using textures for fonts, so I know> that bit works.>> Any Ideas?>> As an aside, if anyone has a better x-platform way of doing this I'm all> ears...>> - Xavier With RMagick you can load image data in asuitable format for gl textures like this(dunno if there's a better way): require 'RMagick' image = RMagick::Image.read(filename).firstrgba_data = image.to_blob{|i| i.format = "RGBA" i.depth = 8} And with Imlib2: require 'imlib2' image = Imlib2::Image.load(filename)data = image.data # IIRC the channel order depends on system endianness here No idea about libpng, sorry :I HTH,Ilmari