Reputation: 997
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?
Upvotes: 0
Views: 517
Reputation: 1
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).
Upvotes: 0