If you want to use juce-loaded images for OpenGL textures, you will want to preprocess them to swap the red and blue channels if you’re using Windows.
The code is obvious, but it might save someone a minute:
static void exchangeRedAndBlue(Image* image) {
int lineStride, pixelStride;
uint8* pixels = image->lockPixelDataReadWrite(
0, 0, image->getWidth(),
image->getHeight(),
lineStride,
pixelStride);
uint8 temp;
int index = 0;
for(int i = 0; i < image->getWidth(); i++) {
for(int j = 0; j < image->getHeight(); j++) {
index = (i * image->getHeight() + j) * pixelStride;
temp = pixels[index + 0];
pixels[index + 0] = pixels[index + 2];
pixels[index + 2] = temp;
}
}
image->releasePixelDataReadWrite(pixels);
}
I am using 1.46 - I know there was a change to images recently so hopefully this still works.