Created
January 12, 2016 13:39
-
-
Save marco-we/ee9e5ccea948814364ff to your computer and use it in GitHub Desktop.
pbo_readpixels
This file contains hidden or 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
const uint32_t width = frameBuffer.m_width; | |
const uint32_t height = frameBuffer.m_height; | |
const uint32_t length = width*height*4; | |
GLuint pboId; | |
GL_CHECK(glGenBuffers(1, &pboId) ); | |
GL_CHECK(glBindBuffer(GL_PIXEL_PACK_BUFFER, pboId) ); | |
GL_CHECK(glBufferData(GL_PIXEL_PACK_BUFFER, length, 0, GL_STREAM_READ) ); | |
GL_CHECK(glBindFramebuffer(GL_FRAMEBUFFER, frameBuffer.m_fbo[0]) ); | |
GL_CHECK(glReadBuffer(GL_COLOR_ATTACHMENT0) ); | |
GL_CHECK(glReadPixels(0, 0, width, height, m_readPixelsFmt, GL_UNSIGNED_BYTE, 0) ); | |
GLubyte* src = (GLubyte*)glMapBuffer(GL_PIXEL_PACK_BUFFER, GL_READ_ONLY); | |
if (src) | |
{ | |
g_callback->screenShot(NULL, width, height, width*4, src, length, true); | |
glUnmapBuffer(GL_PIXEL_PACK_BUFFER); | |
} | |
glBindBuffer(GL_PIXEL_PACK_BUFFER, 0); | |
glDeleteBuffers(1, &pboId); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment