Jump to content
  • Advertisement
Sign in to follow this  
justinCedric2nd

OpenGL Flip texture in DevIL

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

Hi. I'm using DevIl for loading my textures but the images get displayed top-down so I want to flip them vertically. I use C# and the Tao framework for the OpenGL and DevIl stuff. Here's how I load the texture:
...
   int _texture;

   Il.ilInit();
   //Ilu.iluInit();
   Ilut.ilutInit();
   Ilut.ilutRenderer(Ilut.ILUT_OPENGL);

// **1**

   _texture = Ilut.ilutGLLoadImage("knight512.png");   

// **2**
From the DevIl docs I know the functions Ilu.iluFlipImage() and Il.ilOriginFunc(Il.IL_ORIGIN_UPPER_LEFT);Il.ilEnable(Il.IL_ORIGIN_SET) but I could not find out how /when to use them correctly. In the example above I tried both placing at **1** and **2** with no effect. Do you have a clue what's missing? What would be the easiest way to flip the texture?? regards. jc

Share this post


Link to post
Share on other sites
Advertisement
I am not sure but doesn't DevIL handle this for you when you specify Ilut.ilutRenderer(Ilut.ILUT_OPENGL) ?

Anyways, OpenGL requires an image to be aligned to lower left. Not all formats store images this way. Depending on the format you use and the co-ordinate system you apply try flipping the texture.

For OpenGL

ILinfo ImageInfo;
iluGetImageInfo(&ImageInfo);
if( ImageInfo.Origin == IL_ORIGIN_UPPER_LEFT )
{
iluFlipImage();
}





If you are following the DirectX style then textures are aligned to upper left corner.So

ILinfo ImageInfo;
iluGetImageInfo(&ImageInfo);
if( ImageInfo.Origin == IL_ORIGIN_LOWER_LEFT )
{
iluFlipImage();
}



Share this post


Link to post
Share on other sites
the other option is to change the origin on the source image..
cant remember exactly how, but if i make an intelligent guess it would be ilSetParameter/ilSetImageOrigin or something OpenGL'esq

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!