xDexx
2003.05.06, 03:44 PM
i have been looking the QTValuePak and this is what i ended up doing in my program.
GWorldPtr gw;
FSRef fsref;
FSSpec spec;
Boolean dirSize;
Rect imageSize;
void* buffer;
FSPathMakeRef((const UInt8*)"/Users/brettsawyer/Desktop/face.pict", &fsref, &dirSize);
FSGetCatalogInfo(&fsref, kFSCatInfoNone, NULL, NULL, &spec, NULL);
buffer = malloc(160);
QTNewGWorldFromPtr(&gw, k32ARGBPixelFormat, 0, NULL, NULL,
0, buffer, 128);
drawFile(&spec, &imageSize);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, 1);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8,32, 32, 0,GL_BGRA_EXT, GL_UNSIGNED_INT_8_8_8_8_REV,buffer);
DisposeGWorld(gw);
free(buffer);
glBegin(GL_QUADS);
glTexCoord2i((x - TILESIZE/2),(y - TILESIZE/2));
glVertex2i((x - TILESIZE/2),(y - TILESIZE/2));
glTexCoord2i((x + TILESIZE/2),(y - TILESIZE/2));
glVertex2i((x + TILESIZE/2),(y - TILESIZE/2));
glTexCoord2i((x + TILESIZE/2),(y + TILESIZE/2));
glVertex2i((x + TILESIZE/2),(y + TILESIZE/2));
glTexCoord2i((x - TILESIZE/2),(y + TILESIZE/2));
glVertex2i((x - TILESIZE/2),(y + TILESIZE/2));
glEnd();
then here is the drawFile() function
void drawFile(const FSSpec *fss, const Rect *boundsRect)
{
GraphicsImportComponent gi;
GetGraphicsImporterForFile(fss, &gi);
GraphicsImportSetBoundsRect(gi, boundsRect);
GraphicsImportDraw(gi);
CloseComponent(gi);
}
my image is 32x32 pixels. it displays an image but its all screwed up and is nothing like the one i made. what am i doing wrong?
GWorldPtr gw;
FSRef fsref;
FSSpec spec;
Boolean dirSize;
Rect imageSize;
void* buffer;
FSPathMakeRef((const UInt8*)"/Users/brettsawyer/Desktop/face.pict", &fsref, &dirSize);
FSGetCatalogInfo(&fsref, kFSCatInfoNone, NULL, NULL, &spec, NULL);
buffer = malloc(160);
QTNewGWorldFromPtr(&gw, k32ARGBPixelFormat, 0, NULL, NULL,
0, buffer, 128);
drawFile(&spec, &imageSize);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, 1);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8,32, 32, 0,GL_BGRA_EXT, GL_UNSIGNED_INT_8_8_8_8_REV,buffer);
DisposeGWorld(gw);
free(buffer);
glBegin(GL_QUADS);
glTexCoord2i((x - TILESIZE/2),(y - TILESIZE/2));
glVertex2i((x - TILESIZE/2),(y - TILESIZE/2));
glTexCoord2i((x + TILESIZE/2),(y - TILESIZE/2));
glVertex2i((x + TILESIZE/2),(y - TILESIZE/2));
glTexCoord2i((x + TILESIZE/2),(y + TILESIZE/2));
glVertex2i((x + TILESIZE/2),(y + TILESIZE/2));
glTexCoord2i((x - TILESIZE/2),(y + TILESIZE/2));
glVertex2i((x - TILESIZE/2),(y + TILESIZE/2));
glEnd();
then here is the drawFile() function
void drawFile(const FSSpec *fss, const Rect *boundsRect)
{
GraphicsImportComponent gi;
GetGraphicsImporterForFile(fss, &gi);
GraphicsImportSetBoundsRect(gi, boundsRect);
GraphicsImportDraw(gi);
CloseComponent(gi);
}
my image is 32x32 pixels. it displays an image but its all screwed up and is nothing like the one i made. what am i doing wrong?