//***********************************************
//** LoadTexture
//** Loads a texture from a file and stores it in buffer
//***********************************************
void LoadTexture( PIXEL *buffer, const char *file, int width, int height )
{
int size = width * height * 3; //Size in bytes of the image
//If the file is okay
if( texFile.is_open() )
{
texFile.seekg( 18, ios_base::beg ); //Skip the header
texFile.read( (char*)buffer, size ); //Read the data
texFile.close();
}
//If the file is not okay
else {
int l = size >> 2, i;
for( i = 0; i < l; i++ )
((long*)buffer)[i] = 0;
l = size % 4;
if( l )
{
l += (i *= 4);
for( ; i < l; i++ )
((char*)buffer)[i] = 0;
}
}
}