Hi all,
Recently my programmer and I have been doing some last minute porting work on our game (going to Mac) and we've run into a bit of a roadblock. On Linux and Windows, the game works great. We use SDL 1.2 in conjunction with OpenGL to render our graphics. On Mac however, we've run into a unique glitch in that the color channels for the entire window are mixed up from the usual RGBA to BGRA.
As an example, here's a picture of the game on a mac with
messed up colors:
http://i.imgur.com/1xZrFk0.pngAnd here's a picture of the game with
normal colors:
http://i.imgur.com/OYuo52t.pngWe have no idea why the game is doing this. At first we tried changing our glTexImage2D calls to use the different channel arrangement, so:
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, image->w, image->h, 0, GL_RGBA, GL_UNSIGNED_BYTE, image->pixels);
Would become something like
glTexImage2D(GL_TEXTURE_2D, 0, GL_BGRA, image->w, image->h, 0, GL_BGRA, GL_UNSIGNED_BYTE, image->pixels);
But this didn't completely solve the problem. Most graphics were the right colors, except for some hardcoded gui elements, which had switched from a reddish-brown to a mossy green color.
To draw those elements we feed glColor directly with a 32bit unsigned int from which 8 bit color channels are extracted. ie:
glColor3ui( (Uint8)(color>>16), (Uint8)(color>>8), (Uint8)(color) );
We don't know why these colors would still be messed up, since by the official opengl docs the first argument is always red, the second green, and the last blue.
Can anyone with more experience in opengl, sdl, or mac development help us with this???