- void * CPBuffer::ReadPixelsAsync ( int width, int height )
- {
- int nextPBO = filledPBO ^ 1;
- void * res;
- if ( ! canAsyncRead ) return ( NULL );
- // Initiate the asynchronous transfer into the next PBO.
- glReadBuffer ( GL_BACK );
- glBindBufferARB ( GL_PIXEL_PACK_BUFFER_EXT, PBOs [nextPBO] );
- glReadPixels ( 0, 0, width, height, GL_BGRA_EXT, GL_UNSIGNED_BYTE, NULL);
- // Retrieve data from the current PBO.
- glBindBufferARB ( GL_PIXEL_PACK_BUFFER_EXT, PBOs [filledPBO] );
- res = glMapBufferARB ( GL_PIXEL_PACK_BUFFER_EXT, GL_READ_ONLY_ARB );
- filledPBO = nextPBO;
- mappedPBO = 1;
- return ( res );
- }