I am trying to write data to the frame buffer, and then read it back. But when I read it back, the array is not populated with the data I submitted.
What am I doing wrong?
Here is my code:
... pBuff is a float * holding image data ...
//CREATE & BIND TO THE FRAME BUFFER
glGenFramebuffersEXT(1, &framebuffer);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, framebuffer);
//CREATE PBO
int num_elements = rows * cols;
size_tex_data = sizeof(float) * num_elements;
glGenBuffers(1, &pbo_source);
glBindBuffer(GL_PIXEL_UNPACK_BUFFER_ARB, pbo_source);
glBufferData(GL_PIXEL_UNPACK_BUFFER_ARB, size_tex_data, pBuff, GL_DYNAMIC_COPY);
//WRITE TO BUFFER
glBindBuffer(GL_PIXEL_UNPACK_BUFFER_ARB, pbo_source);
glRasterPos2f(0,0);
glDrawPixels( cols,rows,GL_RED,GL_FLOAT,pBuff );
glFlush();
//READ FROM BUFFER
float * retrievalBuff= new float[sideLen*sideLen];
glBindBuffer(GL_PIXEL_PACK_BUFFER_ARB, pbo_source);
glRasterPos2f(0,0);
glReadPixels(0, 0, cols, rows, GL_RED, GL_FLOAT, retrievalBuff);
glFlush();
//save to a file
mv->SaveDataAsPGM(retrievalBuff, rows, cols, "outData.pgm", false);
Thanks in advance!