Accessing Frame Buffer Data?
Hello all!
I m exporting quicktime movies using glReadPixels… as you can imagine, it is really slow. I m wondering if we can access the FBOs data directly to speed things up?
thx
[Edited by - golgoth13 on February 12, 2008 9:48:53 PM]
There is no such thing as direct access.
Use a good format like GL_BGRA with your glReadPixels call.
Don't forget to use GL_UNSIGNED_BYTE as well.
There was some nvidia doc that showed the different speed and formats.
I could suggest PBO but for taking screenshots at each frame, perhaps it won't help.
Use a good format like GL_BGRA with your glReadPixels call.
Don't forget to use GL_UNSIGNED_BYTE as well.
There was some nvidia doc that showed the different speed and formats.
I could suggest PBO but for taking screenshots at each frame, perhaps it won't help.
You can random access the result of FBO using texture lookup. That's the primary goal of FBO.
Quote:You can random access the result of FBO using texture lookup.
hummm... I m sorry, I m not too sure what you meant by random acsess... is there anyway way to get a void* of the FBO data some how?
Quote:Original post by golgoth13
hummm... I m sorry, I m not too sure what you meant by random acsess... is there anyway way to get a void* of the FBO data some how?
Try glMapBufferARB. It provides a void* to the FBO data. Give the GPU enough time to finish rendering the buffer before you call glMapBufferARB, otherwise it will be just as slow as glReadPixels. Also, make sure that glMapBufferARB returns a pointer to AGP memory, not VRAM. Reading data from VRAM with the CPU is painfully slow.
thx death!
im trying to figure this out... did you meant something like:
I m not sure i got it right... m_TextureId is use as a FBO as well.... still digging.
[Edited by - golgoth13 on February 13, 2008 7:18:19 PM]
im trying to figure this out... did you meant something like:
void PBuffer::Set(){ if (m_TextureId == 0) { /// Texures buffer. glGenFramebuffersEXT(1, &m_TextureId); glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_TextureId); /// Color texture. GenerateTexture(m_FrameTexture); glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, m_FrameTexture->GetDimension(), m_FrameTexture->GetId(), 0); Char *l_data = m_FrameTexture->GetImage()->GetData(); glBindBuffer(GL_PIXEL_UNPACK_BUFFER, m_TextureId); glBufferData(GL_PIXEL_UNPACK_BUFFER, m_Width * m_Height * 4, l_data, AX6_BUFFER_DYNAMIC_DRAW); l_data = (Char*) glMapBuffer(GL_PIXEL_UNPACK_BUFFER, GL_READ_WRITE_ARB); glBindBuffer(GL_ARRAY_BUFFER, 0); } else { glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_TextureId); }}
I m not sure i got it right... m_TextureId is use as a FBO as well.... still digging.
[Edited by - golgoth13 on February 13, 2008 7:18:19 PM]
That code looks about right, but you won't be able to use the buffer while it's mapped. You must call glUnmapBuffer before glDrawArrays/Elements. glMapBuffer is used for obtaining direct access to buffer data so you can quickly read/write the data and call glUnmapBuffer as soon as you are done.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement