Yeah, you are on the right track. Don’t know much about this problem, since I never bumped into it myself.
The problem in the pixelformat. Think GL_BGR (in some form) is available as an extension. Take a look at your <GL/gl.h> file, and look for GL_BGR in there, and use it.
When you say ‘My function…’, I suppose you have written it yourself. If so, why not loop through each pixel in the bitmap, and swap red and blue component before returning…
There is a GL_BGR extension you can use but when I got a similar problem once I just swapped the red and blue components in the array just a bob said. This way I don’t have to remember to keep switching from BGR to RGB and so forth. Much easier.
Yes, I notices my error. The constant must be GL_BGR_EXT (for the “format” parameter). This way it works fine. I will see if I can change the R and B component before passing the bits…THX for the help!
Ok. the last parameter the LoadBitmap function returns is GLubyte type. Can I make the switch between blue and red in this variable? I think I cant. The function that reads the bits in the BMP is:
if (fread(mybits, 1, bmpsize, fp) < bmpsize)
{
fclose(fp);
return (NULL);
}
My problem is that I dont know WHERE to do the changes…any idea?
for(unsigned int k=0; k<width; ++k)
{
tempColor =imageJpg[jwidth3+3k+0]; // temp = red
imageJpg[jwidth3+3k+0] =imageJpg[jwidth3+3k+2]; // red = blue
imageJpg[jwidth3+3k+2] = tempColor; // blue =temp = red
}
What this basically does is looks that the huge array in memory that holds all the texture info. First it looks at the first 3 values and switches the first and 3rd. Then it looks at the 2nd 3 values and switches the 1st and 3rd values again. I continue this until I reach the end of the data for the texture.