Re: Textures from SDL upside down
"Sebastian Sylvan" <[email protected]>
| Newsgroups | gmane.comp.lang.haskell.hopengl |
|---|---|
| Message-ID | <[email protected]> |
On 3/13/07, Sven Panne <[email protected]> wrote: > 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 > > quadrics. > > 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. Texture coordinates are not always guarnteed to be in the [0,1] range though. So a coordinate of 1.2 would become -0.2 which will not always sample the correct texel (depending on texture wrapping mode). -- Sebastian Sylvan +46(0)736-818655 UIN: 44640862