Upside Down Texture

BlitzMax Forums/OpenGL Module/Upside Down Texture

TeraBit(Posted 2005) [#1]
Hi all,

I'm doing some copying from the backbuffer to a texture but am a little stumped by something.

When I copy a 16x16 section using:

glCopyTexSubImage2D(GL_TEXTURE_2D, 0, DestX, DestY, SourceX = 10 ,SourceY = 10,16, 16)

It copies a section at the bottom of the screen and does so upside down.

I can offset it like so:

glCopyTexSubImage2D(GL_TEXTURE_2D, 0, DestX, DestY, SourceX = 10 ,SourceY = GFX_HEIGHT - 10,16, 16)

And it copies the correct section. But it's still upside down. It seems to be using the Bottom Left as the origin, even though the glOrtho2D is set up to use the top left. Is this behaviour set? How do you get around this without having to flip the onscreen image as well?


TeraBit(Posted 2005) [#2]
I've worked around it for now by rendering upside down (yeah crazy I know). If anyone figures out how to change this, I'd be very interested.


ImaginaryHuman(Posted 2005) [#3]
It is normal, afaik OpenGl takes the bottom left corner as 0,0 origin, and reads texture data upside down.

When you turn a pixmap into an image, for example, it flips the image vertically.


TeraBit(Posted 2005) [#4]
Fair enough. I think I'll flip all the textures and reverse the UVs on my models. That way it will be the right way up and nobody is the wiser ;)