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 L开发者_C百科oadPngImage(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();
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.
精彩评论