Man, I was messing with this a while back. I know
that the format of the data in memory has to be RGBA.
I was reading data into a void*, and you seem to be
reading into a pixmap. Dunno if that matters or not.
If you look at the memory after the glReadPixels call,
you should see something like: RR GG BB FF (the alpha
channel will be FFs). The address that the picture
data lives at is the last parameter of the
glReadPixels function. In your case, it looks like
whatever address GetPixBaseAddr is returning.
I didn't have to mess with the INT_8_8_8_8/REV unless
I was going from PPC to Intel. I was getting that
freaky pastel look as well, but only on the Intel
side. My image was either really blue or pink.
Probably because I had the data out of order (ie: I
was reading FF RR GG BB which means that the red value
is always FF).
Try this code and see if this helps you out any
better. Most people seem to reference the glgrab.c
example. It looks similar to what you have, but I
never had a problem going from PPC to PPC.
--- Jeff Schindler <email@hidden>
> We're using glReadPixels to capture the screen. I'm
> seeing an issue where
> the bytes come out unexpectedly swapped. I have a
> G4 and a MacBook Pro
> where our code works correctly. But we have another
> G5 machine where the
> bytes are swapped (giving the resulting pixmap a
> blue tint). I'm guessing I
> need to specify GL_UNSIGNED_INT_8_8_8_8_REV at
> times, but I cannot determine
> the determining factor for that. GL_PACK_SWAP_BYTES
> is off on all 3
> machines. Any assistance is much appreciated. BTW
> - I've inherited this
> code and I'm an OpenGL novice.
> CGLContextObj glContextObj;
> CGLPixelFormatObj pixelFormatObj;
> long numPixelFormats;
> // it looks like a CGDirectDisplayID and
> DisplayIDType are
> // equivalent...
> const CGOpenGLDisplayMask displayMask =
> CGLPixelFormatAttribute attribs =
> CGLChoosePixelFormat(attribs, &pixelFormatObj,
> CGLCreateContext(pixelFormatObj, NULL,
> pixelFormatObj = NULL;
> // Grab stuff
> GLint viewport;
> glGetIntegerv(GL_VIEWPORT, viewport);
> const GLint width = viewport;
> const GLint height = viewport;
> Rect qdBounds = (*this->GetDevice())->gdRect;
> GWorldPtr offscreen = NULL;
> OSErr err = UtilityAllocateGWorld(&offscreen, 32,
> if ((err == noErr) and (offscreen != NULL))
> PixMapHandle pixmap =
> glFinish(); /* Finish all OpenGL commands
> glPixelStorei(GL_PACK_ALIGNMENT, 4); /* Force
> 4-byte alignment */
> ((**pixmap).rowBytes & 0x3fff) / 4);
> glPixelStorei(GL_PACK_SKIP_ROWS, 0);
> glPixelStorei(GL_PACK_SKIP_PIXELS, 0);
> glReadPixels(0, 0, width, height,
> PixelShuffle pixelShuffle = Null_shuffle;
> swizzleBitmap(offscreen, pixelShuffle);
> // end stuff
> return offscreen;
> Do not post admin requests to the list. They will be
> Mac-opengl mailing list
> Help/Unsubscribe/Update your Subscription:
> This email sent to email@hidden
"Everyone is allergic to giant rocks hitting them in the head!"
-Thorrin's elf chick after casting a 'meteor swarm' spell ;)
Be a better Globetrotter. Get better travel answers from someone who knows. Yahoo! Answers - Check it out.
Do not post admin requests to the list. They will be ignored.
Mac-opengl mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden