png's flipped vertically

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

png's flipped vertically

Mike
I just upgraded from jogl2.0-rc5 to rc9, and now all the textures that i load from .png's render flipped vertically. I use the TextureIO.newTexture(URL, boolean, String), method to load my textures. Were there some changes to the TextureIO class that i need to take in to account?

Thanks,
Mike
Reply | Threaded
Open this post in threaded view
|

Re: png's flipped vertically

Pixelapp
Yeah, I that happens to me too. I just didn't mind.

My textures on android are okay, but in Desktop are flipped. Don't know why.

Maybe someone knows?
Reply | Threaded
Open this post in threaded view
|

Re: png's flipped vertically

Mike
I did a little digging, and it turns out that the textures drawing upside down were returning 'true' for the method Texture.getMustFlipVertically(). So my solution is to check if the Texture objects need to be flipped and manually flip them before rendering.

Is there maybe a better solution than this? Why do the textures get loaded in upside down in the first place?

Thanks,
Mike
Reply | Threaded
Open this post in threaded view
|

Re: png's flipped vertically

Sven Gothel
Administrator
On 07/07/2012 05:28 AM, Mike [via jogamp] wrote:
> I did a little digging, and it turns out that the textures drawing upside down
> were returning 'true' for the method Texture.getMustFlipVertically(). So my
> solution is to check if the Texture objects need to be flipped and manually
> flip them before rendering.

Either you use the provided texture coordinates by Texture object,
or you swap the Y-axis in your tex-coords yourself.

<http://jogamp.org/deployment/jogamp-next/javadoc/jogl/javadoc/com/jogamp/opengl/util/texture/Texture.html#getImageTexCoords%28%29>

Now we use PNGJ <http://code.google.com/p/pngj/> for PNG texture loading,
which is AWT independent and pretty much more efficient.

> Is there maybe a better solution than this? Why do the textures get loaded in
> upside down in the first place?

Since it's much faster to flip a texture using it's texcoords than
swapping the memory content - this is the best solution.

~Sven


signature.asc (910 bytes) Download Attachment