Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

MetaKnight

Wierdest Thing with PCX?

This topic is 5852 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Advertisement
Can be:

FileLoading: Wrong handling of the images width/height and/or
wrong fragment size/type.

TextureHandling: Wrong pixel (un)packing at ogl.

Any other idea?

Do you have to have a license from ID, when using their file formats?

Share this post


Link to post
Share on other sites
I read an article over @ flipcode on the Quake (2 I think) BSP file format, the guy who wrote it said he had asked John Carmack about the legal issues with the file format and he had said that they don''t care if other people use their file format but you can''t use ID''s tools to create them for comercial products without getting a licence.


http://www.flipcode.com/tutorials/tut_q2levels.shtml

Share this post


Link to post
Share on other sites
Then it''s a good thing ID opensourced their BSP compiler a long time ago, hmm? And the editor doesn''t even belong to ID anymore.

But, what has ID software to do with PCX?

Share this post


Link to post
Share on other sites
ID has nothing to do with PCX (as far as I know), Martin was asking about licences for ID file formats because Meta is loading a PCX texture onto a MD2 model which is a quake 2 model file created by ID.

Share this post


Link to post
Share on other sites
ID has nothing to do with PCX (as far as I know), Martin was asking about licences for ID file formats because Meta is loading a PCX texture onto a MD2 model which is a quake 2 model file created by ID.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
quote:
by xstreme2000:

Martin was asking about licences for ID file formats because Meta is loading a PCX texture onto a MD2 model which is a quake 2 model file created by ID.





Wasn''t his discussion about a problem with the pcx''s stored in a md2 model-file?

Share this post


Link to post
Share on other sites
maybe this code will not show up correctly but this is the codei use for my texture manager and it loads pcx , maybe your are messing with the rle format or swapping the r,g,b components
anyway here it is sorry for the comments in italian

bool CLoadPCX::Load( String *FileName, String *ErrStr )
{
TYPE_PALETTE pal[256];
int PCX_XSIZE;
int PCX_YSIZE;
int PCX_SIZE;
char data, num_reps;
int count = 0;
FILE *in;
PCX_Header pcx_header;

byte *ImageBuffer;
byte *PaletteBuffer;

ImageBuffer=NULL;
TextureImage=NULL;
PaletteBuffer=NULL;

PaletteBuffer=new byte [ 768 ] ;

if ((in = fopen (FileName->c_str(), "rb")) == NULL)
{
*ErrStr="can''t load file";
return (false);
}
else
fread (&pcx_header, PCX_HEADER_SIZE, 1, in);

// Controlliamo che esso sia un file PCX, che sia codificato secondo lo RLE,
// e che non sia a 24 bit (cioŠ un''immagine true color)

if (pcx_header.Manufacturer != 10)
{
*ErrStr="not a pcx file";
return (false);
}
if (pcx_header.Encoding != 1)
{
*ErrStr="bad bits";
return (false);
}
if (pcx_header.NumberOfPlanes > 1)
{
*ErrStr="bad signature";
return (false);
}

// Adesso ci calcoliamo la lunghezza, la larghezza e la dimensione della
// immagine. Essendo globali, le variabili successive potranno tornarci
// utili in numerose occasioni

PCX_XSIZE = (pcx_header.Xmax - pcx_header.Xmin) + 1;
PCX_YSIZE = (pcx_header.Ymax - pcx_header.Ymin) + 1;
PCX_SIZE = PCX_XSIZE * PCX_YSIZE;

// Allochiamo sufficiente memoria per contenere l''immagine.

if (!(ImageBuffer = new byte [ PCX_SIZE+1 ] ) )
{
*ErrStr="can''t load file";
return (false);
}

// Ciclo principale di decodifica dell''immagine

while (count <= PCX_SIZE)
{
// Leggiamo un byte
fread (&data, 1, 1, in);

// Controlliamo se il byte letto Š un RLE
if ((data & 0xc0) == 0xc0) // S, Š un RLE
{
// Calcoliamo il numero delle ripetizioni
num_reps = data & 0x3f;

// Leggiamo il colore
fread (&data, 1, 1, in);

// Memorizziamolo num_reps volte
while (num_reps-->0)
ImageBuffer[count++] = data;
}
else

// No, its a colour

ImageBuffer[count++] = data;
}

// Lettura e normalizzazione della palette

fseek (in, -768L, SEEK_END);
for (count=0; count<256; count++)
{
fread (&pal[count].r, 1, 1, in);
fread (&pal[count].g, 1, 1, in);
fread (&pal[count].b, 1, 1, in);
}

register int j,i;
j=0;
for ( i=0; i<256; i++ )
{
PaletteBuffer[ j ]=pal[ i ].r;
PaletteBuffer[ j+1 ]=pal[ i ].g;
PaletteBuffer[ j+2 ]=pal[ i ].b;
j+=3;
}

TextureImage=new byte [ PCX_SIZE*3+1 ];

for (j = 0; j < PCX_YSIZE; j++)
{
for (i = 0; i < PCX_XSIZE; i++)
{
TextureImage[3*(j*PCX_XSIZE+i)+0]=PaletteBuffer[3*ImageBuffer[j*PCX_XSIZE+i]+0];
TextureImage[3*(j*PCX_XSIZE+i)+1]=PaletteBuffer[3*ImageBuffer[j*PCX_XSIZE+i]+1];
TextureImage[3*(j*PCX_XSIZE+i)+2]=PaletteBuffer[3*ImageBuffer[j*PCX_XSIZE+i]+2];
}
}

delete ( PaletteBuffer );
delete ( ImageBuffer );

width=PCX_XSIZE;
height=PCX_YSIZE;
components=24;
type=GL_RGB;
bits=3;

return true;

}


Share this post


Link to post
Share on other sites
"Do you have to have a license from ID, when using their file formats?"

xstreme2000 is right, Id software does not legally protect any of their file formats... They are one of the companies that support the game development community the most.

"Wasn''t his discussion about a problem with the pcx''s stored in a md2 model-file?"

There are no textures in md2 model files (and that''s good).

If you get too much trouble with PCX, try implementing TGA loading, TGA files have many cool advantages, and the conversion is easy.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!