[HOpenGL] Textures from SDL upside down
sven.panne at aedion.de
Tue Mar 13 11:11:09 EDT 2007
On Tuesday 06 March 2007 00:25, Bas van Dijk wrote:
> I am using HOpenGL in combination with hsSDL
> (http://darcs.haskell.org/~lemmih/hsSDL). This works great except for
> texture loading. All my textures are mirrored over the v-axis. So the
> top of a texture becomes the bottom. I first thought that I got the
> texture coordinates wrong. But the textures are also flipped on the GLU
IIRC, in SDL the y-coordinate increases when going down the screen, while
OpenGL uses the usual mathematical convention of y increasing when going up.
Therefore your images are flipped, I guess.
> Is there some way to tell (H)OpenGL that a texture is mirrored? I tried
> glPixelStore parameters but I don't think it is possible that way.
> Perhaps it is possible to change a hsSDL surface before loading the
> pixel data. Any advice is welcome.
Usually the easiest and most efficient way is to simply flip your t texture
coordinate, i.e. use 1-t instead of t. Using pixelStore should be possible,
too (using negative offsets etc.), but often this is not really needed.
More information about the HOpenGL