0

I have successfully loaded a .jpg image using the library libsoil-dev as found for Debian using the command

    uchar* img = SOIL_load_image(pfname_texture.c_str(),
      &img_width, &img_height, NULL, 0);

The latter two parameters are int* channels and int force_channels whatever that may mean in detail, but they seem to touch stuff like the alpha channel.

Using said command I know width and height of the image in pixels.

Now I want to flop it horizontally (meaning the left and right edges switch sides). This would be easy if I knew the size of uchar* img. However, as things stand I do not, because I cannot be sure how many uchars make up one pixel. Plus I do not know how the pixels are ordered in memory (linewise, columnwise, from top to bottom or vice versa, you name it). Any ideas?

Markus-Hermann
  • 789
  • 11
  • 24
  • Reading code I use from a tutorial I stumble about glTexImage2D(..,type=GL_UNSIGNED_BYTE,..). Given the fact that my program works (ignoring the mirrored texture) this seems to be the size of one pixel. Is this always true? Plus: Still missing the ordering information... – Markus-Hermann Apr 26 '15 at 18:56
  • Coming back to my own question... this seems useful: https://www.opengl.org/wiki/Pixel_Transfer#Pixel_layout – Markus-Hermann Apr 28 '15 at 07:32

1 Answers1

0

Have you try mapping your texture out differently, for example:

glBegin(GL_QUADS);
glTexCoord2f(1, 1); glVertex3f(0, 798, 0); // 0, 1
glTexCoord2f(1, 0); glVertex3f(0, 0, 0); // 0, 0
glTexCoord2f(0, 0); glVertex3f(1280, 0, 0); // 1, 0
glTexCoord2f(0, 1); glVertex3f(1280, 798, 0); // 1, 1
glEnd();

here I switched the x coordinate in glTexCoord2f (first argument) with it's opposite, so glTexCoord2f(1, 1) would become glTexCoord2f(0, 1).