I am currently moving data from the CPU host to OpenGL memory and I am using pixel buffer object to do that. I can copy the whole image like so:
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, buffer);
GLubyte * data = (GLubyte *)glMapBuffer(GL_PIXEL_UNPACK_BUFFER,
GL_READ_WRITE);
// copying 4 channel 8 unsigned char data
memcpy(data, cpu_data, rows * cols * 4);
This is actually quite fast. However, now I need to copy a rectangular subimage of the data. So, in essence I will need to do multiple memcpy to do this, which could take a performance hit as I will have to copy things line by line. I was wondering if somehow there is a faster way to perform this operation.