iPhone OpenGL color bug
Hey everyone, I'm having a bit of a color bug with openGL that I hope someone can clear up for me. The image below contains two instances of the same code, except the top is executing in the simulator while the lower image is a screenshot from my iPhone 3G running 3.1.3. I'm compiling with the 4.0 SDK. The shapes you see in the image are all textures, but for some funky reason the nongreen textures on the iPhone seem to get their colors shifted. Any ideas?
![[Image: wlq048.jpg]](http://i33.tinypic.com/wlq048.jpg)
Your blue and and red channels are swapped somewhere along the line. As an example, that'll happen when you have a BGRA texture and you tell OpenGL it's RGBA.
BGRA
RGBA
See how the B and R are swapped?
BGRA
RGBA
See how the B and R are swapped?
I have the simulator and the device both running ES1.1, and therefore they execute the exact same code. I suppose they could somehow handle the texture loading differently and the swap happens there, but that seems unlikely.
It's very likely if you're using pngs.
Where you call glTexImage, examine your image data. Dump out a couple of pixels in hex and make sure they're what you think they are.
Where you call glTexImage, examine your image data. Dump out a couple of pixels in hex and make sure they're what you think they are.
I am in fact using PNGs, so I'll check that out.
I ended up using a different method of loading pngs because I needed to be able to handle pvrs anyhow, so it's all taken care of. I do still have a weird error though, for some reason after making a few modifications to a png, it will stop working in my code (the primitive is rendered as if there is no texture there). It's as though something changes in the texture after a few saves that breaks the png loader. I'm using GIMP to make the textures.
Xcode destroys PNGs during the build process for the iPhone by default... though that wouldn't explain why it would happen after a few builds...
It's not multiple builds of my app that causes it, it's multiple changes and saves made in gimp. The resolution doesn't change and the image is exported to a png with the same settings each time. Sometimes I can save what I believe to be the exact same image and it happens.
The next thing I'd do is go with arekkusu's suggestion but take it further and dump *all* the pixels to desktop just after they're loaded, as a tga or something simple, so that you can see the raw data that's being loaded. I'd want to do that to figure out if this is an image issue or whether it's a draw issue.
Possibly Related Threads...
| Thread: | Author | Replies: | Views: | Last Post | |
| Problem with the graphics color on a videogame for iphone | femmedragon | 6 | 1,854 |
Dec 16, 2012 07:37 PM Last Post: SethWillits |
|
| ? Find color value of 'pixel' in color buffer? | Elphaba | 1 | 3,446 |
Jul 22, 2009 01:23 PM Last Post: Bachus |
|
| OpenGL Color Buffer Overwrite | Talyn | 8 | 5,243 |
Jan 4, 2009 02:44 AM Last Post: papillon68 |
|
| OpenGL Color map | nkpkd | 4 | 3,473 |
Mar 30, 2007 10:47 AM Last Post: nkpkd |
|
| OpenGl color map mode | nkpkd | 0 | 2,495 |
Mar 29, 2007 07:09 PM Last Post: nkpkd |
|

