upside down textures in opengl

Hello.
In NeHe tutorial it is said to match corners of the texture to corners of the quad. When I do it like that texture appears upside down (picture rotated 180deg on x axis). After some time experimenting, guys at #lwjgl told me that is normal in opengl. So is tutorial wrong then? Outdated?

Another thing… since picture is upside down, how do you handle that, what is best? I can think of 3 options, first one is to create a fliped images and use it instead. Second one is to flip the image on loading time. Third is to work with that upside-down coordinates. Any experience you want to share :slight_smile: ?
Thank you.

Fourth is to flip your projection-matrix for rendering in 2D mode. Then you get Java2D like coordinates again which you just might prefer for some reason.

Second option is kinda bad, because any models you load (with attached textures) will not have their textures flipped, because that was taken into account while modelling with UVs.

[quote=“Kova,post:1,topic:29593”]
No, it’s neither wrong nor outdated. The BMP format, which the early NeHe texturing tutorials use, (usually) has the origin of the image in the lower left corner. This matches the default OpenGL texture coordinate system so the images do not need to be flipped. Some image file formats specify the top left corner as the origin, others allow it to be either/or. The BMP format actually lets you specify the (x,y) coordinates of the origin as part of the header relative to (0,0) being the lower left corner.

It’s not that I prefer Java2D coordinates, it’s that coordinates of the image are upside-down comparing to opengl coordinates. Anyway, don’t know if it matters, but I’m doing in 3D.

I’m using identical images, downloaded with source for LWJGL, .BMPs also. Just tried with PNGs, same thing.

I suspect the image loader code in the tutorial is just different compared to the imageio (or the loader you use) coordinate handling. I would use the texture coordinate option, since it is the fastest.

um, and what option is that? I don’t know what do you mean. :slight_smile:

:slight_smile: