Original Post
What exactly is [RGBA]shift and [RGBA]loss? I have this texture loading function here: It works, its just that I don't like those stray values there. I want to set those to the proper value but I don't even know what they do.
/////////////////////////////////////////////////
void TextQuad::load_image( std::string filename )
/////////////////////////////////////////////////
{
//The loaded surface
SDL_Surface *LoadedImage = NULL;
//The optimized surface
SDL_Surface *OptimizedImage = NULL;
//The texture surface
SDL_Surface *TextureImage = NULL;
//load image
LoadedImage = IMG_Load( filename.c_str() );
//If the image loaded fine
if( LoadedImage != NULL )
{
//The format
SDL_PixelFormat format;
//Set format
format.palette = NULL;
format.BitsPerPixel = 32;
format.BytesPerPixel = 4;
//Set mask
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
format.Rmask = 0xFF000000;
format.Gmask = 0x00FF0000;
format.Bmask = 0x0000FF00;
format.Amask = 0x000000FF;
#else
format.Rmask = 0x000000FF;
format.Gmask = 0x0000FF00;
format.Bmask = 0x00FF0000;
format.Amask = 0xFF000000;
#endif
//Set shift
format.Rshift;
format.Gshift;
format.Bshift;
format.Ashift;
//Set loss
format.Rloss;
format.Gloss;
format.Bloss;
format.Aloss;
//Optimize image
TextureImage = SDL_ConvertSurface( LoadedImage, &format, SDL_SWSURFACE );
//Get rid of temp surface
SDL_FreeSurface( LoadedImage );
}
//Convert to 2^n surface
//If the image loaded fine
if( TextureImage != NULL )
{
//Get the dimensions of surface
w = TextureImage->w;
h = TextureImage->h;
//Generate texture
glGenTextures( 1, &texture );
//Use newly made texture
glBindTexture( GL_TEXTURE_2D, texture );
//Create texture from loaded surface
glTexImage2D( GL_TEXTURE_2D, 0, 4, TextureImage->w, TextureImage->h, 0, GL_RGBA, GL_UNSIGNED_BYTE, TextureImage->pixels );
//Set filtering
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
//Get rid of temp surface
SDL_FreeSurface( TextureImage );
}
}