Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Functions to flip images ?  (Read 12041 times)

0 Members and 1 Guest are viewing this topic.

Bakura

  • Newbie
  • *
  • Posts: 46
    • View Profile
Functions to flip images ?
« 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 ?
Etudiant EFREI, Promo 2013
http://bakura.developpez.com

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Functions to flip images ?
« Reply #1 on: August 25, 2007, 07:06:31 pm »
So far, it has always worked fine. Are you sure your texture coordinates are ok ?
Laurent Gomila - SFML developer

Hybrix

  • Newbie
  • *
  • Posts: 48
    • View Profile
    • http://www.sybrix.fr
Functions to flip images ?
« Reply #2 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:  .
SFML user .

Bakura

  • Newbie
  • *
  • Posts: 46
    • View Profile
Functions to flip images ?
« Reply #3 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 :/.
Etudiant EFREI, Promo 2013
http://bakura.developpez.com

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Functions to flip images ?
« Reply #4 on: August 25, 2007, 08:35:13 pm »
But why do you also need a flip with Corona, if your code is ok ?
Laurent Gomila - SFML developer

Bakura

  • Newbie
  • *
  • Posts: 46
    • View Profile
Functions to flip images ?
« Reply #5 on: August 26, 2007, 08:06:05 pm »
I don't know :/.
Etudiant EFREI, Promo 2013
http://bakura.developpez.com

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Functions to flip images ?
« Reply #6 on: August 26, 2007, 09:06:39 pm »
Because your code is wrong ? :roll:
Laurent Gomila - SFML developer

ferdekk

  • Newbie
  • *
  • Posts: 6
    • View Profile
Functions to flip images ?
« Reply #7 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.

Bakura

  • Newbie
  • *
  • Posts: 46
    • View Profile
Functions to flip images ?
« Reply #8 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 :).
Etudiant EFREI, Promo 2013
http://bakura.developpez.com

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Functions to flip images ?
« Reply #9 on: August 27, 2007, 04:07:51 pm »
Ok ;)
Laurent Gomila - SFML developer

 

anything