   SDL/OpenGL color not quite right
  Hey all. Once again sorry for posting something that you guys must hate seeing. Im going from sdl to opengl and am currently able to load a bitmap and display it with an alpha value. Problem is, that the color is slightly off. I've looked up a million posts and all the endian stuff but no luck.I tend to make stupid mistakes, so if you see it, thank you for your help.int loadTexture (char * filename){    SDL_PixelFormat RGBAFormat;    RGBAFormat.palette = 0; RGBAFormat.colorkey = 0; RGBAFormat.alpha = 0;    RGBAFormat.BitsPerPixel = 32; RGBAFormat.BytesPerPixel = 4;    #if SDL_BYTEORDER == SDL_BIG_ENDIAN    RGBAFormat.Rmask = 0xFF000000; RGBAFormat.Rshift = 0; RGBAFormat.Rloss = 0;    RGBAFormat.Gmask = 0x00FF0000; RGBAFormat.Gshift = 8; RGBAFormat.Gloss = 0;    RGBAFormat.Bmask = 0x0000FF00; RGBAFormat.Bshift = 16; RGBAFormat.Bloss = 0;    RGBAFormat.Amask = 0x000000FF; RGBAFormat.Ashift = 24; RGBAFormat.Aloss = 0;    #else    RGBAFormat.Rmask = 0x000000FF; RGBAFormat.Rshift = 24; RGBAFormat.Rloss = 0;    RGBAFormat.Gmask = 0x0000FF00; RGBAFormat.Gshift = 16; RGBAFormat.Gloss = 0;    RGBAFormat.Bmask = 0x00FF0000; RGBAFormat.Bshift = 8; RGBAFormat.Bloss = 0;    RGBAFormat.Amask = 0xFF000000; RGBAFormat.Ashift = 0; RGBAFormat.Aloss = 0;    #endif    SDL_Surface * orig = NULL;    orig = IMG_Load(filename);    SDL_SetColorKey(orig, SDL_SRCCOLORKEY, SDL_MapRGB(orig->format, 0, 0, 0));    if(orig == NULL){   printf("SDL_image error: \"%s\" couldn't be loaded\n", filename);   return 0;    }    SDL_Surface * conv = SDL_ConvertSurface(orig, &RGBAFormat, SDL_SWSURFACE);    SDL_SetColorKey(conv, SDL_SRCCOLORKEY, SDL_MapRGBA(conv->format, 0, 0, 0,0));  SDL_FreeSurface(orig);    SDL_LockSurface(conv);  glGenTextures(1, &texture);    printf("%d\n", texture);    glBindTexture(GL_TEXTURE_2D, texture);    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, conv->w, conv->h, 0, GL_BGRA, GL_UNSIGNED_BYTE, conv->pixels);   glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);    glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);    glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_BLEND);    SDL_FreeSurface(conv);    return 1;}The entire file can be located here: http://files.edibleonline.com/main/Personal/colors%20sdl_ogl.zipThis will be the last problem I bug you guys with. Once this is done, I'll post it so others can use it for help.Thanks for your time!   
  Looks like your shift values are backwards. eg.RGBAFormat.Rmask = 0xFF000000; RGBAFormat.Rshift = 0;I think that should beRGBAFormat.Rmask = 0xFF000000; RGBAFormat.Rshift = 24;Because the idea is that you shift from the right to the left.   ;  Changing the shifts didn't seem to change the outcome at all. The shifts don't seem to have any affect on it. Any other ideas?   ;  The other problem is that your GL format appears to be wrong.Your RGBAFormat is in R/G/B/A order, but you are specifying GL_BGRA as the pixel format. Surely that should be GL_RGBA? Perhaps you are just getting the 2 pixel format arguments to glTexImage2D the wrong way around.   ;glTexImage2D SpecEdit:According to it, the 7th parameter format to your call to glTexImage2D which you've given "GL_BGRA" isn't among the alternatives.format parameter alternatives:Quote:Specifies theformat of the pixel data.The following symbolic values areaccepted:GL_COLOR_INDEX, GL_RED, GL_GREEN, GL_BLUE,GL_ALPHA, GL_RGB, GL_RGBA, GL_LUMINANCE, andGL_LUMINANCE_ALPHA.So maybe it could be that. [wink][Edited by - programering on September 6, 2008 10:48:17 AM];  Thanks for everyones help. You guys were right about the rgb thing, but the colors were still out. Turns out this line: glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_BLEND); Wasnt needed and was making my textures slightly purple. Thanks for all your support :D   ;Quote:Original post by programeringglTexImage2D SpecEdit:According to it, the 7th parameter format to your call to glTexImage2D which you've given "GL_BGRA" isn't among the alternatives.The fact that it compiles ok would make that less likely. I believe GL_BGRA is an extension that several platforms provide these days.