Java and OGL-textures - Why the need to flip img?

In all the code I’ve seen written in java for loading textures the image is flipped (byte-reversed?) before loading the BufferedImage’s data into the direct buffer.

Is this because of different byteorder in the array returned by the Raster and the byteorder preferred by OGL? In the C versions of the tutorials there seem to be no need for this conversion. It doesn’t seem to depend on imageformat. Chman’s ImageLib perform this operation on all images loaded, even from bmp-source.

I would be very happy if someone could explain exactly why this is necessary in the java code!

Kalle :slight_smile:

ps.
This post is a cross-post from the josrts.org forums.
ds.

That’s just the way it is, and it’s the same in C too. (0,0) is the bottom left coordinate; this means an image is loaded in so that it will appear upsidedown.

The image does not need flipping; you just need to flip your brain to accomodate. Adjust the texture coordinates appropriately.

Cas :slight_smile:

Ah, NOW I understand, that didn’t cross my mind. But I tell you, even after I read your answer I needed to draw some arrows using pen and paper to fully understand :slight_smile: I guess my brain isn’t gl-accelerated yet :wink:

Thanx! Kalle :slight_smile: