hi!
similar code I've written several years ago looks something
like this; I'm not sure if this really helps -- but anyway:
void readLeft(void *, SoAction *)
{
static int c;
unsigned char *p;
unsigned char *tail = (unsigned char *) ImageLeft + sizeof ImageLeft;
// printf("readframe_left_buffer %d\n", c);
glPushMatrix();
glReadBuffer(GL_FRONT);
glPixelStorei(GL_PACK_ALIGNMENT, 1);
glReadPixels(0, 0, IMAGEW, IMAGEH, GL_RGBA, GL_UNSIGNED_BYTE, ImageLeft);
for (p = (unsigned char *) ImageLeft; p < tail; )
*(p++) &= 0xf0;
glPopMatrix();
}
(actually I don't remember why I was doing
*(p++) &= 0xf0;
part; maybe it's not necessary at all :p)
this routine itself is combined into the scenegraph
as a form of callback:
...
SoCallback *callbackL = new SoCallback;
callbackL->setCallback(readLeft);
sceneL->addChild(callbackL);
...
ps.,
I also have noticed, doing this is probably what mostly everyone wants:
void ditherOff(void *, SoAction *)
{
glDisable(GL_DITHER);
}
...
SoCallback *callback1R = new SoCallback;
callback1R->setCallback(ditherOff);
sceneR->addChild(callback1R);
...
regards,
kenji @ fairfax, VA.
|