I am attaching a PBO to the Opengl framebuffer and than use glMapBuffer() to get access to the data.
I am passing the data to a Bluefish card for SDI Output.
The issue is that the resultant output appears inverted.
How can i invert y axis of the data being pointed by PBO pointer.
glReadBuffer(GL_FRONT);
glBindBuffer(GL_PIXEL_PACK_BUFFER, pbo[writeIndex]);
// copy from framebuffer to PBO asynchronously. it will be ready in the NEXT frame
glReadPixels(0, 0, SCR_WIDTH, SCR_HEIGHT, GL_RGB, GL_UNSIGNED_BYTE, nullptr);
// now read other PBO which should be already in CPU memory
glBindBuffer(GL_PIXEL_PACK_BUFFER, pbo[readIndex]);
// map buffer so we can access it
void* downsampleData = (unsigned char *)glMapBuffer(GL_PIXEL_PACK_BUFFER,GL_READ_ONLY);
This is how i am trying to flip data after advised by Nicol and i get the desired result.
unsigned char OriginalData[width * height * 4];
unsigned char FlippedData[width * height * 4];
memcpy( OriginalData , downsampleData , sizeof( OriginalData) ); // copy data from the pointer.
for( int i = sizeof( OriginalData) - 1; i >= 0 ; i-- )
{
Flippeddata[k] = OriginalData[sizeof( OriginalData) - 1 - 1];
}
You can't. OpenGL always considers the first row to be the bottom row of the image data for any image operation (sending/receiving pixel blocks, fetching texture samples/image data in a shader, etc). So if you want to invert the data you get, you will have to do that manually by copying the data around.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With