Load PCX instead of BMP

I want to change this routine from loading BMP to loading PCX files.

Anyone?

int CTexture::LoadGLTexture(char *filename, int num)
{
int Status=FALSE; // Status Indicator

AUX_RGBImageRec *TextureImage[1]; // Create Storage Space For The Texture

memset(TextureImage,0,sizeof(void *)*1); // Set The Pointer To NULL

// Load The Bitmap, Check For Errors, If Bitmap’s Not Found Quit
if (TextureImage[0]=LoadBMP(filename))
{
if( num+1 > total)
{
total=num+1;
texture2d.resize(num+1);
logfile.Log(" Texture space increased to handle %d texture(s)", num+1);
}
Status=TRUE; // Set The Status To TRUE

  glGenTextures(1, &texture2d[num]);					// Create The Texture

  // Typical Texture Generation Using Data From The Bitmap
  glBindTexture(GL_TEXTURE_2D, texture2d[num]);
  glTexImage2D(GL_TEXTURE_2D, 0, 3, TextureImage[0]->sizeX, TextureImage[0]->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[0]->data);
  glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
  glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);

}

if (TextureImage[0]) // If Texture Exists
{
if (TextureImage[0]->data) // If Texture Image Exists
{
free(TextureImage[0]->data); // Free The Texture Image Memory
}

  free(TextureImage[0]);								// Free The Image Structure

}
return Status; // Return The Status
}

The PCX format is extremely simple to deal with. Here is the PCX format spec from www.wotsit.org :
http://www.wotsit.org/download.asp?f=pcx

[This message has been edited by DFrey (edited 10-14-2000).]

Be careful using RLE compressed PCXs, sometimes they’re bigger than the uncompressed variant (depends on the program that saved them).

No, it depends on the picture data, because one fourth of all possible byte codes you have to code in TWO bytes in the compressed format (all from 11000000 to 11111111). If there is a complex image with little repeating pixels, the ‘compressed’ image becomes larger than the original.

Regards
Marc

Originally posted by Marc:
No, it depends on the picture data,

Thanks
Ok, I put this unluckily… of course it depends on the data to compress (as any compression algorithm does). What I meant was, if the exporting program is smart, it determines by itself if the compression enlarges the file size and in this case saves the image uncompressed.

I know this is O/T, but frankly I don’t really understand why so many 3D applications (especially games) store their textures in an un- or only barely compressed format… even with today’s mass storage media, decompressing, say LZ77 or Huffman data, is for sure faster than loading the bigger files from CD…
So why not (quality-loss free) compress the hell out of the texture data, save one CD (and many CD switches during the game) and get rid of the sometimes annoyingly long loading times?