hi guys,
Im new to lwjgl and have been havin problems loading in png’s. I have tryed using slick and a pngdecoder(think it was called fastpng) but they both had the same outcome. The displayed texture wasnt correct as it changed all of the colors from the original png to greenish shades.
Do you know why this might be happening? have been using 256 png8s for these tests.
What i want to do is load pngs of size 256 or 512 idealy greater than png8 so i can have more use of transparency and not just clear or not(hope ive phased that well enough)
Do you know of a good way of doing this or just for png8s? or do you know of any good librarys that will take care of this for me?
Do you mean when its loaded in its not in rgba format?
what would be the best way to fix this?
cheers
edit:
done some tests and the first number of every pixal is wrong in the buffer e.g put red corner on pic so the first pixal should of been 186,44,38,0 but when i looked it was read in as -70,44,38,-1 the alpha being -1 i dont think is a problem but the red number is 256 off.
Has anyone else experienced this problem with fastpng lib? or could offer a solution to this?
There is also a simple working example on using the slick-util library here. It shows you how to load an image and you should try it to see if the problem is with the library or your code.
Keep in mind that it’s loading unsigned byte data into a signed byte (since Java can’t do unsigned). When you make the opengl texture calls, you correctly say UNSIGNED_BYTE, it’s only that printing it in Java is incorrect. To see the unsigned value, do:
Cheers, cleared that up, did what you said and yeah comes out right. So its not a problem with reading it in.
Tryed using this one but same outcome
Have already tryed this, followed tut but didnt work.
Have tryed messing around with my code abit but cannot get anything to work, still getting shades of green instead of colored texture.
Also tryed it on different comp and still had the same outcome.
this is the my code using lwjgl 2.7 and pngdecoder that Nate linked to afew posts up.
Im stuck and dont know what to try now. any help?
Would anyone be willing to give me an example of working code, just loading and displaying texture. so i can compare it with mine and so i can actually see it working. would be much appreciated.
Yeah, i went through that tutorial but had the same out come
edit:
Thanks kappa, last post got me to relook at that tutorial, found what i did wrong. Actually no idea y this line of code was ever in there but taken it out and its fixed.
this was the line: GL11.glColor3f(0.0f, 0.5f, 0.5f); very stupid mistake!
Cheers for the help guys but i was just being a noob
So… ran into another problem, textures flipped in y axis. just read that opengl stores textures backwards so that would explain it. What is the best way to flip the byte buffer before i load it into opengl as a texture?