Jump to content
  • Advertisement
Sign in to follow this  
VitaliBR

[SDL] Inverted image

This topic is 2992 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

I'm loading an image with SDL for texturing a polygon with OpenGL.
But the image is loaded upside down.

"The solution is to turn the SDL surface upside-down before using it in glTexImage2D, so the rest of the program can use the normal OpenGL conventions. To do so, one can use a flip function, or directly save accordingly the flipped images beforehand. "

I don't have idea how to do this

Share this post


Link to post
Share on other sites
Advertisement
One option would be simply to set up your OpenGL texture coordinates to accommodate the image orientation.

If you want to flip it, and if you're using an image loading API that offers a 'vertical flip' option (some do), use that.

Otherwise, you can flip the SDL_Surface image data manually if you want. For this, you'll need to grab the image height, pitch and/or image width, and a pointer to the raw data, and swap the rows manually starting at the top and bottom and moving inward.

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!