Upside down bitmaps in OpenGL

I have a windows CBitmap that I am trying to display using glDrawPixels() but OpenGL displays it upside down. I know what causes this effect. Is there any source code out there that will do this for me.

Thanks in advance.

Aren’t windows bitmaps held upside down in memory?

You can either flip the texture coordinates or flip the memory buffer.

why don’t you just use some gumpy image manipulation program to… <takes a big and dramatic breath> invert the pictures? Surely this isn’t a dramatic leap in logic?

but if you’re loading them from disk as a user-provided thing, then inverting bitmaps in memory isn’t exactly rocket science, either… unless i’m completely missing something here.

Also consider glPixelZoom(1,-1), if you are excessively lazy.

  • Matt

Yeah, I took the time and just did it myself. I guess I am just lazy at heart.

Thanks for the responses.

I have same problem, But flipping memory takes too much time for real-time animation. Is there any way to solve this problem fast enough for real-time rendering ???

my board is Oxygen GVX210

Mark -

As matt said, if you’re using drawpixels use glPixelZoom(1, -1). If you’re texturemapping change the y texture coordinate to 1-y.

This fixes the problem without any memory juggling.

It’s weird, though, that you say this is too slow to be interactive. The only reason not to flip the image during your program’s startup initialization would be if you were loading them during the program. If you’re doing this, isn’t the load time much worse than memory flip time anyway?

– Zeno