Sign in to follow this  

Accessing Frame Buffer Data?

This topic is 3593 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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]

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
thx death!

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]

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

This topic is 3593 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this