SFML community forums

Help => Graphics => Topic started by: Bakura on August 25, 2007, 06:43:07 pm

Title: Functions to flip images ?
Post by: Bakura on August 25, 2007, 06:43:07 pm
Hi !

Before I loaded my images textures with Corona and in order to render the texture correctly, I had to flip them about the X axis (or Y axis, don't remember).

Now I load them with sfImage :

Code: [Select]
sfImage Image;

if (!Image.LoadFromFile (m_sMaterial.nomTexture))
return EXIT_FAILURE;

   glGenTextures (1, &m_uiTexture);
   glBindTexture (GL_TEXTURE_2D, m_uiTexture);

glTexParameteri (GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE);
   glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
   glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);

glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, Image.GetWidth(), Image.GetHeight(), 0, GL_RGBA, GL_UNSIGNED_BYTE, Image.GetPixelsPtr());


The texture can be seen, but it's not well drawn, like those I loaded with corona without the flip. So, is there any flip functions in order to draw that ? Or it can be another problem ?
Title: Functions to flip images ?
Post by: Laurent on August 25, 2007, 07:06:31 pm
So far, it has always worked fine. Are you sure your texture coordinates are ok ?
Title: Functions to flip images ?
Post by: Hybrix on August 25, 2007, 07:15:18 pm
Hi (Sorry for my english :s ),

Look

Code: [Select]

    gluOrtho2D(  0,  1024, 768, 0);


If you're function is :

Code: [Select]

    gluOrtho2D(  0,  1024, 0, 768);


The image is flip on the Y axis.

This :
Code: [Select]

    gluOrtho2D( 1024,  0, 768, 0);

The image is flip on the X axis.

It's just a idea  :roll:  .
Title: Functions to flip images ?
Post by: Bakura on August 25, 2007, 07:33:29 pm
Quote from: "Laurent"
So far, it has always worked fine. Are you sure your texture coordinates are ok ?


I just checked with Corona and a flip, and it works, so the problem is with SFML I think. Furthermore the ASE file was generated with Blender, so I don't think :/.
Title: Functions to flip images ?
Post by: Laurent on August 25, 2007, 08:35:13 pm
But why do you also need a flip with Corona, if your code is ok ?
Title: Functions to flip images ?
Post by: Bakura on August 26, 2007, 08:06:05 pm
I don't know :/.
Title: Functions to flip images ?
Post by: Laurent on August 26, 2007, 09:06:39 pm
Because your code is wrong ? :roll:
Title: Functions to flip images ?
Post by: ferdekk on August 27, 2007, 02:07:07 am
same problem here, but i solve that.

data in corona,freeimage.lib (img->getPixels() or FreeImage_GetBits) are placed from bottom to top. not top to bottom.

use:
FreeImage_FlipVertical(FIBITMAP *dib);.  (in freeimage)
or
FlipImage(Image* source, CA_Y); (in corona)

thats not foul of sfml.
sry, for english.
Title: Functions to flip images ?
Post by: Bakura on August 27, 2007, 03:48:30 pm
Oh ! I think I remember the problem :|. Sorry Laurent, I think it's my fault.

In fact, in order to avoid "flip" the image, I just remember that when I was using Corona, I flip the image with Paint, so I didn't need to do that in the program. But now, with SFML... The texture is still flip with Paint (I have some models I always use for my tests :p) :p.

I'll try to "unflip" the image :).
Title: Functions to flip images ?
Post by: Laurent on August 27, 2007, 04:07:51 pm
Ok ;)