Jump to content
  • Advertisement
Sign in to follow this  
MarkB

OpenGL Targa upside down!

This topic is 4840 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

There is some code in the book "OpenGL Game Programming" near the end of chapter 7 for loading bitmaps and targa files. There LoadBitmapFile() works, but when using there LoadTGAFile() the image is displayed upside-down! In looking at there source on the CD it seems they convienenttly left out the tga file, so there example don't even work. Does the TGA format store the last pixel first? If so, this is an error in the book. I just put my own .tga file there so it could actually open it, and sure enough there example code shows it upside down to! I'm trying to figure out where the problem is. I can't post the code because it would violate a copyright, but if you are determined to help you can download it for yourself at http://glbook.gamedev.net/source/ch07.zip The source is in the bitmapex4 directory in main.cpp. The meat of the code is in the function LoadTGAFile() Thanks for any help.

Share this post


Link to post
Share on other sites
Advertisement
Sometimes a TGA file is indeed stored upside down. Look at the code at http://gpwiki.org/index.php/LoadTGACpp, there is a function to flip it back.

Share this post


Link to post
Share on other sites
check out the targa spec (pdf search for it)
the origin is either at the bottomleft or topleft,
the best way i found was just to flip the image over yourself when u load it (takes practically no cpu time)

Share this post


Link to post
Share on other sites
Solutions:

1) Use an image lib (there are libs that allow you to load every existing file format)

2) Flip the image yourself; this is done once loaded

3) Flip the texture!


glMatrixMode(GL_TEXTURE);
glLoadIdentity();
glScalef(1, -1, 1);

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!