When i load an image via FreeImage, the bits are bottom to top. My GL code expects all images to be topdown. Whats the best way to flip the image when i copy the bits to the texture?
+1
A:
I think it's wise to do an in-place flip using simple array arithmetic and 1 temporary longword value. (so flip per pixel, 4 bytes).
You could of course flip texture coords but that would be unwise IMHO, as you probably don't want to pollute your code with the info that the texture is upside down.
Frans Bouma
2009-01-14 17:10:37
+1
A:
You could use the texture matrix to effectively flip texcoords. I think this would work:
glMatrixMode(GL_TEXTURE);
glLoadIdentity();
glScalef(1.0, -1.0, 1.0);
glMatrixMode(GL_MODELVIEW);
Drew Hall
2009-01-15 02:45:58
Isn't that a bad choice? I mean: you'll embed an aspect of a texture in the code, so when the texture data is supplied correctly, your code all of a sudden doesn't work anymore .
Frans Bouma
2009-01-15 08:32:52
Drew Hall
2009-01-15 15:45:46
Texture matrix is no longer in core OpenGL - having to constantly patch vertex shaders to flip texture coordinates is painful and certainly inefficient. Better consistenly flip once and for all the source geometry texture coordinates, or flip the texture at load time and be done.
rotoglup
2009-09-04 13:51:45