2

I am rendering an orange pumpkin in opengl es 1.1 on the iphone.

In the simulator the pumpkin renders as expected - it is the correct orange color.

When I test on a device the pumpkin becomes blue.

What is causing this and how can I fix it?

thanks

edit, here is my texture load code:

void LoadPngImage(const std::string& filename) {
    NSString* basePath = [NSString stringWithUTF8String:filename.c_str()];
    NSString* resourcePath = [[NSBundle mainBundle] resourcePath];
    NSString* fullPath = [resourcePath  stringByAppendingPathComponent:basePath];
    UIImage* uiImage = [UIImage imageWithContentsOfFile:fullPath];
    CGImageRef cgImage = uiImage.CGImage;
    m_imageSize.x = CGImageGetWidth(cgImage);
    m_imageSize.y = CGImageGetHeight(cgImage);
    m_imageData = CGDataProviderCopyData(CGImageGetDataProvider(cgImage));
}

void* GetImageData() {
    return (void*)CFDataGetBytePtr(m_imageData);
}

edit, adding more code:

glGenTextures(1, &m_texture);
glBindTexture(GL_TEXTURE_2D, m_texture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

m_resourceManager->LoadPngImage("Pumpkin64.png");
void* pixels = m_resourceManager->GetImageData();
ivec2 size = m_resourceManager->GetImageSize();
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, size.x, size.y, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
m_resourceManager->UnloadImage();
Ryan
  • 5,883
  • 13
  • 56
  • 93
  • Are you using vertex colors or a texture? If you're using a texture, how are you loading the image from storage? – genpfault Feb 14 '11 at 22:46
  • @genpfault, just texture no vertex colors. I have edited my question with the texture load code. – Ryan Feb 15 '11 at 21:38
  • What does your code to create and populate your OpenGL texture object(s) look like? – genpfault Feb 15 '11 at 22:03
  • @genpfault, I edited in more code. thanks. also, i think this is the same issue: http://stackoverflow.com/questions/4012035/opengl-es-iphone-alpha-blending-looks-weird. see his own accepted answer. he says he's solved the issue my changing the extension to something other than .png or by using IPHONE_OPTIMIZE_OPTIONS | -skip-PNGs. i tried both of those and neither worked. but i think the packing up of things for the device is altering the png, while the simulator doesn't take that same step. – Ryan Feb 16 '11 at 06:42

1 Answers1

2

I suspect an endianess problem is flipping your RGB triplets around, since orange is RGB(255,165,0) and RGB(0,165,255) is rather blue.

I'd look at your texture image loading code to make sure it gives the same output on x86 and ARM.

genpfault
  • 51,148
  • 11
  • 85
  • 139
  • Hi, yes, I think it has something to do with rgba vs bgra. here is my texture load: – Ryan Feb 15 '11 at 21:34