texture coordinates

Started by
1 comment, last by GameDev.net 17 years, 2 months ago
The various websites I read describe the texture coordinates (u, v) such that v increases from 0 to 1, where 0 is the _bottom_ of the texture, and 1 is the _top_ of the texture. When I try this with my own texture I observed the opposite behavior. Perhaps it is because I specify my texture data to glTexImage2D() in row-major form, starting with the topmost row of the image, to the bottom-most. Is everyone else passing data to glTexImage2D in the opposite order? (bottom to top)? And if so why, since most image formats save their data from the top to bottom. thx.
Advertisement
If you are consistent in how you specify your texture data and texture coordinates, it doesn't matter how you do it. If that way works for you, then that's good.

Personally, all my texture loading code loads the image bottom up (reversing direction while loading if needed), since that is consistent with the rest of the API. Every default coordinate system in OpenGL got it's origin in the lower left corner, including textures and texture coordinates. Therefore, I choose to follow the API and use the default origin.

I don't know your definition of "most" when you say most formats store the data top down, but some commonly used formats store them bottom up aswell; BMP for example, and TGA can store in both directions (according to a bit in the header). Since they are easy to make custom parses for, they are commonly used. And since they store the data in default order for OpenGL, it's a double score for those formats.
That's like saying why do some formats specify RGB and some specify BGR?
They just do. Origin of texture coordinates is API-specific. Do not make assumptions.

"Assumption is the mother of all f**kups." :)

This topic is closed to new replies.

Advertisement