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);
}