Flip (Mirror Vertical) a texture

Started by
2 comments, last by SelethD 11 years, 5 months ago
I have been having issues 'building' a texture from several others. At first I thought I needed to 'blit' one texture upon the other, then I realized, I need to 'render' onto a texture.

So , I have my src textures, and I render them onto my destination texture, this works great, until I then try to use that destination texture, and its totally upside down, mirrored.

After some reading, it appears this is a common issue with rendering onto a texture.

I dont really feel like making a duplicate for all my text drawing, sprite drawing functions just to make them reverse the Y

So, my question is.... once I have my destination texture, is there an easy way to simply Flip the texture, so then when I do use it to render, it will be correct.

I was thinking... is it possible to render the texture onto itself?

such as, if I have my dst texture as my render target, can I simply render it to itself, on a quad with an inverted texture Y coord?

Thanks for any advice.
Advertisement
Ok, I have tried to render a quad textured with the 'render target' texture, onto itself, and this works.

However, i cant figure out to flip it vertically, I tried to swap the UV for the Y portion (cant remember if the Y is the U or the V) when drawing the quad, but it displays it scrambled, instead of mirrored.

Any suggestions on how to render the quad with the mirrored texture?

Thanks.
You either need to invert the y coord (y = 1-y) or best to flip the texture before uploading it to the GPU.
Thanks, I inverted the y-coord. All is well

This topic is closed to new replies.

Advertisement