Advertisement

Load PNG

Started by July 19, 2004 01:09 PM
7 comments, last by meganuke 20 years, 4 months ago
Can anyone tell me how to load png files and keep te Alpha channel, i need it for sprites which have partialy transparent parts!! And say i render these transparent images does the order i do it in matter at all!! I mean wont it blend the same?
----------------------------

http://djoubert.co.uk
If you do your alpha blending by using the alpha test (glEnable(GL_ALPHA_TEST);), there's no need to do depth-peeling. But you will need some kind of sorting algo if you're trying to implement it by using some sort of OpenGL blending function (glEnable(GL_BLEND);).

For your question, how to load .png images, I do not have an answer right now. Check google.com for some free PNG loading libraries or tutorials. You can also goto www.wotsit.org so check out if there's some kind of file format specification for the PNG image format, available.

Good luck,
Flo
Advertisement
There's libPNG, which is an Open-Sourced PNG library.
i´ve been using glpng to get png with alpha loaded, get it from here
http://www.wyatt100.freeserve.co.uk/download.htm
it´s dead simple to use, just check the sample game that comes with the source.

jens.
so what ur saying is if i leave depth testing on it deosnt matter
----------------------------

http://djoubert.co.uk
It's not that difficult to write a PNG loader. Handling the huffman trees is the toughest part. I believe I have a partial implementation of a PNG loader in my LOTR TTT entry. If I remember correctly it can load RGB8 and RGBA8 formats but isn't implemented to load other formats. Feel free to nab it if you want.

As to what ZMaster was saying, I don't think it applies to your situation because you want partial transparency.

Enigma
Advertisement
where can i nab this partial implementation
----------------------------

http://djoubert.co.uk
It's under the LOTR TTT contest link on the NeHe main page, but I'll give you a direct link to make things easier for you [smile]. You'll have to seperate out the relevant clases yourself.

Enigma
libpng doc is a nightmare, you spend hours and hours
reading how how to compress, uncompress pixels, how to invert channels, how to make coffe, and etc.
but you never see the day you are going to read "how to make a f***ing simple load of a png file"
i dont know you, but the only thing i want to do with a png file, is to load it.

right now im using glpng, wich is best suited for game programmers (in my opinion)
http://www.wyatt100.freeserve.co.uk/download.htm

believe me: it cannot be more simple

greets!
Aquellos que crean que algo es imposible no deben ponerse en el camino de los que estan dispuestos a intentarlo.MEGANUKE

This topic is closed to new replies.

Advertisement