JoeMac
11-26-2001, 10:44 AM
Hi Everyone,
I realize this is a common question, but reviewing the faq's and redbook hasn't helped. Its probably an assumption I'm making, so maybe a few thousand fresh eyes may help. I'm trying to read the back buffer into an array, do some image processing on the pixel values, write the array back to the back buffer, then swap buffers. I haven't even made it to the image proc. point since I can't seem to get Draw pixels to work. Her's the code:
GLubyte Pixels = (GLubyte *)calloc((2*640*480*4),sizeof(GLubyte));//2* to make sure
if(Pixels==NULL)
exit(0);
glReadBuffer(GL_BACK);
glReadPixels(0,0,640,480,GL_RGBA,GL_UNSIGNED_BYTE, Pixels);
//image processing to go here
glDrawBuffer(GL_BACK);
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);//Wind->Clear();
glRasterPos2i(0,0);
glDrawPixels(640,480,GL_RGBA,GL_UNSIGNED_BYTE,Pixe ls);
SwapBuffers();
Any suggestions?
Joe
I realize this is a common question, but reviewing the faq's and redbook hasn't helped. Its probably an assumption I'm making, so maybe a few thousand fresh eyes may help. I'm trying to read the back buffer into an array, do some image processing on the pixel values, write the array back to the back buffer, then swap buffers. I haven't even made it to the image proc. point since I can't seem to get Draw pixels to work. Her's the code:
GLubyte Pixels = (GLubyte *)calloc((2*640*480*4),sizeof(GLubyte));//2* to make sure
if(Pixels==NULL)
exit(0);
glReadBuffer(GL_BACK);
glReadPixels(0,0,640,480,GL_RGBA,GL_UNSIGNED_BYTE, Pixels);
//image processing to go here
glDrawBuffer(GL_BACK);
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);//Wind->Clear();
glRasterPos2i(0,0);
glDrawPixels(640,480,GL_RGBA,GL_UNSIGNED_BYTE,Pixe ls);
SwapBuffers();
Any suggestions?
Joe