Last active
December 12, 2019 11:09
-
-
Save Akira-Hayasaka/da97a9cf8d1c891653b82ac6892ea403 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// .h | |
ofBufferObject pixelBufferBack, pixelBufferFront; | |
// on setup | |
pixelBufferBack.allocate(3840 * 2160 * 4, GL_DYNAMIC_READ); | |
pixelBufferFront.allocate(3840 * 2160 * 4, GL_DYNAMIC_READ); | |
// func | |
void fast_tex_to_px(ofTexture& tex) | |
{ | |
ofPixels pix2; | |
tex.copyTo(pixelBufferBack); | |
pixelBufferFront.bind(GL_PIXEL_UNPACK_BUFFER); | |
unsigned char * p = pixelBufferFront.map<unsigned char>(GL_READ_ONLY); | |
pix2.setFromExternalPixels(p, tex.getWidth(), tex.getHeight(), OF_PIXELS_RGBA); | |
pixelBufferFront.unmap(); | |
pixelBufferFront.unbind(GL_PIXEL_UNPACK_BUFFER); | |
swap(pixelBufferBack, pixelBufferFront); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment