In a project I’m working on an image is loaded with the SDL_image
library and then the *pixels are looped through and the color values
are extracted with SDL_GetRGBA to be stored in RGB(A) order for
passing to OpenGL texture creation functions. However, on my
machine, which is MacOS X.1.2, the colors come out all swapped
around when the texture is drawn. Greens are blues, reds are greens,
all mixed up, I can’t tell you exactly what’s swapped right now, I
haven’t
bothered isolating the swaps. I think it’s probably one of these
problems:
- Endian problem with OpenGL texture creation.
- SDL_GetRGBA isn’t returning the right color values in the right
variables.
For example, maybe SDL_GetRGBA is storing the green value in the variable
I pass for it to store blue. This could be an SDL_GetRGBA bug or it
could be
caused by:
- SDL_image doesn’t set the R, G, B, and Amasks right, so SDL_GetRGBA
is returning the wrong values.
Any suggestions or comments?
-Randall Leeds
Don’t know what SDL_image is, but images loaded with SDL_LoadBMP
has byte order BGR. Maybe this is the case here also?
Randall Leeds wrote:>
In a project I’m working on an image is loaded with the SDL_image
library and then the *pixels are looped through and the color values
are extracted with SDL_GetRGBA to be stored in RGB(A) order for
passing to OpenGL texture creation functions. However, on my
machine, which is MacOS X.1.2, the colors come out all swapped
around when the texture is drawn. Greens are blues, reds are greens,
all mixed up, I can’t tell you exactly what’s swapped right now, I
haven’t
bothered isolating the swaps. I think it’s probably one of these
problems:
- Endian problem with OpenGL texture creation.
- SDL_GetRGBA isn’t returning the right color values in the right
variables.
For example, maybe SDL_GetRGBA is storing the green value in the variable
I pass for it to store blue. This could be an SDL_GetRGBA bug or it
could be
caused by:
- SDL_image doesn’t set the R, G, B, and Amasks right, so SDL_GetRGBA
is returning the wrong values.
Any suggestions or comments?
-Randall Leeds
SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl