void copy_from(buffer& source) { source.unmap(); source.bind(); GL(glBindTexture(GL_TEXTURE_2D, id_)); GL(glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width_, height_, FORMAT[stride_], TYPE[stride_], NULL)); GL(glBindTexture(GL_TEXTURE_2D, 0)); source.unbind(); source.map(); // Just map it back since map will orphan buffer. }
void copy_to(buffer& dest) { dest.unmap(); dest.bind(); GL(glBindTexture(GL_TEXTURE_2D, id_)); GL(glReadBuffer(GL_COLOR_ATTACHMENT0)); GL(glReadPixels(0, 0, width_, height_, FORMAT[stride_], TYPE[stride_], NULL)); GL(glBindTexture(GL_TEXTURE_2D, 0)); dest.unbind(); GL(glFlush()); }