PDA

View Full Version : Pict Textures



07-04-2000, 07:02 AM
I've been using this code to load a Pict file and then use it as a texture, but, glTexImage2D() had been giving me fits; the variable PICTDATA cannot be used as a pointer to the image data. What is the problem?
Here is the code:

void GETPICT(Str255 NAME); //All files must be 256x256
void GETPICT(Str255 NAME)
{
OSErr noError;
long DIRID;
short REFERENCEID;
long PICTSIZE;
Ptr PICTDATA;

DIRID = LMGetCurDirStore();

noError = HOpen(0, DIRID, NAME, fsRdWrPerm, &REFERENCEID);

if (!noError)
ExitToShell();

noError = GetEOF(REFERENCEID, &PICTSIZE);

if (!noError)
ExitToShell();

PICTSIZE = PICTSIZE - 512;

noError = SetFPos(REFERENCEID, fsFromStart, 512);

if (!noError)
ExitToShell();

noError = FSRead(REFERENCEID, &PICTSIZE, PICTDATA);

if (!noError)
ExitToShell();

glPixelStorei(GL_UNPACK_ALIGNMENT, 1);

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);

glTexImage2D(GL_TEXTURE_2D, 0, 3, 256, 256, GL_RGB, GL_INT, PICTDATA);

glEnable(GL_TEXTURE_2D);
}

cartilago
07-04-2000, 04:56 PM
The problem is that the pict data you are reading directly from the file is stored
in compressed form, to get the pict file
in to texture memory you should decompress it first , for anyone interested
in some good code to get pict files in to texture memory including the alpha channel please e-mail me at jchavezh@tvazteca.com.mx