Sign in to follow this  
justinCedric2nd

OpenGL Flip texture in DevIL

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
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this